cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F207 RAM Execution

Anvi
Associate III

Hello,

I'm developing on an STM32F207 and I would like to know what the procedure to execute code from RAM is?

I need to modify a couple of sectors of the internal Flash but the F207 does not have banked memory so I would need to execute the flash erase & write operations in RAM. Executing from the internal Flash is causing crashes for me.

I have tried to follow the steps explained here for Keil; but my application still crashes.

Thanks

3 REPLIES 3

You can copy code to RAM, and jump/branch to it. You'd also probably want to move the vector table to RAM, and any functions/libraries the code calls. It can be as simple or complex as you make it. Typically you want to copy small self contained code.

You can also execute from FLASH whilst erasing/writing in different area, the execution will slow as the MCU inserts wait-states. This can be a problem if you have a watchdog.

Your code likely crashes for other reasons, and you should probably figure that out first. There is a mix of 16, 64 and 128KB sectors. Don't expect to erase a sector with active code in it and not crash. Understand what your code is doing, instrument it so you know.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

So, I've made sure the the sectors I'm trying to modify are not being used. I do have a watchdog that I'm temporarily disabling while the flash operations execute. This works fine executing from Flash but fully writing to two 128 Kbyte sectors stalls for about ~3.3 seconds. That's too long for me, and I'd also prefer not to disable the watchdog, even temporarily.

I'm trying to find an example on how to move code to RAM since I've never done this before; but I've been unsuccessful finding anything.

Also, why would I need to move the vector table to RAM as well?

My goal is to prevent the processor from from stalling while I write to the flash; but I understand that the processor cannot read the flash while it is being written. My understanding here is pretty limited; but if I execute my flash operations in RAM, won't that also block because it is writing to the flash?