cancel
Showing results for 
Search instead for 
Did you mean: 

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

HMüll.4
Associate III

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!

 

5 REPLIES 5

Or you could just set up In-Application Programming (IAP):

https://www.st.com/resource/en/application_note/an4657-stm32-inapplication-programming-iap-using-the-usart-stmicroelectronics.pdf

 

See also ST's Open Bootloader:

https://github.com/STMicroelectronics/stm32-mw-openbl

 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
TDK
Guru

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

If you feel a post has answered your question, please click "Accept as Solution".
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.

 


@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.

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

> there is no dedicated way to write to and boot from RAM directly, to do this, some specific hacks are necessary.

I don't know how you arrived at that. The methods to write to and boot from RAM directly are the same as those to write to and boot from FLASH. These methods include using a programmer over the SWD port or using the bootloader, or making your own bootloader. Only difference is the RAM is volatile, so you'll need to do it each time power is lost.

If you feel a post has answered your question, please click "Accept as Solution".