Home arrow Support arrow Forums

Luminary Micro Forums

<< Start < Prev 1 2 Next > End >>

ddrennan

Senior Boarder
Click here to see the profile of this user

2008/06/18 08:49

working with data in flash

This is a rookie question, but I am struggling to find resources on how to do this.

I would like to store some data values in flash (mainly an address) which can be changed at run time (typically only once).

I am using the LM3S101 and IAR EWARM.

1) How do I direct the compiler to place the data at a particular place? e.g. last 1kB of flash

2) What type of qualifier should be used on the variable? e.g. const or volatile

3) Are there any examples or resources that I could look at for more info?

Thanks,
Duncan

login or register to reply

awneil

Expert Boarder
Click here to see the profile of this user

2008/06/18 14:54

Re:working with data in flash

ddrennan wrote:
3) Are there any examples or resources that I could look at for more info?
This is going to be compiler-specific, so IAR support would be the place to start...

login or register to reply

ddrennan

Senior Boarder
Click here to see the profile of this user

2008/06/27 05:57

Re:working with data in flash

I've been reading (and re-reading) IAR documentation about linker files, but feel like I am just going around in circles. Maybe it is time for a slightly different approach...

My idea would be to have a reserved area of the flash (say the last 1kB) which would store the parameters. There would be parameter_read() and parameter_write() functions which would read and persist the values from/to flash.

If I use the Luminary bootloader then I can update the code without overwriting the parameters (set FLASH_RSVD_SPACE to 0x00000400).

Is it possible to write data (such as a serial number) to the reserved space at the time of programming? What are the methods to programme the reserved flash space (other than via the application)?

Post edited by: ddrennan, at: 2008/06/27 06:03

login or register to reply

cb1

Platinum Boarder
Click here to see the profile of this user

2008/06/27 12:50

Re:working with data in flash

Interesting issue - we too use IAR and understand(?) similarly.

Believe that the C compiler may be the villan here - it may over-write your data. Was told in the past that an ALL assembler program "could" satisfy your requirement - but omG - assembler!

A year or so ago IAR further stated that most C compilers could/would NOT guarantee that certain data/variables/constants etc. may be placed "most anywhere" in otherwise "free" flash space. (I will search the notes if you need exact detail)

That said - LMI's bootloader does indeed seem to allow you to reserve significant "free space" high up in the flash. Wonder just "how much" of this area can be "reserved" - and just "how" the bootloader overcomes the C compiler's "random" data locating???

Two simple-minded alternate solutions may provide some comfort:
1) use an external eeprom to store/retrieve this data
2) use LMI device w/hibernate module. This includes 64 - 32 bit words of battery backed, nov-volatile memory which are safe/secure. (I believe - in theory)

If you have the time/desire perhaps you could perform some "brute force" boot-loads and subsequently examine the flash to see if data locates/persists as you hoped/expected... Wonder if "reads" of flash would uncover this "random" data placement by the C compiler...

Post edited by: cb1, at: 2008/06/29 09:59

login or register to reply

ddrennan

Senior Boarder
Click here to see the profile of this user

2008/06/30 03:12

Re:working with data in flash

I have discovered a couple of things so far. Firstly, there is no way to erase the flash via IAR EWARM and the J-Link debugger. It would seem that the Segger J-Flash programme is needed (which is just irritating). Are there other software combinations that can do this with the J-Link?

The main thing that I need to do now is to write a serial number to the protected part of flash at programming time (bootloader protects the reserved space). It would be nice if there was an easy way to do this via the bootloader.

It is certainly possible to stop the linker from placing data in certain areas. For example if you wanted to make sure no programme data was written into the last kB of flash, then the linker script (for LM3S101) would change from,

Code:

 define region FLASH mem:[from 0x00000000 to 0x00001FFF];



to

Code:

 define region FLASH mem:[from 0x00000000 to 0x00001BFF];



In my understanding that would make sure that no programme code or data would be placed in the last kB (am I right/wrong?)

login or register to reply

cb1

Platinum Boarder
Click here to see the profile of this user

2008/06/30 10:54

Re:working with data in flash

Thanks for your report. I remain fearful that "certain" data may show up in "unexpected" locations.

Segger does mesh well with IAR - any port in a storm to help us. Check their site for updates - also new capabilities. (some may cost)

We have built/sold/shipped several hundred LMI based control boards - without "realizing" that our IAR could NOT erase flash! (just kept debugging/optimizing/verifying and then shipping)

Your 3S101 may NOT have ALL of the "hooks" included with the newer "Fury" class devices. (we use the 48 pin, mature parts)

A broader issue may be a simple means to read or write data placed either in the "protected" bootloader space or in other areas of flash - outside of your code and data regions. I personally would have preferred more detail in AP Note 1248...

login or register to reply
<< Start < Prev 1 2 Next > End >>