cancel
Showing results for 
Search instead for 
Did you mean: 

How to putg all the code into RAM

SBosc
Associate II

Good morning,

I'm writing a bootloader and I need to put all the code in the RAM and execute from it (the microcontroller is a STM32F733).

The code is already working correctly from the flash.

How can I move it into the RAM?

Thanks in advance

11 REPLIES 11
SBosc
Associate II

@Pavel A.​ 

The idea is to store bootloader into the internal flash, copy it on RAM and jump to RAM to execute the bootloader.

I need it because in my application there's an external watchdog circuit that resets the uC.

Erasing the internal flash sectors takes too long (and the flash stalls during the operation, so I can't execute code to kick the watchdog if sits in flash)

@Community member​ 

The BOOT option is correctly set to the start of the flash, where the bootloader is initially stored before the copy.

About the debugger, are you saying that it loads the content directly into RAM?

If it's true, it should set also the PC to execute directly from RAM...

Am I correct?

>About the debugger

Yes you're correct. The debugger is smart, it knows how to load the program to RAM vs flash, and it knows how to set up the registers and start it. This is, btw, how it loads and executes the "external loaders". Of course you can copy this logic to your own project and load the STM32 code over the debugger interface.