# Data storage Example

**URL:** <https://forum.sierrawireless.com/t/data-storage-example/4738>\
**Category:** Open AT\
**Created:** [November 11, 2010, 4:02pm UTC](https://forum.sierrawireless.com/t/data-storage-example/4738 "2010-11-11T16:02:38Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![josepvr](https://avatars.discourse-cdn.com/v4/letter/j/d78d45/32.png) [@josepvr](https://forum.sierrawireless.com/u/josepvr)\
**Post date:** [November 11, 2010, 4:02pm UTC](https://forum.sierrawireless.com/t/data-storage-example/4738/1 "2010-11-11T16:02:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [November 11, 2010, 4:23pm UTC](https://forum.sierrawireless.com/t/data-storage-example/4738/2 "2010-11-11T16:23:27Z")

</div>

> [@josepvr](#):
>
> save/load information to a flash memory?

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…

---

<div class="post-metadata">

**Author:** ![josepvr](https://avatars.discourse-cdn.com/v4/letter/j/d78d45/32.png) [@josepvr](https://forum.sierrawireless.com/u/josepvr)\
**Post date:** [November 11, 2010, 4:32pm UTC](https://forum.sierrawireless.com/t/data-storage-example/4738/3 "2010-11-11T16:32:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![josepvr](https://avatars.discourse-cdn.com/v4/letter/j/d78d45/32.png) [@josepvr](https://forum.sierrawireless.com/u/josepvr)\
**Post date:** [November 15, 2010, 8:37am UTC](https://forum.sierrawireless.com/t/data-storage-example/4738/4 "2010-11-15T08:37:19Z")

</div>

Can anybody help me?

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [November 15, 2010, 9:40am UTC](https://forum.sierrawireless.com/t/data-storage-example/4738/5 "2010-11-15T09:40:36Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![josepvr](https://avatars.discourse-cdn.com/v4/letter/j/d78d45/32.png) [@josepvr](https://forum.sierrawireless.com/u/josepvr)\
**Post date:** [November 16, 2010, 11:15am UTC](https://forum.sierrawireless.com/t/data-storage-example/4738/6 "2010-11-16T11:15:28Z")

</div>

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:

```auto
____________________________________
| 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!

---

<div class="post-metadata">

**Author:** ![blackyblack](https://avatars.discourse-cdn.com/v4/letter/b/2acd7d/32.png) [@blackyblack](https://forum.sierrawireless.com/u/blackyblack)\
**Post date:** [November 17, 2010, 6:10am UTC](https://forum.sierrawireless.com/t/data-storage-example/4738/7 "2010-11-17T06:10:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [November 17, 2010, 6:52am UTC](https://forum.sierrawireless.com/t/data-storage-example/4738/8 "2010-11-17T06:52:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![blackyblack](https://avatars.discourse-cdn.com/v4/letter/b/2acd7d/32.png) [@blackyblack](https://forum.sierrawireless.com/u/blackyblack)\
**Post date:** [November 17, 2010, 7:33am UTC](https://forum.sierrawireless.com/t/data-storage-example/4738/9 "2010-11-17T07:33:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [November 17, 2010, 8:11am UTC](https://forum.sierrawireless.com/t/data-storage-example/4738/10 "2010-11-17T08:11:34Z")

</div>

> [@blackyblack](#):
>
> Well I’ve never encountered such a case.

A firmware update is the most obvious example!

---

<div class="post-metadata">

**Author:** ![josepvr](https://avatars.discourse-cdn.com/v4/letter/j/d78d45/32.png) [@josepvr](https://forum.sierrawireless.com/u/josepvr)\
**Post date:** [November 22, 2010, 8:25am UTC](https://forum.sierrawireless.com/t/data-storage-example/4738/11 "2010-11-22T08:25:32Z")

</div>

Thank you!  
Now it’s a little bit clear
