<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>keeping data in flash on fixed address</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/9515/keeping-data-in-flash-on-fixed-address</link><description>Hi, 
 with the pstorage library, is it possible to store data at a specific flash address?
The background of the question is that I would like to store data in flash, and be able to access it again after a power cycle, e.g. when the batteries need to</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 05 Oct 2015 10:24:27 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/9515/keeping-data-in-flash-on-fixed-address" /><item><title>RE: keeping data in flash on fixed address</title><link>https://devzone.nordicsemi.com/thread/35144?ContentTypeID=1</link><pubDate>Mon, 05 Oct 2015 10:24:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:411c717f-cbf0-437a-ab56-b29690fdcadb</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;The block size is limited to the page size, see &lt;a href="https://devzone.nordicsemi.com/question/15271/how-can-i-write-10kb-of-data-to-internal-flash/?answer=17300#post-id-17300"&gt;this thread&lt;/a&gt;. I suspect defining more amount of blocks will consume slightly more RAM as you need one identifier for each block. I have not seen any limitation on the number of blocks you can have in total. The block size just need to be word aligned, i.e. with size 4, 8, 12, 16, ... etc. Defining more blocks will however not consume more flash.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: keeping data in flash on fixed address</title><link>https://devzone.nordicsemi.com/thread/35143?ContentTypeID=1</link><pubDate>Sat, 03 Oct 2015 13:46:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9085ddc6-3586-487a-944d-eb17380214a0</guid><dc:creator>wim</dc:creator><description>&lt;p&gt;Stefan, one more question:
when registering a block, is there any consequence to the choice of the block_size and block_count in the storage_module_parameter_t argument of storage_register()?
Or in other words, would a block size of 100 and a block_count of 10 use an equal amount of memory and flash as a block size of 10 and a block_count of 100? Are there any limitations to block_count or block_size?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: keeping data in flash on fixed address</title><link>https://devzone.nordicsemi.com/thread/35142?ContentTypeID=1</link><pubDate>Fri, 02 Oct 2015 17:33:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e8717dfb-cd99-4f30-88e0-bc76d73e84f4</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;That is correct, it only gets the handle of the specified block. Normally you would call pstorage_block_identifier_get for every block you want to write/clear/read&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: keeping data in flash on fixed address</title><link>https://devzone.nordicsemi.com/thread/35141?ContentTypeID=1</link><pubDate>Fri, 02 Oct 2015 17:23:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:69c2fd26-e5e9-4e04-b6e9-1164b6136bb7</guid><dc:creator>wim</dc:creator><description>&lt;p&gt;ok, this is clear now. So I can call pstorage_block_identifier_get(...) as much as I want, it just gets the handle, does not register or change anything or fill memory space, correct?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: keeping data in flash on fixed address</title><link>https://devzone.nordicsemi.com/thread/35140?ContentTypeID=1</link><pubDate>Fri, 02 Oct 2015 17:21:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:472045f6-97e5-4144-a7d9-5a49a0561d6c</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;You are correct, sorry for the confusion&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: keeping data in flash on fixed address</title><link>https://devzone.nordicsemi.com/thread/35139?ContentTypeID=1</link><pubDate>Fri, 02 Oct 2015 17:20:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9c78a977-e957-4196-992e-0071958f7ddb</guid><dc:creator>wim</dc:creator><description>&lt;p&gt;Stefan
i guess you mean that block number will have address start_of_page + 1 x block size, where block size in the code snippet is 100, so start_of_page+100, correct?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: keeping data in flash on fixed address</title><link>https://devzone.nordicsemi.com/thread/35137?ContentTypeID=1</link><pubDate>Fri, 02 Oct 2015 16:26:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:20aea75f-5a62-4f30-9f4e-3afd470a020d</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Hi Wim&lt;/p&gt;
&lt;p&gt;If you are not using the device manager and only need one page for application data, I think you need to set&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define DFU_APP_DATA_RESERVED 0x0800 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;in order to reserve one page for the swap page and one page for the application data. If you would need two pages, you should set&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define DFU_APP_DATA_RESERVED 0x0C00
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;in order to reserve one page for the swap page and two pages for the application data&lt;/p&gt;
&lt;p&gt;In the code snippet shown &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk51.v9.0.0/lib_pstorage.html?cp=4_1_0_3_13_2_2#pstorage_get_block_id"&gt;here&lt;/a&gt;, the identifier of block number 2 is returned, hence the number &amp;quot;2&amp;quot; as the second parameter in pstorage_block_identifier_get. The first block is number 0 and will have the address of the start of the page. Block number 1 will have the address start_of_page + 1, Block number 2 will have the address start_of_page + 2, etc.&lt;/p&gt;
&lt;p&gt;There is also a code example available &lt;a href="https://devzone.nordicsemi.com/question/15271/how-can-i-write-10kb-of-data-to-internal-flash/?answer=17300#post-id-17300"&gt;here&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: keeping data in flash on fixed address</title><link>https://devzone.nordicsemi.com/thread/35138?ContentTypeID=1</link><pubDate>Fri, 02 Oct 2015 11:56:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:476955d1-0ff1-456f-9dba-ec4449859481</guid><dc:creator>wim</dc:creator><description>&lt;p&gt;Hello Stefan,&lt;/p&gt;
&lt;p&gt;apparently by default de DFU_APP_DATA_RESERVED is 0x0000 in the SDK, in version 7.2.0 at least, as I am using that one.
Do I have to set this value to as much as memory I need in bytes? I did not fully  understand why, in the thread you mentioned above, this value had to be set to 0x800 rather than 0x400. Was that because he was using the device manager?
I do not use the device manager, and 1 page is enough, so for me setting DFU_APP_DATA_RESERVED to 0x400 would be fine, right?&lt;/p&gt;
&lt;p&gt;And about the actual data access: if I do  a pstorage_block_identifier_get, do I get a pointer to the &amp;#39;next available&amp;#39; data? In other words, if I only do this once in my application, and do this again, will I access the same physical flash space? And this it start reservation at the bottom of the reserved memory, so at 0x3C000-0x400 and then upwards, or downwards starting from 0x3BFFF?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: keeping data in flash on fixed address</title><link>https://devzone.nordicsemi.com/thread/35136?ContentTypeID=1</link><pubDate>Thu, 01 Oct 2015 15:33:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a2b6c373-484f-4673-a2ea-5d09d4e15b8c</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Hi Wim&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/question/22791/how-to-preserve-app-data/?comment=22989#comment-22989"&gt;This thread&lt;/a&gt; tells something about where data is actually stored in flash when using pstorage. Another option is to use pstorage in &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk51.v9.0.0/lib_pstorage.html?cp=4_1_0_3_13_3#pstorage_raw_mode"&gt;RAW mode&lt;/a&gt; where you write directly to addresses in the memory space.&lt;/p&gt;
&lt;p&gt;If you use bootloader, you need to configure the bootloader so it does not overwrite any application data stored in flash. The application data space is reserved with modifying the constant DFU_APP_DATA_RESERVED in dfu.types.h&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>