<?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>Issues with Buttonless DFU added to existing project</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/34459/issues-with-buttonless-dfu-added-to-existing-project</link><description>Hello: 
 
 We have a BLE project running on the BMD-300 from Rigado for which we want to add BLE DFU functionality. I am basing our development on the &amp;quot;ble_app_buttonless_dfu&amp;quot; project as well as the &amp;quot;secure_dfu_ble&amp;quot; for the bootloader. We are using NRF</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 24 May 2018 07:44:33 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/34459/issues-with-buttonless-dfu-added-to-existing-project" /><item><title>RE: Issues with Buttonless DFU added to existing project</title><link>https://devzone.nordicsemi.com/thread/133145?ContentTypeID=1</link><pubDate>Thu, 24 May 2018 07:44:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7f9863b9-f103-4714-82b7-43327ab30514</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;The bootloader must be present when you initialize the DFU service because it sets up the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.0.0/lib_svc.html?cp=4_0_0_3_47"&gt;SVCI interface&lt;/a&gt; to the bootloader. This might explain the error in step 2 . However, I don&amp;#39;t think it&amp;#39;s related to the&amp;nbsp; invalid state errror from&amp;nbsp;nrf_sdh_enable_request(). I&amp;#39;d suggest to step through the&amp;nbsp;nrf_sdh_enable_request function and see if&amp;nbsp;NRF_ERROR_INVALID_STATE is returned because&amp;nbsp;m_nrf_sdh_enabled is &amp;#39;true&amp;#39;, or if the error gets returned from&amp;nbsp;sd_softdevice_enable().&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issues with Buttonless DFU added to existing project</title><link>https://devzone.nordicsemi.com/thread/133096?ContentTypeID=1</link><pubDate>Wed, 23 May 2018 18:45:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f059da1f-b04f-4537-8213-4c9d3483a01f</guid><dc:creator>Eduardo Garcia</dc:creator><description>&lt;p&gt;Thanks Vidar! That are some good points.I fixed my issue with the WDT on the bootloader and I believe that was the main issue-however we are getting the following error if we debug our device without the bootloader in place:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I have noticed that when I am debugging and restart the device I am getting failures at &amp;quot;nrf_sdh_enable_request();&amp;quot; with error code 0x08. I get this until I do a power cycle. I believe I was getting errors unrelated to this, and when I reset I was getting this issue, which is why I may have confused it with the bootloader. But I tried without the bootloader, got an unrelated error, and after reset kept getting this error!&lt;/p&gt;
&lt;p&gt;To clarify:&lt;/p&gt;
&lt;p&gt;1.) Erased device, loaded SD S132 and Application via nRF GO and J-LINK (note NO bootloader).&lt;/p&gt;
&lt;p&gt;2.) Got an unrelated error (bug in my code, or just reset device with debugger)&lt;/p&gt;
&lt;p&gt;3.) Reset debugger to understand what happened&lt;/p&gt;
&lt;p&gt;4.) After this reset I keep getting &amp;quot;nrf_sdh_enable_request();&amp;quot; errors on the main application until I power cycle.&lt;/p&gt;
&lt;p&gt;This does not happen if I have the bootloader present on step 1.&lt;/p&gt;
&lt;p&gt;The code is the same as the one I states some posts before, but I recopy it here:&lt;/p&gt;
&lt;p&gt;Application main.c&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;  int main(void)
{
int32_t err_code = 0;
    int32_t task_error = 0;
   
    
    nrf_delay_ms(1000); //wait after power up
    
    err_code  = NRF_LOG_INIT(NULL);
    NRF_LOG_DEFAULT_BACKENDS_INIT();
    //nrf_dfu_svci_vector_table_unset();
    NRF_LOG_INFO(&amp;quot;Hello!&amp;quot;);
    NRF_LOG_FLUSH();
    SEGGER_RTT_WriteString(0, &amp;quot;RTT initialized\n&amp;quot;);
     
     BLE_init(); //Chrashes inside here
     ...
     }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Inside BLE_Init&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;int32_t BLE_init(void)
{
    bool erase_bonds;
    uint32_t err_code;

    // Initialize
    ble_stack_init(); //Crashes inside here
    err_code = app_timer_init();
    //...
    }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issues with Buttonless DFU added to existing project</title><link>https://devzone.nordicsemi.com/thread/132893?ContentTypeID=1</link><pubDate>Wed, 23 May 2018 07:39:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c3ff7872-5ab4-4bf7-9942-62e7c77d97de</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;it was a bit misleading of me to say that the bootloader disables the softdevice before branching to the main app. Actually, the bootloader does not enable the softdevice on normal boot (power on reset, etc), only when it enters DFU mode and initialize the BT transport. After DFU complete, the bootloader will perform a system reset to ensure that the application always boots into the same state as it would after a normal boot.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;To debug the bootloader you can step through the nrf_dfu.c::nrf_dfu_init() and check if&amp;nbsp;nrf_bootloader_app_start() is being called. Then try to disable the softdevice after&amp;nbsp;nrf_dfu_mbr_init_sd(); to see if that helps. Although it shouldn&amp;#39;t be necessary as the softdevice should be disabled at this point (&lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.sds/dita/softdevices/s130/mbr_bootloader/mbr_sd_initialization.html?cp=2_3_1_0_11_3"&gt;Master Boot Record (MBR) and SoftDevice initialization procedure&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;Also, you&amp;nbsp;should&amp;nbsp;remove&amp;nbsp;nrf_drv_clock_uninit() since you&amp;#39;re using the WDT, please refer to this thread for more details:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/30677/bootloader-doesn-t-load-application-with-watchdog"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/30677/bootloader-doesn-t-load-application-with-watchdog&lt;/a&gt;&amp;nbsp;(fixed in SDK 15 bootloader)&lt;/p&gt;
