8 years, 11 months ago.

regarding flash memory

wont this code affect the areas where the program is flashed ? if so how can we rectify this?

Question relating to:

IAP code for Freescale platforms

1 Answer

8 years, 10 months ago.

You can overwrite your program flash indeed. Solution is to not do it ;). As long as you don't do anything special the compiler will place everything at the start of your flash. So assuming you use less flash than the total capacity of your mcu, you can safely write at the end of your flash. But that's something for the user to take care of.

Accepted Answer

I use something like this on my LPC micros:

const char dataArea[NUM_PAGES * 256] __attribute__((aligned(256), used)) = {};


The LPC micros I use have 256B pages, so I made dataArea 256B aligned. Simply change 256 to the required alignment for your micro, and replace NUM_PAGES with the number of pages (or sectors) you want to reserve. The linker will reserve a region of flash, and set it to all zeros by default.

posted by Neil Thiessen 01 Jun 2015

I sort of of found the solution , i just printed out all the registers from the end till the start without erasing the flash , when compiling all unused register were set to -1 and the place where the flashed program ends has a 0. So, i just used the remaining registers :D without touching the programmed flash area.

posted by Seeker of Truth , 09 Jun 2015