<?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>fstorage erase is not working</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/114475/fstorage-erase-is-not-working</link><description>Hi, 
 I am using fstorage functions in the ANT broadcast RX project. 
 
 I am doing the fstorage write function when the ANT device is connected (Inside RX EVENT of ANT event handler, only one write) and I am calling erase function during any button interrupt</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 18 Sep 2024 09:07:37 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/114475/fstorage-erase-is-not-working" /><item><title>RE: fstorage erase is not working</title><link>https://devzone.nordicsemi.com/thread/502896?ContentTypeID=1</link><pubDate>Wed, 18 Sep 2024 09:07:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:53d2965f-893a-4709-b1a3-1da4f0cde03d</guid><dc:creator>Aslam98</dc:creator><description>&lt;p&gt;Hi Susheel,&lt;/p&gt;
&lt;p&gt;Now, flash operations are working fine.&lt;/p&gt;
&lt;p&gt;Thanks for all the support.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Aslam&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: fstorage erase is not working</title><link>https://devzone.nordicsemi.com/thread/502424?ContentTypeID=1</link><pubDate>Fri, 13 Sep 2024 06:05:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b7dbc6f0-e8c2-4b87-92df-8c8f7654da0e</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;The issue is that fstorage only works with SOC events and not with ANT events. So when we have added nrf_fstorage_sd.c we have&amp;nbsp;NRF_SDH_SOC_OBSERVER properly defined but this seems to be optimized away when you are using only nrf_sdh_ant.c.&lt;/p&gt;
&lt;p&gt;The solution is add nrf_sdh_soc.c also along with nrf_sdh_ant.c&amp;nbsp; in your project like this&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1726207377067v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;and all the below line in flash_placement.xml file&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;	&amp;lt;ProgramSection alignment=&amp;quot;4&amp;quot; keep=&amp;quot;Yes&amp;quot; load=&amp;quot;Yes&amp;quot; name=&amp;quot;.sdh_soc_observers&amp;quot; inputsections=&amp;quot;*(SORT(.sdh_soc_observers*))&amp;quot; address_symbol=&amp;quot;__start_sdh_soc_observers&amp;quot; end_symbol=&amp;quot;__stop_sdh_soc_observers&amp;quot; /&amp;gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:299px;max-width:597px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/1194x598/__key/communityserver-discussions-components-files/4/pastedimage1726207470216v2.png" /&gt;&lt;/p&gt;
&lt;p&gt;After that, I can compile the code and get fstorage events correctly.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;lt;info&amp;gt; app_timer: RTC: initialized.
&amp;lt;info&amp;gt; app: --&amp;gt; Event received: erased 1 page from address 0x2C000.
&amp;lt;info&amp;gt; app: --&amp;gt; Event received: wrote 4 bytes at address 0x2C000.
&amp;lt;info&amp;gt; app: DUMMY READ : 69C5
&amp;lt;info&amp;gt; app: device id read from the flash : 27077
&amp;lt;info&amp;gt; app: ANT SLAVE LEV started.
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: fstorage erase is not working</title><link>https://devzone.nordicsemi.com/thread/502297?ContentTypeID=1</link><pubDate>Thu, 12 Sep 2024 12:08:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7101c803-a559-4393-ae61-e8aab746a3c9</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I can replicate the issue now. I will try to provide you a workaround soon.&lt;/p&gt;
&lt;p&gt;Thanks for your patience and the attaching the project.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: fstorage erase is not working</title><link>https://devzone.nordicsemi.com/thread/502105?ContentTypeID=1</link><pubDate>Wed, 11 Sep 2024 11:58:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ebb9d24-41c5-4b03-8591-32177beaf57f</guid><dc:creator>Aslam98</dc:creator><description>&lt;p&gt;Hi Susheel,&lt;/p&gt;
&lt;p&gt;I have been utilizing nrf_fstorage_sd for flash storage operations.&lt;/p&gt;
&lt;p&gt;I have attached my project. Please check it on your end and provide us solution.&lt;/p&gt;
&lt;p&gt;And use the ANT S212 Soft device hex file with this project.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/ant_5F00_devzone_5F00_prj.zip"&gt;devzone.nordicsemi.com/.../ant_5F00_devzone_5F00_prj.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Aslam&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: fstorage erase is not working</title><link>https://devzone.nordicsemi.com/thread/502008?ContentTypeID=1</link><pubDate>Tue, 10 Sep 2024 21:06:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:daba1217-9ef2-4caf-a36e-8e720b0c5d73</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;it almost sounds like you are not using the nrf_fstorage_sd as your backend for fstorage.&lt;/p&gt;
&lt;p&gt;When softdevice is enabled, all flash activity needs to go through the softdevice flash API which is hidden in the abstraction of the backend in nrf_fstorage_sd.c&amp;nbsp; Please look at the example &lt;a href="https://github.com/particle-iot/nrf5_sdk/blob/master/examples/peripheral/flash_fstorage/main.c#L245"&gt;nRF5_SDK_17.1.0_ddde560\examples\peripheral\flash_fstorage\main.c&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If you have used the proper backend and included the nrf_fstorage_sd.c, I do not see how this could be a problem. Can you attach your project here so that I can give a quick smoke test on the DK on my desk?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: fstorage erase is not working</title><link>https://devzone.nordicsemi.com/thread/501825?ContentTypeID=1</link><pubDate>Tue, 10 Sep 2024 04:58:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6e04eae1-a411-4662-86b2-521280ca3e05</guid><dc:creator>Aslam98</dc:creator><description>&lt;p&gt;Hi Susheel,&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;quot;Have you declared&amp;nbsp;NRF_FSTORAGE_DEF in your application?&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Yes, I have declared&amp;nbsp;NRF_FSTORAGE_DEF in my application. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;And I have observed that&amp;nbsp;Writing to flash before soft device initialization results in successful flash writes and flash events being triggered.&lt;/p&gt;
&lt;p&gt;However, writing to flash after soft device initialization does not result in flash writes and flash events are not triggered.&amp;nbsp;&lt;span&gt;I have checked in debug mode, the program seems to be stuck on the line where&amp;nbsp;nrf_fstorage_is_busy function is called.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Aslam&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: fstorage erase is not working</title><link>https://devzone.nordicsemi.com/thread/501772?ContentTypeID=1</link><pubDate>Mon, 09 Sep 2024 14:18:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9635a502-2ee5-49a2-aaee-764ccbfafcaf</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;ANT expert says that it should be fine to use fstorage the way you are using and we are not sure why you are not getting any events. Have you declared&amp;nbsp;NRF_FSTORAGE_DEF in your application?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: fstorage erase is not working</title><link>https://devzone.nordicsemi.com/thread/501733?ContentTypeID=1</link><pubDate>Mon, 09 Sep 2024 12:33:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:354fc981-715c-4b1d-9c2b-fed48c8b5c0c</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Mohamed,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I will ask the ANT expert to see if there are any pitfalls in writing to flash with ANT. Will write back to you soon with his comments.&lt;/p&gt;
&lt;p&gt;In the meantime, I would suggest you to start your program in debugger and run it for a while with the setup where&amp;nbsp;&lt;span&gt;nrf_fstorage_is_busy is called from main and always returns true. After running the debugger for a while, please halt the debugger and see if the code is looping in some context. If we can get this context, then we can try to understand why that happens.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: fstorage erase is not working</title><link>https://devzone.nordicsemi.com/thread/501684?ContentTypeID=1</link><pubDate>Mon, 09 Sep 2024 09:54:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:78dc4a44-8985-4d7f-96c8-1a53a8b064f7</guid><dc:creator>Aslam98</dc:creator><description>&lt;p&gt;Hi Susheel,&lt;/p&gt;
&lt;p&gt;Adding to the previous point, If I write before soft device initialization, then&amp;nbsp;&lt;span&gt;nrf_fstorage_is_busy(&amp;amp;fstorage) function is giving false after some time (means flash write is happening correctly).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;But if I write something after&amp;nbsp;soft device initialization, then&amp;nbsp;nrf_fstorage_is_busy(&amp;amp;fstorage) function is always giving &amp;quot;true&amp;quot; means the program gets stuck in this line.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Aslam&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: fstorage erase is not working</title><link>https://devzone.nordicsemi.com/thread/501532?ContentTypeID=1</link><pubDate>Fri, 06 Sep 2024 11:54:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6a665b32-e484-44fd-b6fb-9f513e5dd903</guid><dc:creator>Aslam98</dc:creator><description>&lt;p&gt;Hi Susheel,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks for the suggestion.&lt;/p&gt;
&lt;p&gt;But I have calling the&amp;nbsp;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;code dir="ltr"&gt;nrf_fstorage_write()&lt;/code&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;and&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;code dir="ltr"&gt;nrf_fstorage_erase()&lt;/code&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;functions inside the interrupt.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If I call&amp;nbsp;nrf_fstorage_is_busy function inside the ISR, the device getting hanged.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;And also, I have tried calling this&amp;nbsp;nrf_fstorage_is_busy function inside the main after calling the ANT INIT, and this&amp;nbsp;nrf_fstorage_is_busy(&amp;amp;fstorage) function is always giving &amp;quot;true&amp;quot; means the program gets stuck in this line and flash storage is always busy.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Aslam&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: fstorage erase is not working</title><link>https://devzone.nordicsemi.com/thread/501509?ContentTypeID=1</link><pubDate>Fri, 06 Sep 2024 10:40:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:46545980-e98f-40e6-b105-6400abbd0f45</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;div&gt;it seems like you might be encountering an issue with the order of operations or the timing of your fstorage function calls.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;In a&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/92799/fstorage-write-erase-interrupt-not-triggered-when-ble-init-called?ReplyFilter=Answers&amp;amp;ReplySortBy=Answers&amp;amp;ReplySortOrder=Descending"&gt;similar post&lt;/a&gt;, a user reported a similar issue where the&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;code dir="ltr"&gt;nrf_fstorage_evt()&lt;/code&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;callback was not triggered when&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;code dir="ltr"&gt;BLEInit()&lt;/code&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;was called. The user was able to resolve the issue by changing the order of their code.&lt;/div&gt;
&lt;div&gt;In this&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/94459/fsstorage-randomly-erasing?ReplyFilter=Answers&amp;amp;ReplySortBy=Answers&amp;amp;ReplySortOrder=Descending"&gt;thread&lt;/a&gt;, a user reported that their device was randomly erasing data when&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;code dir="ltr"&gt;Fstorage&lt;/code&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;was executed. They were able to resolve the issue by increasing the&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;code dir="ltr"&gt;NRF_FSTORAGE_SD_QUEUE_SIZE&lt;/code&gt;.&lt;/div&gt;
&lt;div&gt;It&amp;#39;s also important to note that the&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;code dir="ltr"&gt;nrf_fstorage_write()&lt;/code&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;and&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;code dir="ltr"&gt;nrf_fstorage_erase()&lt;/code&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;functions are asynchronous. This means that they return immediately, and the operation is performed in the background. You can use the&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;code dir="ltr"&gt;nrf_fstorage_is_busy()&lt;/code&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;function to check if an operation is ongoing.&lt;/div&gt;
&lt;div&gt;Here is an example of how you might structure your code:&lt;/div&gt;
&lt;div&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;uint32_t rc;

// Erase the flash.
rc = nrf_fstorage_erase(&amp;amp;fstorage, FSTORAGE_START_ADDR, 1, NULL);
APP_ERROR_CHECK(rc);

// Wait for the erase operation to complete.
while (nrf_fstorage_is_busy(&amp;amp;fstorage));

// Write to the flash.
rc = nrf_fstorage_write(&amp;amp;fstorage, FSTORAGE_START_ADDR, &amp;amp;data, sizeof(data), NULL);
APP_ERROR_CHECK(rc);

// Wait for the write operation to complete.
while (nrf_fstorage_is_busy(&amp;amp;fstorage));&lt;/pre&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>