Topic : How to protect one flash page from writing at loading the hex file

Forum : ARM

Original Post
Post Information Post
January 13, 2009 - 3:54pm
Guest

Hello all

i use the last page of my STM32 Controller as a EEProm replacement. But: each time i load a new compiled file to the target this section is overwritten with FF. How can i avoid this? Or better: How can i load specific datas in this section?

Thanks in advantage

Socrates (i know, that i don't know anything)

Replies
Post Information Post
+1
0
-1
June 24, 2009 - 11:22am
Guest

I'd like to second this request. I too have data in the high end of flash that I'd like to persist across debug sessions.

It looks like my RLink Pro is erasing the device before programming - is there a way I can get it to just erase the flash sectors specified in the hex file?

+1
0
-1
June 25, 2009 - 11:05am
Raisonance Support Team

Hi,

For now this is not possible. Among other problems, Ride has to know the full content of the flash for debugging. We plan to implement a feature like that some day, but I cannot tell you when, as I have a lot of other urgent things to do and it's not as easy as it seems.

Here is some possible workaround for keeping the existing data there: before debugging, read the flash back using RFlasher and save the data section in a hex file. Then, include this hex file in your project for debugging as if it was a source file. That should do the trick as Ride will then reprogram the same thing it has just erased, but you have to do it again every time the data section changes.

For writing specific data at a given address, there is a much cleaner, 'normal' way: You just have to use a custom linker script that declares two memory regions for the Flash, and then send your data to the second region. See the GettingStartedARM document for how to use a custom linker script in Ride. See the linker documentation from gcc to see how to modify linker scripts. See the 'non_debuggable_code' section in the CircleOS linker script for an example of how to 'split the Flash and direct data to the second section'.

I hope it helps.

Best Regards,

Vincent