<?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>nrf_dfu_flash_* callbacks don&amp;#39;t get called</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/28490/nrf_dfu_flash_-callbacks-don-t-get-called</link><description>I am modifying the bootloader_secure_ble code to receive a serial number via BLE and store it in flash. However, whenever I call nrf_dfu_flash_store or nrf_dfu_flash_erase, the callback is never called. Here is my code (stripped of other functions and</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 21 Nov 2017 10:13:30 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/28490/nrf_dfu_flash_-callbacks-don-t-get-called" /><item><title>RE: nrf_dfu_flash_* callbacks don't get called</title><link>https://devzone.nordicsemi.com/thread/112700?ContentTypeID=1</link><pubDate>Tue, 21 Nov 2017 10:13:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b8ebfb8d-8bd8-497e-8ee0-fe5ad0a0c7fc</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;You should always check for the return code of the function, make sure it returns NRF_SUCCESS after you call it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_dfu_flash_* callbacks don't get called</title><link>https://devzone.nordicsemi.com/thread/112699?ContentTypeID=1</link><pubDate>Mon, 20 Nov 2017 22:09:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:78f386c4-7ad4-4fb4-9526-0491240a585e</guid><dc:creator>zolotiyeruki</dc:creator><description>&lt;p&gt;Ok, I modified the code to the following, and now the handler runs:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void setSerialNumber(uint8_t const * const src){
    uint32_t * dest = (uint32_t *)FLASH_SERIAL_ADDR;
    nrf_dfu_flash_erase(dest, 1, serial_flash_callback);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So I&amp;#39;m back moving again.  Unfortunately, calling nrf_dfu_flash_store() within the handler doesn&amp;#39;t result in the handler being called again.  Still digging into that one.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_dfu_flash_* callbacks don't get called</title><link>https://devzone.nordicsemi.com/thread/112701?ContentTypeID=1</link><pubDate>Mon, 20 Nov 2017 13:57:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8eced564-f917-4a7f-9ec6-9d8e627cb00e</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Zolo,&lt;/p&gt;
&lt;p&gt;The BLE event and the flash operation callback event are both at &amp;quot;Softdevice API calls and non-time-critical processing&amp;quot; see &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.sds/dita/softdevices/s130/processor_avail_interrupt_latency/exception_mgmt_sd.html?cp=2_3_1_0_15_1"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If you want to wait for the event, you should better wait at the main loop or at those priority level 5-6-7. You can use app scheduler to send the flash task to main context.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_dfu_flash_* callbacks don't get called</title><link>https://devzone.nordicsemi.com/thread/112697?ContentTypeID=1</link><pubDate>Fri, 17 Nov 2017 18:30:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ead66398-555e-428a-95de-f7e98ee916bf</guid><dc:creator>zolotiyeruki</dc:creator><description>&lt;p&gt;The stack goes something like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;setSerialNumber() 
called by ble_dis_on_evt() (modified ble_dis.c)
called by ble_evt_dispatch() (modified nrf_ble_dfu.c)
called by SoftDevice
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So the softdevice generates a BLE event, and the handler for the BLE event attempts to write to flash, and is waiting for the SoftDevice to generate a system event (from the flash erase or write event completing).&lt;/p&gt;
&lt;p&gt;How do I know what the relative priorities of the two are?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_dfu_flash_* callbacks don't get called</title><link>https://devzone.nordicsemi.com/thread/112698?ContentTypeID=1</link><pubDate>Fri, 17 Nov 2017 16:13:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a8463eea-b9fa-4b3c-b20b-91116401372d</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Where do you call setSerialNumber() if you call that function from inside an event handler and then wait inside that event for the serial_flash_callback() to be called by same or lower priority level event, you may have to wait forever.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>