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

Buttonless DFU, Jump from app to DFU not working

The jump from application to DFU is not working during buttonless DFU. NRFToolbox displays GATT ERROR. I use SDK 7.1.0 with SD V7.1.0.

In dfu_app_handler.c, I made the following changes and the jump worked, also it took around 26 seconds for the jump to happen. Would it take so much time or am I doing it wrong??

static void bootloader_start(void)
{
    m_reset_prepare();
    uint32_t err_code = sd_power_gpregret_set(BOOTLOADER_DFU_START);
    APP_ERROR_CHECK(err_code);
    err_code = sd_softdevice_disable();
    APP_ERROR_CHECK(err_code);
    err_code = sd_softdevice_vector_table_base_set(NRF_UICR->BOOTLOADERADDR);
    APP_ERROR_CHECK(err_code);
    if (m_dm_handle_valid) {
        dfu_app_set_peer_data();
    }
    NVIC_ClearPendingIRQ(SWI2_IRQn);
    interrupts_disable();
    sd_nvic_SystemReset(); //Provided a system reset instead of "bootloader_util_app_start"
//    bootloader_util_app_start(NRF_UICR->BOOTLOADERADDR);
}

Why didn't it work as such? What should I do to make it work as such?? Would this method result in faster jump from app to DFU?

  • @Martial: If you are not using bootloader_util_app_start(), in your bootloader you should force the bootloader to initialize the softdevice regardless value app_reset is. Basically you should remove
    " if (init_softdevice)" in ble_stack_init() in the bootloader main.c file.

    Note that, by doing reset, there will be no bond information sharing between the bootloader and the application.

    If you don't want to use sd_nvic_SystemReset(); and want to switch back to bootloader_util_app_start() you can copy and replace bootloader_util_reset() in bootloader.c made for GCC from SDK v8.x or 9.0 so that it would work with gcc.

  • @Hung Bui Method 1(Using sd_nvic_SytemReset()) It works but it takes around 30 - 40 sec before it starts downloading the firmware. Can this time be reduced?? Or is this the actual behaviour?? Method 2 (Using bootloader_util_app_start()) This does not work and I get GATT ERROR still after doing copy and replace bootloader_util_reset() in bootloader.c made for GCC from SDK v8.x or 9.0 so that it would work with gcc

  • @martial:

    • Method1: It could also be because of the app. We currently giving quite large delay to make sure the bootloader has started properly. Note that on some phone, it might be because of the phone won't disconnect with the device immediately when we call disconnect and there will be some delay there to wait for the phone to actually disconnect. You can improve this by actively disconnect from the device, have a look at the reset_prepare() function in SDK v9.0.

    • Method2: Have you made sure you set IS_SRVC_CHANGED_CHARACT_PRESENT= 1 ? Without that the phone will cache the att table and won't update the attribute table when we switching between application and bootloader. When testing please make sure you have unbond , turn off and on Bluetooth on the phone before starting your test.

Related