<?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>Best approach to save data to flash while using Softdevice</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/83115/best-approach-to-save-data-to-flash-while-using-softdevice</link><description>Hello, 
 I am using nrf52840, SDK 17.0.2, softdevice s140 and also implemented OTA DFU in my application. 
 I want to save some data lets say admin code in flash. Once I burn the firmware to device it should be like below 
 uint8_t ADMIN_CODE[6] = {0xFF</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 29 Dec 2021 05:15:48 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/83115/best-approach-to-save-data-to-flash-while-using-softdevice" /><item><title>RE: Best approach to save data to flash while using Softdevice</title><link>https://devzone.nordicsemi.com/thread/345309?ContentTypeID=1</link><pubDate>Wed, 29 Dec 2021 05:15:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6fb56f2e-83dd-4581-9f0c-ffdf97591087</guid><dc:creator>AqibK</dc:creator><description>&lt;p&gt;Yes, now its working as intended. Thank you Hung Bui!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best approach to save data to flash while using Softdevice</title><link>https://devzone.nordicsemi.com/thread/345264?ContentTypeID=1</link><pubDate>Tue, 28 Dec 2021 14:37:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ba719de8-f2cb-443d-8125-1e6f11b0be42</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;It&amp;#39;s not automatically done when you do a reset.&amp;nbsp;&lt;br /&gt;If you want to do that you need to implement the code on your own, for example when you booting up you can check the&amp;nbsp;&lt;span&gt;RESETREAS register if it&amp;#39;s booting up from a pin reset or not. Do something like this:&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;if (NRF_POWER-&amp;gt;RESETREAS &amp;amp; POWER_RESETREAS_RESETPIN_Msk)&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;//It was booting up by pin reset&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best approach to save data to flash while using Softdevice</title><link>https://devzone.nordicsemi.com/thread/345258?ContentTypeID=1</link><pubDate>Tue, 28 Dec 2021 14:07:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:74eb1f1e-d62a-4dd9-a80b-9612c344a94a</guid><dc:creator>AqibK</dc:creator><description>&lt;p&gt;No I don&amp;#39;t want to do factory reset. I just want to reset one variable (which is stored in flash using fds)&amp;nbsp;when I press reset button.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best approach to save data to flash while using Softdevice</title><link>https://devzone.nordicsemi.com/thread/345256?ContentTypeID=1</link><pubDate>Tue, 28 Dec 2021 13:45:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e173a8d7-8e89-44ec-9d3e-535e2ee04a38</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi AqibK,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What do you mean by &amp;quot;&lt;span&gt;when I do reset, data(admin code) is not reset to default value&amp;quot; do you mean you want to &amp;quot;factory reset&amp;quot; when you press the reset button ? Meaning all data is reverted to 0xFF&amp;nbsp; ?&amp;nbsp;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;This is not be done automatically. And when you reset, the chip simply re-boot. There is no factory reset. You would need to implement that your self and define a way to tell the chip to do a factory reset (not by pressing reset button).&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best approach to save data to flash while using Softdevice</title><link>https://devzone.nordicsemi.com/thread/345250?ContentTypeID=1</link><pubDate>Tue, 28 Dec 2021 13:09:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4d0eec4e-28ac-47c9-bf50-94189de7ac93</guid><dc:creator>AqibK</dc:creator><description>&lt;p&gt;Thank you Jimmywong and Hungbui,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I am now able to save data to flash using fds and it is doing same as intended when I power off and then on. However, when I do reset, data(admin code) is not reset to default value.&lt;/p&gt;
&lt;p&gt;I guess I need to find the reset handler function and there I can make current value of admin code invalid and update it to its default value.&lt;/p&gt;
&lt;p&gt;The only problem is I cannot find reset handler. Can you please point me to some resource, where it actually explain that what happens when we press reset button on dev kit and if there is some handler function where my program goes once I press reset button.&lt;/p&gt;
&lt;p&gt;Thanks again&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best approach to save data to flash while using Softdevice</title><link>https://devzone.nordicsemi.com/thread/345116?ContentTypeID=1</link><pubDate>Mon, 27 Dec 2021 13:53:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:92fa64d4-4d83-4ca2-9f77-13349e4a958e</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi AqibK,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Could you let me know if you used any flash library ? or you access flash directly ?&amp;nbsp;&lt;br /&gt;Please note that you would need to erase flash before you can write new value to it (flash is only allowed to write once after erase). Or you can do what Jimmy suggested, to use fds library.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best approach to save data to flash while using Softdevice</title><link>https://devzone.nordicsemi.com/thread/345026?ContentTypeID=1</link><pubDate>Sat, 25 Dec 2021 02:50:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9f7f9c05-310b-4bfe-939d-4bdf4378d3f3</guid><dc:creator>Jimmywong2003</dc:creator><description>&lt;p&gt;You can refer to the code from the thingy52 (&lt;a href="https://github.com/NordicSemiconductor/Nordic-Thingy52-FW/blob/master/source/modules/m_ble_flash.c"&gt;https://github.com/NordicSemiconductor/Nordic-Thingy52-FW/blob/master/source/modules/m_ble_flash.c&lt;/a&gt;)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>