This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

example stm32 bootloader for uvision 4?

Hello,

I am looking for a how-to / walk-through for writing a custom bootloader for STM32. I need my device to bootload from attached SPI flash, so I can't use the built-in bootloader. So far I have been unable to find information about how to do this -- can anyone send a pointer to a how-to? (I am using uVision 4).

Thanks,
-David Merrill

Parents
  • AN2557: STM32F10x in-application programming using the USART

    "The purpose of this application note is to provide general guidelines for creating an IAP application... The STM32F10x microcontroller can run user-specific firmware to perform IAP of the microcontroller-embedded Flash memory. This feature allows the use of any type of communication protocol for the reprogramming process (such as CAN, USART, USB).
    USART is the example used in this application note."

    www.st.com/.../familiesdocs-110.html

Reply
  • AN2557: STM32F10x in-application programming using the USART

    "The purpose of this application note is to provide general guidelines for creating an IAP application... The STM32F10x microcontroller can run user-specific firmware to perform IAP of the microcontroller-embedded Flash memory. This feature allows the use of any type of communication protocol for the reprogramming process (such as CAN, USART, USB).
    USART is the example used in this application note."

    www.st.com/.../familiesdocs-110.html

Children
  • Thanks Andy.

    So, just to make sure I understand: I think the way that the example in AN2557 works is the following:

    - IAP driver program gets loaded into the Flash memory at the base address of the Flash (0x0800 0000)

    - User program gets loaded into the flash memory immediately after the IAP driver (0x0800 2000)

    - when the STM32 starts, the IAP driver code checks the state of a button that may or may not be pressed

    - if the button was pressed at startup, it runs the IAP driver, otherwise it jumps to 0x0800 2000 to execute the user program.

    Is that correct? And if so, what do I need to do at compile/link/upload time to put the code in the right places?

    After looking through the project, I have a couple questions: is there a difference between unlocking the flash and disabling write protection?

    (from stm32f10x_flash.c)

    void FLASH_Unlock(void)
    {
      /* Authorize the FPEC Access */
      FLASH->KEYR = FLASH_KEY1;
      FLASH->KEYR = FLASH_KEY2;
    }
    

    Then in common.c, there is a call to:

    FLASH_UserOptionByteConfig
    

    It seems like FLASH_Unlock is always done when the IAP driver starts, and the function that calls FLASH_UserOptionByteConfig can be invoked interactively from the command line.

    Also, it seems that this strategy for bootloading does not make use of the BOOT0 / BOOT1 pins at all -- the system is ALWAYS booting into the Flash (never to the System memory / built-in bootloader) -- is that correct?

    thanks,
    -David