<?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>Module requires 3 power cycles to initialize FDS Manager.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/60556/module-requires-3-power-cycles-to-initialize-fds-manager</link><description>Hardware Description: 
 MKBN02A00 module based on nRF52832 SOC 
 Software Description 
 nRF SDK 15.2.0 , SoftDevice S112 
 Observation: 
 When power_manager_init() is called before fds_manager_init(). It requires 3 power cycles to initialize FDS module</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 04 Jun 2020 21:45:25 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/60556/module-requires-3-power-cycles-to-initialize-fds-manager" /><item><title>RE: Module requires 3 power cycles to initialize FDS Manager.</title><link>https://devzone.nordicsemi.com/thread/253389?ContentTypeID=1</link><pubDate>Thu, 04 Jun 2020 21:45:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d98cc691-6f80-4115-840d-c4653984a1a6</guid><dc:creator>mtsunstrum</dc:creator><description>&lt;p&gt;I am seeing the same on SDK16.0.0&lt;/p&gt;
&lt;p&gt;My application is operating with FreeRTOS, so I need to search out a solution here.&lt;/p&gt;
&lt;p&gt;fds_init() occurs after FreeRTOS is running ...&lt;/p&gt;
&lt;p&gt;Not clear the path to solve this problem. I surely don&amp;#39;t want a customer to powercycle the product 3 times to force resets ...&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Found a solution ... replaced nrf_delay_ms(50) inside the while() loop, with FreeRTOS friendly vTaskDelay(50)&lt;/p&gt;
&lt;p&gt;This way the&amp;nbsp;&lt;span&gt;FDS_EVT_INIT&amp;nbsp;is able to be returned to the&amp;nbsp;&lt;strong&gt;fds_evt_handler()&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;This issue only occured on a &amp;#39;virgin&amp;#39; FDS setup.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Module requires 3 power cycles to initialize FDS Manager.</title><link>https://devzone.nordicsemi.com/thread/248937?ContentTypeID=1</link><pubDate>Fri, 08 May 2020 12:18:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6a0fe6f9-5755-42e0-93ee-743f5eeafa5a</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;fds_init() notifies the application with the FDS_EVT_INIT event right away if all the fds pages have been tagged previously. In this case, the &lt;em&gt;m_fds_initialized &lt;/em&gt;flag will get cleared before entering the wait loop. Remember that FDS is able to tag one page on each boot, so the number of resets you need is going to depend on the number of flash pages you have allocated to FDS. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Module requires 3 power cycles to initialize FDS Manager.</title><link>https://devzone.nordicsemi.com/thread/248793?ContentTypeID=1</link><pubDate>Thu, 07 May 2020 16:44:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6f39e88f-2374-48d4-8c28-e4dbb0267bd0</guid><dc:creator>M.Anis</dc:creator><description>&lt;p&gt;can you please elaborate more on this.&lt;br /&gt;the code is stuck in an infinite loop waiting for the&amp;nbsp;&lt;em&gt;m_fds_initialized&lt;/em&gt; flag.&lt;br /&gt;how is the FDS event being triggered without calling&amp;nbsp;&lt;em&gt;app_sched_execute();&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;thanks&lt;/em&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Module requires 3 power cycles to initialize FDS Manager.</title><link>https://devzone.nordicsemi.com/thread/248624?ContentTypeID=1</link><pubDate>Thu, 07 May 2020 07:00:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9fca8b17-09a0-453f-aded-a4f21e6fe799</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;The reason for this is that fstorage is only able to complete one out of the three tasks requested by FDS on initial&amp;nbsp;boot (there is one fstorage operation/task per allocated FDS page).&amp;nbsp;Fstorage&lt;span style="font-family:inherit;"&gt;&amp;nbsp;processes the tasks queue when&amp;nbsp;receiving&amp;nbsp;flash&amp;nbsp;completion events from the Softdevice.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Module requires 3 power cycles to initialize FDS Manager.</title><link>https://devzone.nordicsemi.com/thread/248545?ContentTypeID=1</link><pubDate>Wed, 06 May 2020 17:07:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:388cbd10-d1a8-4385-87eb-56539bea9d87</guid><dc:creator>M.Anis</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/vibe"&gt;Vidar Berg&lt;/a&gt;&amp;nbsp;if the problem was caused by the events in the queue not being processed then why does it work after the third reset? shouldn&amp;#39;t it be always stuck in that infinite loop?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Module requires 3 power cycles to initialize FDS Manager.</title><link>https://devzone.nordicsemi.com/thread/248375?ContentTypeID=1</link><pubDate>Wed, 06 May 2020 09:12:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8d0c8ed3-6775-4a4f-875b-d96d83a342ca</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;You found the problem. Softdevice events&amp;nbsp;get&amp;nbsp;added to the scheduler queue from the SD IRQ handler when the&amp;nbsp;&amp;#39;NRF_SDH_DISPATCH_MODEL_APPSH&amp;#39; model is used, but processing of this queue doesn&amp;#39;t start&amp;nbsp;until the program reaches app_sched_execute() in your main loop. The result of this is that the&amp;nbsp;m_fds_initialized flag never gets cleared and wait_for_fds_ready() ends up becoming an&amp;nbsp;endless loop.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The solution of&amp;nbsp;manually polling the event will work. Another possible option is to process the scheduler task as shown by the code snippet below, but I don&amp;#39;t think there is any real difference between these two methods.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**
 * @brief Wait for fds to initialize.
 * 
 */