&lt;p&gt;&amp;quot;The unit always seems to be stuck in PC 0x13d6e of SoftDevice.&amp;quot;&lt;/p&gt;
&lt;p&gt;The program counter will stay at this address most of the time as this is where the __WFE instruction is being called&amp;nbsp;from the softdevice&amp;nbsp; to enter System ON mode (sleep).&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issues with Buttonless DFU added to existing project</title><link>https://devzone.nordicsemi.com/thread/132809?ContentTypeID=1</link><pubDate>Tue, 22 May 2018 14:34:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d7db7fdc-3ae4-47d7-a806-2ac2b34d91e9</guid><dc:creator>Eduardo Garcia</dc:creator><description>&lt;p&gt;I forgot to say, the SDK is&amp;nbsp;nRF5_SDK_14.0.0&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issues with Buttonless DFU added to existing project</title><link>https://devzone.nordicsemi.com/thread/132808?ContentTypeID=1</link><pubDate>Tue, 22 May 2018 14:34:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:890b96b9-5a5b-492e-96f0-c18a71ec3cc6</guid><dc:creator>Eduardo Garcia</dc:creator><description>&lt;p&gt;Thank you for your response!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I have not made any changes to the code of the BLE DFU (Other than WDT calls to feed the WDT on the bootloader!). As you can see with the code above the main application only does NRF_LOG and RTT - related code before calling&amp;nbsp;BLE_init() which in turn calls&amp;nbsp;ble_stack_init(). Could you please point me to where the DFU code disables the SD so I can debug and see if it hits that place? I could not find it!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issues with Buttonless DFU added to existing project</title><link>https://devzone.nordicsemi.com/thread/132728?ContentTypeID=1</link><pubDate>Tue, 22 May 2018 11:14:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:615a0740-ef18-48df-a117-a8a3b4d888a7</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The bootloader disables the softdevice before branching to the main application, so it should not return invalid state when you try to re-enable it from the app. Have you made any changes to the default bootloader code that may have changed this behavior?&amp;nbsp; Also, do you have a LF crystal in your design, or are you using the internal RC oscillator?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;*EDIT*:&lt;/p&gt;
&lt;p&gt;Related to&amp;nbsp;nrf_sdh_enable_request() returning invalid state: are you doing any fstorage operations prior to ble_stack_init()? Looks like the fstorage softdevice backend may enable the softdevice through&amp;nbsp;nrf_sdh_request_continue();&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issues with Buttonless DFU added to existing project</title><link>https://devzone.nordicsemi.com/thread/132443?ContentTypeID=1</link><pubDate>Thu, 17 May 2018 18:26:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c5ef27ca-70b2-4618-9dfb-3e409dc0d267</guid><dc:creator>Eduardo Garcia</dc:creator><description>&lt;p&gt;Another test, it seems that if I do the following I can get it to work:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;*&lt;/strong&gt;Disable WDT on main application (Don&amp;#39;t know as of now how to handle WDT feeding on Bootloader, will search around...)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;*&lt;/strong&gt;Assume that SD can be already initialized: Added this code to &amp;quot;&lt;strong&gt;ble_stack_init()&amp;quot;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void ble_stack_init(void)
{
    ret_code_t err_code;
    ble_cfg_t ble_cfg;
    if(nrf_sdh_is_enabled() == false){
      err_code = nrf_sdh_enable_request();
      APP_ERROR_CHECK(err_code);
    }else
    {
      NRF_LOG_INFO(&amp;quot;SD is already enabled!&amp;quot;);
    }
    ...
    }&lt;/pre&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;*Assume LF clock is already initialized (on&amp;nbsp;&lt;strong&gt;a function after BLE initialization that sets our App&amp;#39;s HW):&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;-&amp;gt;Note protection of &amp;quot;nrf_clock_lf_src_set(NRF_CLOCK_LFCLK_Xtal);&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;int32_t CLK_lfclk_config(void)
{
  int32_t status = 0;
  status = nrf_drv_clock_init();
  if(status != NRF_ERROR_MODULE_ALREADY_INITIALIZED) //Assumption
  {
    nrf_clock_lf_src_set(NRF_CLOCK_LFCLK_Xtal);
    //APP_ERROR_CHECK(err_code);

    nrf_drv_clock_lfclk_request(NULL);
  }else
  {
    status = 0;
  }
  
  if (status !=0)
    return ((int32_t)CLOCK_ERROR);
  else
    return (0);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I kind of understand that the BLE bootloader may initialize the SD and the LF clock, but I am worried to not understand why the &amp;quot;&lt;span&gt;secure_dfu_ble&lt;/span&gt;&amp;quot; did not do this. I also worry that I am missing something that might come back to byte me! Is there a list of components to take care of when adding buttonless DFU? Or, am I doing something wrong and because of that I need the changes I implemented?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issues with Buttonless DFU added to existing project</title><link>https://devzone.nordicsemi.com/thread/132438?ContentTypeID=1</link><pubDate>Thu, 17 May 2018 17:10:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bbf9f222-22f8-45fc-8507-9e172b4d2a5b</guid><dc:creator>Eduardo Garcia</dc:creator><description>&lt;p&gt;I solved a minor issue, the setting for the bootloader button on the &amp;quot;secure_dfu_ble&amp;quot; example was set up incorrectly, so maybe that was the issue with the need to reset multiple times until it worked. The main issue, however, is still present!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I tested using the &amp;quot;&lt;span&gt;ble_app_buttonless_dfu&amp;quot; application to upload my application and the upload works. However it still crashes on &lt;strong&gt;sd_softdevice_enable() with an&amp;nbsp;NRF_ERROR_INVALID_STATE&amp;nbsp; error.&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Can it be that the stack is already initialized by the bootloader and when it enters my code and initializes again I get this error?&lt;span&gt;I am not sure what the issue is; I see that the &amp;quot;ble_app_buttonless_dfu&amp;quot; example initializes the BLE stack very early on and it does not de-initialize it. I am doing the same thing.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;My code in main.c (needs some cleanup...):&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;pre class="ui-code" data-mode="c_cpp"&gt;  int main(void)
{
int32_t err_code = 0;
    int32_t task_error = 0;
   
    
    nrf_delay_ms(1000); //wait after power up
    
    err_code  = NRF_LOG_INIT(NULL);
    NRF_LOG_DEFAULT_BACKENDS_INIT();
    //nrf_dfu_svci_vector_table_unset();
    NRF_LOG_INFO(&amp;quot;Hello!&amp;quot;);
    NRF_LOG_FLUSH();
    SEGGER_RTT_WriteString(0, &amp;quot;RTT initialized\n&amp;quot;);
     
     BLE_init(); //Chrashes inside here
     ...
     }&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Code inside BLE_Init&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;int32_t BLE_init(void)
{
    bool erase_bonds;
    uint32_t err_code;

    // Initialize
    ble_stack_init(); //Crashes inside here
    err_code = app_timer_init();
    //...
    }&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Crashes on &amp;quot;err_code = nrf_sdh_enable_request();&amp;quot; with a return error of&amp;nbsp;&lt;strong&gt;NRF_ERROR_INVALID_STATE.&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>