Data storage Example

Hello,
I’ve written and application that reads data from uart, process received information and sends to a remote server throught GPRS.
But now I want to store this information on flash to avoid data loss when GPRS connection have gone and batteries are empty.

Have anybody an example of how to save/load information to a flash memory?

Any information will be appreciated.

Thanks in advance.

Do you mean an external flash memory device, or the Open-AT flash?

For the Open-AT flash, take a look at the “Application & Data Storage” (A&D) section of the ADL User Guide…

Hi awneil,
I mean OpenAt flash. I’ve read the section that you specified in ADL user guide but isn’t clear for me.
If someone have a simple example to test reading and writing internal flash could be easier to understand.

Thanks.

Can anybody help me?

I think the “Application Download” sample, in serial link mode, might be helpful…?

  • AT+APPDWL downloads an “application” to A&D Storage;

  • AT+APPUPL uploads an “application” from A&D Storage.

Apart from installing the “application”, the upload & download, and reading & writing A&D Storage, should really neither know nor care if it’s just arbitrary data…

Hi,
thanks awneil, I’ve read A&D Example and I’ve read Flash Object Management. Can you explain in wich situations is a better solution use A&D or Flash to store data?
Moreover, I’m starting to understand how to use flash memory with OpenAT. Correct me if I have any mistake in next Flash memory usage representation:

____________________________________
|             FLASH MEMORY
|------------------------------------
|        __________
|       |   ____   | <---- Set of Objects 1
|       |  | o1| <-|------ Object 1
|       |  |___|   |
|       |   ____   |
|       |  | o2| <-|------ Obejct 2
|       |  |___|   |
|       |   ____   |
|       |  | o3| <-|------ Obejct 3
|       |  |___|   |
|       |          |
  ....................
|       |   ____   |
|       |  | oX| <-|------ Obejct X
|       |  |___|   |
|       |__________|
|
|
|        __________ 
|       |   ____   | <---- Set of Objects ...
|       |  |..1| <-|------ Obejct ..1
|       |  |___|   |
|
|
|

To Read/Write a Flash Object my the steps should be:

  1. Subscribe to a desired set of objects and specify the amount of objects to be used (but, how many objects can I use?)
  2. Read/Write data using handle to a objects set subscribed in previous step and specifing desired object ID.

Thank you!

If you need to store a small amount of data (less than 128K) it is better to use Flash Objects. It is much easier than A&D, has integrated Garbage Collector and some kind of wear leveling. Total count of subscribed objects is 2000. Total amount of Flash Objects memory is supposed to be changed with DwlWin but I’ve never tried this feature.
With A&D you could use much more flash memory - more than 1MByte.

I think A&D is also the one to use if the size of the data is not fixed (or known at compile time)?

Well I’ve never encountered such a case. These are usually settings or NMEA data or ADC data which all have a well known format and size. You just reserve your 128K and write your data as soon as it is coming.

A firmware update is the most obvious example!

Thank you!
Now it’s a little bit clear