static void wait_for_fds_ready(void)
{
    while (!m_fds_initialized)
    {
       /* Enter System ON idle mode while waiting for SD event */
       (void) sd_app_evt_wait();
       /* Process scheduler queue. Is normally done from main loop only
          and should never be called from interrupt context */
       app_sched_execute();
    }
}&lt;/pre&gt;&lt;/p&gt;
[quote user="Mukesh Kumar"]Is it must that NRF_SDH_DISPATCH_MODEL should be set to NRF_SDH_DISPATCH_MODEL_POLLING&amp;nbsp; to use&amp;nbsp;&lt;span&gt;nrf_sdh_evts_poll() as suggested&lt;/span&gt;[/quote]
&lt;p&gt;It is not a must. You can&amp;nbsp;poll the event manually even if you have selected NRF_SDH_DISPATCH_MODEL_APPSH model, but it will only make sense to do so when you know the scheduler queue is not going to be processed. The Softdevice interrupt drives the polling otherwise.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Module requires 3 power cycles to initialize FDS Manager.</title><link>https://devzone.nordicsemi.com/thread/248294?ContentTypeID=1</link><pubDate>Tue, 05 May 2020 17:14:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d8facb6b-9dd8-443b-8b7d-a3cabeded5ed</guid><dc:creator>Mukesh Kumar</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/ble_5F00_app_5F00_hts.zip"&gt;devzone.nordicsemi.com/.../ble_5F00_app_5F00_hts.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Hi Vidar,&lt;/p&gt;
&lt;p&gt;I got involved in other development work and So I&amp;#39;m replying bit late.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I have attached a project (ble_app_hts.zip) which is having the same 3 power cycle issue.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You can extract the ble_app_hts folder and place it in &lt;strong&gt;SDK_ROOT/examples/&lt;/strong&gt; and use the segger project.&lt;/p&gt;
&lt;p&gt;FYI:&lt;/p&gt;
&lt;p&gt;I&amp;#39;m using App Scheduler in the application and so I have set the macro&amp;nbsp;&lt;strong&gt;NRF_SDH_DISPATCH_MODEL to 1 i.e. NRF_SDH_DISPATCH_MODEL_APPSH.&amp;nbsp;&lt;/strong&gt;And I had used&amp;nbsp;&lt;strong&gt;sd_app_evt_wait()&lt;/strong&gt;&amp;nbsp;in&amp;nbsp;&lt;strong&gt;wait_for_fds_ready().&amp;nbsp;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Now when I use&amp;nbsp;&lt;strong&gt;nrf_sdh_evts_poll()&lt;/strong&gt; instead of&amp;nbsp;&lt;strong&gt;sd_app_evt_wait() ,&lt;/strong&gt; the issue is solved.&lt;/p&gt;
&lt;p&gt;As per my understanding, the Softdevice events were being scheduled using app_scheduler and&amp;nbsp;sd_app_evt_wait()&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;expects SoftDevice events&amp;nbsp;in interrupt context. And maybe because of that, the application couldn&amp;#39;t come out of&amp;nbsp;wait_for_fds_ready()&lt;strong&gt;. &lt;/strong&gt;Whereas&amp;nbsp;nrf_sdh_evts_poll() continuously polls for events and is able to capture the event.&lt;/p&gt;
&lt;p&gt;Please, let me know if this fix and my reasoning are correct. I would like to know if there is any other fix to this. Also, it would be great if you could explain the behavior observed.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Is it must that NRF_SDH_DISPATCH_MODEL should be set to NRF_SDH_DISPATCH_MODEL_POLLING&amp;nbsp; to use&amp;nbsp;&lt;span&gt;nrf_sdh_evts_poll() as suggested at&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v14.0.0%2Fgroup__nrf__sdh.html"&gt;https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v14.0.0%2Fgroup__nrf__sdh.html&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Module requires 3 power cycles to initialize FDS Manager.</title><link>https://devzone.nordicsemi.com/thread/246753?ContentTypeID=1</link><pubDate>Mon, 27 Apr 2020 10:13:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9731bafd-6855-4c76-9359-bb22cab4148d</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Thanks for confirming. So it doesn&amp;#39;t appear to be one of the common causes at least. Are you able to share a minimal version of your project so I can try to debug this here?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Module requires 3 power cycles to initialize FDS Manager.</title><link>https://devzone.nordicsemi.com/thread/246626?ContentTypeID=1</link><pubDate>Sat, 25 Apr 2020 15:59:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2343edfa-638f-4471-8bea-84fb9b9e39c5</guid><dc:creator>Mukesh Kumar</dc:creator><description>&lt;p&gt;I also have .fs_data section in the linker script of my project and it is same as that in the example&amp;#39;s (ble_app_hrs) linker script.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;.fs_data :
  {
    PROVIDE(__start_fs_data = .);
    KEEP(*(.fs_data))
    PROVIDE(__stop_fs_data = .);
  } &amp;gt; RAM&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Module requires 3 power cycles to initialize FDS Manager.</title><link>https://devzone.nordicsemi.com/thread/246396?ContentTypeID=1</link><pubDate>Fri, 24 Apr 2020 07:13:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:11ac7d3a-9aab-4a36-b160-b1b824aa1d30</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Thanks for confirming. Another possible explanation as to why the events might not be forwarded is if the linker is not correctly configured to store the SoC observers mentioned in the documentation I linked to.&lt;/p&gt;
