This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

S130 DFU BLE Bootloader: no timeout?

Hello,

As far as I understand previous versions of DFU BLE bootloader implemented a timeout so if DFU is not being used and an app is present it will run after a few time.

I can't see anything on the latest SDK (12). Can't exit from DFU unless I send another update packet (.zip).

Any ideas on how to return to app code if present?

Parents
  • My suggestion would be to start the watchdog timer(WDT) once you enter nrf_dfu_init() in nrf_dfu.c and then feed it everytime the bootloader handles requests from the DFU controller. Configure and start the WDT by adding the following code snippet to nrf_dfu_init() after the if(enter_bootloader_mode != 0 || !nrf_dfu_app_is_valid()) statment

     //Configure WDT.
        NRF_WDT->CONFIG         = (WDT_CONFIG_SLEEP_Run << WDT_CONFIG_SLEEP_Pos);       // Configure WDT to run when CPU is asleep
        NRF_WDT->CRV            = 3932159;                                              // Timeout set to 120 seconds, timeout[s] = (CRV-1)/32768
        NRF_WDT->RREN           = WDT_RREN_RR0_Enabled << WDT_RREN_RR0_Pos;             // Enable the RR[0] reload register
        NRF_WDT->TASKS_START    = 1;                                                    // Start the WDT   
    

    Then add the snippet below to the nrf_dfu_req_handler_on_req() function in dfu_req_handling.c

    // Reload the WDTs RR[0] reload register
    NRF_WDT->RR[0] = WDT_RR_RR_Reload; 
    

    I have also attached the main.c and dfu_req_handling.c files below which include the snippets.

    nrf_dfu.c

    dfu_req_handling.c

    Best regards

    Bjørn

  • Great! I was already trying something like that using an "app_timer" which is overkill. WDF does the job wonderfuly. I also added an op code do Control Point characteristic so I can remotely reset the nRF51 while in DFU mode. Thanks!

Reply Children
No Data
Related