<?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>partial erase vs BLE stack</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/96676/partial-erase-vs-ble-stack</link><description>Hello, 
 I have been developed a log system in the internal flash. To do that I have been using the nrf storage library. 
 My first problem came up when I tried to use nrf_fstorage_erase for one single page; this operation is blocking the interrupts of</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 16 Feb 2023 15:55:01 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/96676/partial-erase-vs-ble-stack" /><item><title>RE: partial erase vs BLE stack</title><link>https://devzone.nordicsemi.com/thread/410443?ContentTypeID=1</link><pubDate>Thu, 16 Feb 2023 15:55:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7da0263a-bb8a-4ea1-9453-74066a6886bc</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Are you triggering the flash erase from main or interrupt context? If interrupt, what is the interrupt priority of this handler? You are not using app_scheduler in your application/for the SoftDevice handler library? Could you check which events are generated? Is it related to flash operations?&lt;/p&gt;
[quote user="Juan Laehra"]* Is it normal this 150 ms elapsed time for a&amp;nbsp;nrf_fstorage_erase when the datasheet is marking 85 ms?[/quote]
&lt;p&gt;If you are using the SoftDevice backend for fstorage, the time it will take to complete the flash operation depends on the SoftDevice activity and scheduling. If there is no activity, the operations can complete faster, but it can also never succeed if there is too much activity, see&amp;nbsp;&lt;a title="Flash memory API" href="https://infocenter.nordicsemi.com/topic/sds_s140/SDS/s1xx/flash_mem_api/flash_mem_api.html?cp=5_7_4_0_7"&gt;Flash memory API&lt;/a&gt;.&lt;/p&gt;
[quote user="Juan Laehra"]* When I use&amp;nbsp;nrf_fstorage_erase I have not such an issue in my execution, even though the execution is too long, there is no interrupt generating errors during the process. What is&amp;nbsp;nrf_fstorage_erase doing that I don&amp;#39;t do with my approach?[/quote]
&lt;p&gt;If you use the Softdevice backend for Fstorage, it will use the SoftDevice API to perform the erase operation. The SoftDevice flash API is still available if the SoftDevice is disabled: &amp;quot;&lt;span&gt;If the SoftDevice is not enabled no event will be generated, and this call will return&amp;nbsp;&lt;/span&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v7.3.0/group__nrf__error.html#ga7e6367efeaac363d8cf024940b4ec123"&gt;NRF_SUCCESS&lt;/a&gt;&lt;span&gt;&amp;nbsp;when the erase has been completed&amp;quot;.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: partial erase vs BLE stack</title><link>https://devzone.nordicsemi.com/thread/410046?ContentTypeID=1</link><pubDate>Wed, 15 Feb 2023 11:19:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3cbc8537-b9b7-4a3f-9576-3464e16c013e</guid><dc:creator>Juan Lahera</dc:creator><description>&lt;p&gt;Hi, thanks for your answer.&lt;/p&gt;
&lt;p&gt;I have added error control to the enable/disable requests and no error is returned (so it looks like no observer is blocking my request). I have also added the wait for disabled events in my pause_ble() function. The problem is always the same, after partial_erase execution, at some&amp;nbsp;point the interrupt &lt;span&gt;SWI2_EGU2_IRQn is&amp;nbsp;raised, then the&amp;nbsp;BLE_ERROR_NOT_ENABLED is produced blocking my execution. I have checked the&amp;nbsp;sdk function &amp;quot;nrf_sdh_disable_request&amp;quot; and there is a&amp;nbsp;sd_softdevice_disable(); called followed by&amp;nbsp;softdevice_evt_irq_disable();, so I don&amp;#39;t understand where is this interrupt coming from and how it comes it is not disabled during this process.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Any idea?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Additionally, in my first tests I mentioned that I used fstorage library, but I changed to partial erase due to the high overrun in page erase (150 ms), 2 questions here:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;* Is it normal this 150 ms elapsed time for a&amp;nbsp;nrf_fstorage_erase when the datasheet is marking 85 ms?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;* When I use&amp;nbsp;nrf_fstorage_erase I have not such an issue in my execution, even though the execution is too long, there is no interrupt generating errors during the process. What is&amp;nbsp;nrf_fstorage_erase doing that I don&amp;#39;t do with my approach?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Juan&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: partial erase vs BLE stack</title><link>https://devzone.nordicsemi.com/thread/410007?ContentTypeID=1</link><pubDate>Wed, 15 Feb 2023 09:16:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6feadd8b-423e-4dcd-b9e1-4bf95206b799</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""]The problem here is that it looks incompatible with the parallel execution of BLE stack.[/quote]
&lt;p&gt;That is correct, &lt;a href="https://infocenter.nordicsemi.com/topic/sds_s140/SDS/s1xx/sd_resource_reqs/hw_block_interrupt_vector.html"&gt;the Softdevice blocks/restricts access to peripherals it uses&lt;/a&gt;, including the NVMC. Directly accessing one of these peripherals will cause a hardfault, see&amp;nbsp;&lt;a title="Peripheral runtime protection" href="https://infocenter.nordicsemi.com/topic/sds_s140/SDS/s1xx/sd_resource_reqs/peripheral_runtime_protection.html?cp=5_7_4_0_6_4"&gt;Peripheral runtime protection&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;As far as I know, SWI2 is not used directly by the SoftDevice, however it is used by the &lt;a title="SoftDevice Handler library" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/lib_softdevice_handler.html?cp=9_1_3_48"&gt;SoftDevice Handler library&lt;/a&gt;. Your&amp;nbsp;pause_ble() function only calls&amp;nbsp;nrf_sdh_disable_request() without any error checking, and without waiting for the disabled event. The request might be aborted if an observer blocks the request, see&amp;nbsp;&lt;a title="Message sequence chart for SoftDevice state requests" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/lib_softdevice_handler.html?cp=9_1_3_48_8#lib_sdh_example_delay_msc"&gt;Message sequence chart for SoftDevice state requests&lt;/a&gt;&amp;nbsp;for more details about the process. You should at a minimum follow the same procedure as you have in your resume_ble() function before proceeding:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;// Wait for SoftDevice to be disabled
    while (nrf_sdh_is_enabled()) {
         __WFE();
    }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>