SparkFun Forums 

Where electronics enthusiasts find answers.

Open source ARM Debugger
User avatar
By jamesjmcdermott
#17014
I am trying to build a program that can save and retrieve data from the FLASH.

I am using the Atmel eval board and their SAM-ICE with IAR's Jumpstart kit.

When I run in Debug (RAM) I can read and write the FLASH area (addr 0x101000). I can see the data change and verify from one run to the next that it is persistent.

When I run in Release (FLASH) I can single step through my code and it appears to be working but when I kick it loose with no single-stepping or breakpoints it does not work.

Are there any tricks or special things I need to do when running out of FLASH and trying to read/write FLASH?
By mlu
#17042
You cannot run the code that writes to flash from flash.
The flash memory controller returns invalid read data while writing, so
the instructions read from flash are nonsense and the code fails.

The solution is to put the instructions that executes the Write Page flash command and wait for the FRDY flag in RAM.
You can put a small subroutine into a RAM block and use the adress of this block as the function pointer.
User avatar
By jamesjmcdermott
#17066
Thanks, I think I accomplished this by declaring my function as __ramfunc?

I had tried this and it appeared to fail. I discovered that using the debugger with Software breakpoints would also yield unpredicatable results.

So now I have __ramfunc and Hardware breakpoints.

And it works! Thanks for the advice!

james