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

SDK 15 dfu and application issue

hi there,

i have made the application and dfu working but there is a smal issue. if i program dfu and application from nrfgo studios the dfu run continuously and app does not run until i preform OTA from nrf mobile app. similarly if i make dfu settings from nrfutil.exe   and combine the dfu and settings and then program from nrfgo studios then the app runs fine but i cannot initiate it to dfu mode . following are dfu settings output image and my code for putting the application in dfu mode

i anyone can help me out that would be nice

regards

  • Have you added DFU support to your application, e.g. like the ble_app_buttonless_dfu example in the SDK? Do you get an error from the nRF Connect app if you try to perform a DFU when you have flashed the nRF52832 device with SoftDevice, Bootloader, Bootlaoder settings and Application?

  • hi there,

    no, i have not added ble_app_buttonless_dfu in my application just the snippet i attached above. the is not error on output.

    DFU is performed successfully when i do it from the nrf connect app.

    the issues is simple one if i flash the code with dfu settings then i cannot get into the dfu mode. the nrf52 resets and then goto application again rather than going to dfu.

    if i flash the code without dfu settings then dfu runs and i have to perform the ota to get the app running.

  • Yes, this is the expected behavior. The settings page states that there is a valid application present on the device, hence the bootloader will jump to this. If you want to stay in bootloader mode then you can assert the bootloader button pin( given that this is enabled). See dfu_enter_check() in nrf_bootloader.c in the bootloader code, i.e. 

    static bool dfu_enter_check(void)
    {
        if (!nrf_dfu_app_is_valid(crc_on_valid_app_required()))
        {
            NRF_LOG_DEBUG("DFU mode because app is not valid.");
            return true;
        }
    
        if (NRF_BL_DFU_ENTER_METHOD_BUTTON &&
           (nrf_gpio_pin_read(NRF_BL_DFU_ENTER_METHOD_BUTTON_PIN) == 0))
        {
            NRF_LOG_DEBUG("DFU mode requested via button.");
            return true;
        }
    
        if (NRF_BL_DFU_ENTER_METHOD_PINRESET &&
           (NRF_POWER->RESETREAS & POWER_RESETREAS_RESETPIN_Msk))
        {
            NRF_LOG_DEBUG("DFU mode requested via pin-reset.");
            return true;
        }
    
        if (NRF_BL_DFU_ENTER_METHOD_GPREGRET &&
           (nrf_power_gpregret_get() & BOOTLOADER_DFU_START))
        {
            NRF_LOG_DEBUG("DFU mode requested via GPREGRET.");
            return true;
        }
    
        if (NRF_BL_DFU_ENTER_METHOD_BUTTONLESS &&
           (s_dfu_settings.enter_buttonless_dfu == 1))
        {
            NRF_LOG_DEBUG("DFU mode requested via bootloader settings.");
            return true;
        }
    
        return false;
    }

  • the GPREGRET condition should put the device in dfu as i am specifically calling it in my code

    uint32_t err_code = sd_power_gpregret_clr(0, 0xffffffff);
    APP_ERROR_CHECK(err_code);

    err_code = sd_power_gpregret_set(0, BOOTLOADER_DFU_START);
    APP_ERROR_CHECK(err_code);


    // Signal that DFU mode is to be enter to the power management module
    nrf_pwr_mgmt_shutdown(NRF_PWR_MGMT_SHUTDOWN_GOTO_DFU);

    if i flash the code without dfu settings then dfu runs and i have to perform the ota to get the app running. after performing ota i can enter dfu mode whenever i command the nrf52 to execute the above code.  but if i flash the settings then when i command the nrf52 to execute the above code it resets but go to application rather then going to dfu.  the following condition should work even when the dfu settings are flashed. 

    if (NRF_BL_DFU_ENTER_METHOD_GPREGRET &&
    (nrf_power_gpregret_get() & BOOTLOADER_DFU_START))
    {
    NRF_LOG_DEBUG("DFU mode requested via GPREGRET.");
    return true;
    }

    behavior i am observing is given below

    1) if i flash the code without dfu settings then dfu runs and i have to perform the ota to get the app running. after performing ota i can enter dfu mode whenever i  write on my custom characteristics and works perfectly. the only issue is i have to perform OTA to get the app running first time

    2)if i flash the code with dfu settings then app runs perfectly but when i write on the characteristics it does not go to dfu mode rather it resets and go back to application. 

    same application hex file used for both conditions mentioned above 

    if you need any debug log let me know

    thanks

  • Yes, I agree that the device should stay in bootloader mode even with the settings.hex flashed to the device. If you could use the debug version of the bootloader, i.e.examples\dfu\secure_bootloader\pca10040_ble_debug, and post the debug log output then that would be great. 

    You could also start the bootloader in a debug session when you have flashed the SD+APP+BL+settings, Run the code so that it jumps to the application, set a breakpoints in dfu_enter in nrf_bootloader_init is set to true by dfu_enter_check when you write to your custom characteristic. 

    Best regards

    Bjørn 

Related