&lt;p&gt;If you are using Segger embedded studio or GCC, please compare the flash_placment.xml or *.ld (GCC) file with one from a project you know use FDS already (e.g. ble_app_hrs). The linker script must include a section named .fs_data in addition to other sections used by the Softdevice Handler library.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Module requires 3 power cycles to initialize FDS Manager.</title><link>https://devzone.nordicsemi.com/thread/246303?ContentTypeID=1</link><pubDate>Thu, 23 Apr 2020 14:36:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:de8b04e0-7ebd-41ee-999d-545c97b11442</guid><dc:creator>Mukesh Kumar</dc:creator><description>&lt;p&gt;Hi Vidar, Thanks for the quick response.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Yes, I verified, I have included nrf_sdh_soc.c file in the build.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Module requires 3 power cycles to initialize FDS Manager.</title><link>https://devzone.nordicsemi.com/thread/246240?ContentTypeID=1</link><pubDate>Thu, 23 Apr 2020 11:45:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d6b8a94d-7ca7-4755-8f7f-3b49525dfc75</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve seen similar behavior like this when Softdevice flash events are not being forwarded back to fstorage -&amp;gt; fds. So I suspect the problem may be related to Softdevice event forwarding from the&amp;nbsp;&lt;span&gt;&lt;a title="SoftDevice Handler library" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/lib_softdevice_handler.html?cp=7_1_3_47"&gt;SoftDevice Handler library&lt;/a&gt;&lt;/span&gt;.&amp;nbsp; Please confirm if the nrf_sdh_soc.c file is included in your build.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>