Skip to main content
Graduate
April 14, 2025
Question

STM32 MCUs: load data to RAM and boot from there?

  • April 14, 2025
  • 2 replies
  • 622 views

Hi,

I'm aware of the BOOT0 pin which is available on most STM32 MCUs and allows to select the device being booted from Flash.

Now my problem is, once shipped to an end user, this flash can't be updated easily. So it would be better to have a more simple possibility to update this firmware. In my setup, there is an other micro-controller available which commands and controls that STM32 MCU. No my idea is, to load the STM32-program from this controller to the RAM of the STM32 MCU and then start this dynamically loaded firmware.

So...is this possible? Can I download some code to an STM32 MCU and then start it via some internal boot-selection.-function?  Or do I have to do some hacks for my own?

Any ideas and suggestions are welcome :)

Thanks!

 

    This topic has been closed for replies.

    2 replies

    Super User
    April 14, 2025
    Super User
    April 14, 2025

    So...is this possible? Can I download some code to an STM32 MCU and then start it via some internal boot-selection.-function?

    Yes. it's possible. Your program would need to write data to the ram, then boot there either with BOOTx pins and option bytes, or jumping there directly.

     

    However, it seems an unnecessary intermediate step. If you can program the RAM, why not program the FLASH instead and cut out this part of the process? Using the built-in system bootloader to program the device seems like a better solution than having a separate MCU dedicated to the task.

    STM32 microcontroller system memory boot mode - Application note

    USART protocol used in the STM32 bootloader - Application note

    HMüll.4Author
    Graduate
    April 15, 2025
    Using the built-in system bootloader to program the device seems like a better solution than having a separate MCU dedicated to the task.

    The point is, the separate MCU is already there, it has not to be added just for programming the RAM, it is a major part of the whole board. And: this separates MCU's firmware can be updated easily. Because of that, my idea was to access the RAM of this sub-MCU. Yes, I can program the flash too, but this in every case is slower than just writing to RAM.

    So to sum up the answers from here: there is no dedicated way to write to and boot from RAM directly, to do this, some specific hacks are necessary.

     

    Super User
    April 15, 2025

    @HMüll.4 wrote:

    So to sum up the answers from here: there is no dedicated way to write to and boot from RAM directly, to do this, some specific hacks are necessary.


    Yes.

    These microcontrollers are designed to run from Flash.

    You will also note that the amount of Flash is significantly larger than the amount of RAM - so you would only be able to run (relatively) very small programs entirely from RAM.