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

DFU not working

SDK 15.2 API 6.10 SES custom board

I am trying to get DFU to work and it is not seeming to work right. 

I am trying to engage DFU mode by holding in button on board for 10-20 seconds. after releasing during allotted time i call enter_dfu_mode()

static void dfu_flash_cb(void *p_buf)
{ 
    uint32_t result = *((uint32_t*)p_buf);
    if(result == NRF_SUCCESS)
    {
        NRF_LOG_DEBUG("resetting into DFU...\n");

        //blink the led 4x
        tb_led_blink(TLBX_LED_LOGO, 4, 500);
        
        NVIC_SystemReset();
    }
    else
    {
        NRF_LOG_DEBUG("error 0x%x writing DFU settings\n");
    }
}

static void enter_dfu_mode(void)
{
    NRF_LOG_DEBUG("writing dfu settings\n");
    
//    uint32_t err_code = sd_power_gpregret_clr(GPREGRET, BOOTLOADER_DFU_START);
//    APP_ERROR_CHECK(err_code);

    //write the bootloader settings and reset
    s_dfu_settings.enter_buttonless_dfu = true;
    (void)nrf_dfu_settings_write(dfu_flash_cb);
}

I am using the dfu secure_bootloader no changes to it

I added the buttonless dfu service, not sure if necessary considering my way of wanting to enter DFU mode, from the buttonless_dfu example.

When i call the function it does nothing. When i try and write to the settings nrf_dfu_settings_write returns the following

<error> nrf_fstorage: p_fs->p_api check failed in nrf_fstorage_erase() with value 0x8.
<warning> nrf_dfu_flash: nrf_fstorage_erase() failed with error 0x8.
<error> nrf_dfu_settings: Could not erase the settings page!

Is there something i am missing with how i want to do this or is there a method to enter DFU mode with a button press i have not seen in examples yet.

Also. Once in DFU mode. How do you reset the device either after OTA is complete or after 20sec of no transfer?

  • Can you verify that the the NRF_LOG_DEFAULT_LEVEL in sdk_config.h is set to 4 (i.e. Debug).

  • I did have it set to log level 3. After setting it to log level 4 i can now see debug info in the RTT Viewer. However, after i start the DFU i cant seem to use RTT Viewer to see or log any information after that. Is there another setting somewhere to enable DFU debug data logging?

    Also i was able to get it to upload the dfu .zip file. After it uploads it says application sent successfully, but the system does nothing. The only thing i changed in the application is instead of flashing LED 2 times when i push a button it flashes 4 times.

    Do I need BLE_DFU_ENABLED set to '1'? I had it set to '0' but changed it to '1' and it does not help.

    It appears it locks up after accepting the new firmware. 

  • Segger RTT uses a control block in RAM to store the loggin data. When you jump to the bootloader, you are resetting the device and the bootloader code is reinitializing the RAM, which means that the RTT control block placed at a different location. So this is why you do not see any more log output after starting the DFU. 

    My suggestion would be to start the Bootloader in debug session, countinue the execution so that the application starts up and then trigger DFU. You should then see all the log data from the bootloader during the DFU. 

    Can you check if nrf_bootloader_app_start is being called? If it is then it means that the bootloader has passed execution to the new application and if the device is not responding then the fault is in the new application. 

    Best regards

    Bjørn 

Related