<?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>How to read data by using fstorage</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/12774/how-to-read-data-by-using-fstorage</link><description>Hii all, 
 I am working on a project where I need to store data to persistent storage and retrieve back when the board is restart. but now we are migrated to simultaneous central and peripheral role and I found some thing like fstorage and I read this</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 05 May 2017 09:18:01 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/12774/how-to-read-data-by-using-fstorage" /><item><title>RE: How to read data by using fstorage</title><link>https://devzone.nordicsemi.com/thread/48544?ContentTypeID=1</link><pubDate>Fri, 05 May 2017 09:18:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2453edf6-ea35-415f-9dec-a33855b07acd</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Yes, this is what i wrote a couple of comments up:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;You can store your data chunks at a specific flash address so that you know where to retrieve the data by dereferencing the pointer to that specific flash address.&lt;/em&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read data by using fstorage</title><link>https://devzone.nordicsemi.com/thread/48543?ContentTypeID=1</link><pubDate>Fri, 05 May 2017 09:15:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5decd2cf-72f2-4140-b6b6-e2da5dff1564</guid><dc:creator>dingari</dc:creator><description>&lt;p&gt;One thing that is not clear in your example is that the &lt;code&gt;p_start_addr&lt;/code&gt; pointer can be set manually, according to the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v12.0.0%2Fstructfs__config__t.html"&gt;docs&lt;/a&gt;. So instead of &lt;code&gt;pstorage_load&lt;/code&gt; you have to specify a place in flash, assign &lt;code&gt;p_start_addr&lt;/code&gt; to point to that address, and dereference that pointer to load the data?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read data by using fstorage</title><link>https://devzone.nordicsemi.com/thread/48542?ContentTypeID=1</link><pubDate>Fri, 05 May 2017 07:17:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a1e9bac6-2cf1-443a-88ef-07b052c38af0</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;@Abe: Yes, that is correct.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read data by using fstorage</title><link>https://devzone.nordicsemi.com/thread/48541?ContentTypeID=1</link><pubDate>Thu, 04 May 2017 13:50:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ac89923c-4a1f-4fd0-a377-59e373a210ba</guid><dc:creator>Abe</dc:creator><description>&lt;p&gt;@BjørnSpockeli: So, just to be clear, the fstorage module does not support any functionalities apart from storing and erasing data. Then is the Flash Data Storage module the API to use for functionalities revolving around both, storing and retrieving data from Flash just like pstorage module?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read data by using fstorage</title><link>https://devzone.nordicsemi.com/thread/48540?ContentTypeID=1</link><pubDate>Thu, 04 May 2017 13:21:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c72ef826-75d2-43f8-866f-937fb1a14ccf</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;@abeshek: Firstly, fstorage is the replacement of pstorage, i.e. the fstorage module provides the functionality to store data to flash and erase flash pages just like pstorage. Nothing more and nothing less. You can store your data chunks at a specific flash address so that you know where to retrieve the data by dereferencing the pointer to that specific flash address.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read data by using fstorage</title><link>https://devzone.nordicsemi.com/thread/48539?ContentTypeID=1</link><pubDate>Thu, 04 May 2017 13:07:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cdc775bb-6d8b-424c-84d3-a5520918b3ce</guid><dc:creator>Abe</dc:creator><description>&lt;p&gt;@BjørnSpockeli Can you please be kind enough as to respond to the message chain and clear out any confusions that are lingering around the capabilities of fstorage module - to load,update,store,and erase the persistent data? Also, speaking from a end-user&amp;#39;s perspective it would be highly inefficient if fstorage - a higher and advanced version of pstorage module, is not able to support the basic and developer friendly techniques of storing and loading the chunks of data.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read data by using fstorage</title><link>https://devzone.nordicsemi.com/thread/48538?ContentTypeID=1</link><pubDate>Fri, 31 Mar 2017 09:14:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8c8bdcdc-a9c4-4491-ad5a-933eda36b29f</guid><dc:creator>Anuj C</dc:creator><description>&lt;p&gt;@siddhantmodi There is no flaw. In the &amp;quot;Experimental: Flash Storage&amp;quot; documentation for SDK 11 if you look at the section &amp;quot;Priority for Flash Usage&amp;quot; you&amp;#39;ll see how it works.   You assign each chunk of registered flash memory a priority when you configure it.  Assuming the contents of the flash do not change between restarts, the chunk with the same priority will always be assigned to the same memory location.  You also cannot change the number of pages dedicated to each chunk as this would mess up the spacing.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read data by using fstorage</title><link>https://devzone.nordicsemi.com/thread/48537?ContentTypeID=1</link><pubDate>Wed, 15 Mar 2017 10:41:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1f23ca47-8c23-4bdb-b4eb-a201dbed9637</guid><dc:creator>dingari</dc:creator><description>&lt;p&gt;Is there really not a way of simply loading data using the fstorage module? It seems really unthought, given that pstorage has been deprecated. The module that is supposed to replace it doesn&amp;#39;t provide the same functionality?&lt;/p&gt;
