cancel
Showing results for 
Search instead for 
Did you mean: 

FLASH_ERROR_PG - what does that mean?

tkjmail2
Associate II
Posted on March 29, 2010 at 00:26

FLASH_ERROR_PG - what does that mean?

15 REPLIES 15
Posted on May 17, 2011 at 13:44

Depends on your lifetime erase/write expectations? 1,000 or 1,000,000

The flash is perfectly fine for storing calibration data, configuration data, etc.

Just be aware that erasing and writing it will slow down code executing in other parts of the flash. I think the 1MB STM32 has banks, you'd have to check.

-Clive

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on May 17, 2011 at 13:44

>>I don't understand this sentence. Writing 0x0234 over 0x1234 functions on your stm32? The 0x0234 can be read back from flash? The flash signals an error, but does write nevertheless?

That's what I think I saw yesterday, but was unable to duplicate this morning. Writing the same value errors, only writing zero succeeds.

The write of zero could be used to invalidate a previously written structure.

-Clive

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
tkjmail2
Associate II
Posted on May 17, 2011 at 13:44

Hi Clive.

Do you have any examples on this?

As the problem is that I have the Touch Screen calibration settings saved to start with, but then afterwards the user should also be able to change some other user-interface settings. So how should you place this in the Flash if you have to erase a complete page before you can rewrite it?

Fx. if we place the touch screen at one page, and then the user-interface settings just after, then if we erase that page, we will erase the touch screen calibration data too!

Best Regards

Thomas Jespersen

Posted on May 17, 2011 at 13:44

Hi Thomas,

There are a couple of ways of attacking this.

On the STM32F103RET part the flash pages are 2KB. Depending on how many free pages you have you could put calibration data in it's own page, or tack it on the back-end of a page at the end of the firmware if it has space. For example if your firmware goes to 0x0801F6FF there'd be 0x100 bytes of spare space. This would assume you write in only once, and that if you upgraded the firmware you would retain a copy, or move it somewhere else.

When it comes to erasing pages, you can copy critical/old settings to RAM, and rewrite them after the erase. Here you would want to be cautious about the window of vulnerability for the power to fail, or the erase/write to fail.

Another way would be to ping-and-pong between two flash pages, with a sequence number that would permit you locate the most recent setting, but also have the old ones to revert too. To update you would erase the oldest settings, and write the new ones there.

If your settings only take say 256 bytes, you could write up to 8 copies in a 2K page, again either with a sequence number, or checking for a 0xFFFF marker. At startup you could enumerate through the copies to find the most recent.

-Clive

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
htp
Associate II
Posted on May 17, 2011 at 13:44

Look at eeprom emulation examples from ST and modify it using 2 pages where one is always active page and second as backup, in case when first is erased data are restored from second one, same after correctly update eeprom values you must copy all data to second eeprom block.

I suggest you to modify eeprom structure: for example eeprom field number 0x11 with 3 bytes of data ''0x99, 0x88, 0x77'' will looks like a this 0xE0 0x11 0x00 0x03 0x99 0x88 0x77 after this you can put second eeprom field, every data with any size which you need can be stored as specific field number by marker of 0xE0 0x?? you can know this is field block and with next two bytes you can make easy walk over of all fields. This need a lot of changes in original ST eeprom emulation samples but this is good start for you.

eeprom fields are common used in mobile phones exactly for store static factory values and user settings are easy to update/modify/resize/add and with additional backup page with last known good values this works perfect.

tkjmail2
Associate II
Posted on May 17, 2011 at 13:44

That was also my second thoughts, so that will probably be what I'm going to do.

About the EEProm example provided by ST - I couldn't get it working as I thought, as there is only provided a write example, not a read one.

I've tried some of the functions in the library, but I couldn't get it working!

Thomas