&lt;p&gt;Anyway. In my application I have to store a single struct and retrieve it on startup. I don&amp;#39;t want to use a complicated Flash Data Storage with files and records. I ended up using your way with a dummy word that I write to and retrieve the data from the pointer upon getting the completed event.&lt;/p&gt;
&lt;p&gt;But that&amp;#39;s a rather silly workaround for a &lt;em&gt;flash storage module&lt;/em&gt;...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read data by using fstorage</title><link>https://devzone.nordicsemi.com/thread/48536?ContentTypeID=1</link><pubDate>Mon, 20 Feb 2017 11:47:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b1f84f8f-7c7f-4078-bd37-4dca08a48d91</guid><dc:creator>Kapil Rawat</dc:creator><description>&lt;p&gt;You also need to erase previous value if you updating value, i.e.&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;fs_erase(&amp;amp;fs_config, fs_config.p_start_addr, 1);&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read data by using fstorage</title><link>https://devzone.nordicsemi.com/thread/48535?ContentTypeID=1</link><pubDate>Tue, 24 Jan 2017 09:49:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:08477891-df6e-48d0-832b-39ce4303422b</guid><dc:creator>summer</dc:creator><description>&lt;p&gt;@Bjørn Spockeli  any updates here?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read data by using fstorage</title><link>https://devzone.nordicsemi.com/thread/48534?ContentTypeID=1</link><pubDate>Thu, 01 Dec 2016 00:54:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b2a00ebd-48e3-4daf-867d-08c668fd88b5</guid><dc:creator>Sid Modi</dc:creator><description>&lt;p&gt;@Bjørn Spockeli: Has a way to overcome this logic flaw been found? I was looking at the latest version of the sdk and it looks like the problem persists.&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;
&lt;p&gt;Cheers,
Sid&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read data by using fstorage</title><link>https://devzone.nordicsemi.com/thread/48533?ContentTypeID=1</link><pubDate>Thu, 13 Oct 2016 19:32:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:09e36aa0-e926-4b92-aa38-b730001aa6be</guid><dc:creator>Dave_couling</dc:creator><description>&lt;p&gt;Hi Bjorn,&lt;/p&gt;
&lt;p&gt;Wouldn&amp;#39;t the values in the Section Variables still be lost after a power-cycle?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read data by using fstorage</title><link>https://devzone.nordicsemi.com/thread/48532?ContentTypeID=1</link><pubDate>Tue, 11 Oct 2016 07:32:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:29613475-46ee-4f10-8731-5cb2fa3d0c94</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;@dave_couling: Yes, I agree that my example has a major logic flaw.
I think this has been addressed by the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v12.0.0/lib_fstorage.html?resultof=%22%66%73%74%6f%72%61%67%65%22%20%22%66%73%74%6f%72%61%67%22%20"&gt;Section Variables&lt;/a&gt; feature in the latest releases of the SDK.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read data by using fstorage</title><link>https://devzone.nordicsemi.com/thread/48531?ContentTypeID=1</link><pubDate>Thu, 06 Oct 2016 00:57:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2248f0c1-63ef-4195-b32c-ddf674dde8d2</guid><dc:creator>Dave_couling</dc:creator><description>&lt;p&gt;Does this not have a logic FLAW?   If you lose power, you will lose the data pointers to the Flash memory locations.  Therefore you will not be able to retrieve Flash data after a power-cycle,  only after first saving and retrieving the pointer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read data by using fstorage</title><link>https://devzone.nordicsemi.com/thread/48530?ContentTypeID=1</link><pubDate>Mon, 12 Sep 2016 13:17:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3edf6577-b9a3-4ab2-b5e3-05a8abf9d0c4</guid><dc:creator>dblasco</dc:creator><description>&lt;p&gt;Dear Bjorn,&lt;/p&gt;
&lt;p&gt;I understand your way to read data. But this way you are forced to overwrite your data before being able to read it, right? How can you access the pointer without modifying the saved data?
Thank you&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read data by using fstorage</title><link>https://devzone.nordicsemi.com/thread/48529?ContentTypeID=1</link><pubDate>Wed, 20 Apr 2016 10:38:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:04ecd6ba-d6b6-485e-a85a-450234ae6d45</guid><dc:creator>Pavan kumar</dc:creator><description>&lt;p&gt;OOh ok I think its better if you have any. Any how that&amp;#39;s fine and thanks for ans&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read data by using fstorage</title><link>https://devzone.nordicsemi.com/thread/48528?ContentTypeID=1</link><pubDate>Wed, 20 Apr 2016 10:36:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:48011bd2-50a3-46f8-a730-4faffd066219</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;There is no load API call, you have to keep track of the pointer after you store the data.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read data by using fstorage</title><link>https://devzone.nordicsemi.com/thread/48527?ContentTypeID=1</link><pubDate>Wed, 20 Apr 2016 09:54:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:45446043-4b70-48ea-a001-48f9f0f196fd</guid><dc:creator>Pavan kumar</dc:creator><description>&lt;p&gt;Thanks Bjorn for replying. I already come to know that I can use the data by using pointer but my question is just like in pstorage we have any call that can return the data required&lt;/p&gt;
&lt;p&gt;Thanks&amp;amp;regards
Pavan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read data by using fstorage</title><link>https://devzone.nordicsemi.com/thread/48526?ContentTypeID=1</link><pubDate>Thu, 31 Mar 2016 10:46:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:373c39b8-6a68-44f8-80db-fda3f23a39e7</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;After calling &lt;code&gt;fs_store()&lt;/code&gt; you will receive the &lt;code&gt;FS_EVT_STORE&lt;/code&gt; event  in the &lt;code&gt;fs_evt_handler()&lt;/code&gt; when  the flash operation is finished. Within the &lt;code&gt;fs_evt_t&lt;/code&gt; structure you&amp;#39;ll find the pointer to the data that was written to flash.&lt;/p&gt;
&lt;p&gt;To retrieve the data, you must create a pointer variable that should be used to store the pointer that points to the data in flash, i.e.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;const uint32_t * stored_data;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and when you get the &lt;code&gt;FS_EVT_STORE&lt;/code&gt;, simply set the pointer to point to the same address as the pointer that is returned in the &lt;code&gt;fs_evt_handler()&lt;/code&gt;, i.e.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void fs_evt_handler(fs_evt_t const * const evt, fs_ret_t result)
{
    switch(evt-&amp;gt;id)
    {
        case FS_EVT_STORE:
            if(result == FS_SUCCESS)
            {
                stored_data = evt-&amp;gt;store.p_data;
                SEGGER_RTT_printf(0,&amp;quot;Stored Data: %X \n&amp;quot;,*stored_data);
            }
            break;
        
        case FS_EVT_ERASE:
            // Handle erase event
            break;
        
        default:
            //Do nothing
            break;
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is provided that you run the following code snippet in main()&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;FS_REGISTER_CFG(fs_config_t fs_config) =
    {
        .callback  = fs_evt_handler,    // Function for event callbacks.
        .num_pages = 1,                 // Number of physical flash pages required.
        .priority  = 0xFE               // Priority for flash usage.
    };

fs_ret_t ret = fs_init();
if (ret != FS_SUCCESS)
{
    SEGGER_RTT_printf(0,&amp;quot;FS ERROR OCCURED\n&amp;quot;);
    // An error occurred.
}

//Data to be written to flash
static uint32_t data = 0x12345678;

ret = fs_store(&amp;amp;fs_config, fs_config.p_start_addr, &amp;amp;data, 1);
if (ret != FS_SUCCESS)
{
     SEGGER_RTT_printf(0,&amp;quot;FS ERROR OCCURED\n&amp;quot;);
    // An error occurred.
}    
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and that you have added the &lt;code&gt;fs_sys_event_handler()&lt;/code&gt; function in &lt;code&gt;sys_evt_dispatch()&lt;/code&gt;, i.e.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void sys_evt_dispatch(uint32_t sys_evt)
{
    ble_advertising_on_sys_evt(sys_evt);
    fs_sys_event_handler(sys_evt);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;-Bjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>