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

How to switch from application mode to bootloader mode again in OTA

Hi,

I am using nRF52832 DK and also my custom board based on nRF52832.

I have uploaded the application file into my device using OTA-DFU.

Now my device goes in application mode and advertising as nordic_blinky as my application.

And now I want to upload new application file into my device but it is in application mode, so how to switch again into bootloader mode (advertising as DFU_TRAG again).

I have tried by BOOT/RESET button but it's not done.

And also guide me how to do same on my custom board, my custom board is same as nordic beacon.

Please help me in this.

Thanks & regards,

  Archana

  • Hi Archana

    in the dfu_enter_check() function, which is called by nrf_bootloader_init(), the bootloader checks if one of the NRF_BL_DFU_ENTER_METHOD_xxxx has been used to trigger the device to stay in bootloader mode and not start the application( if there is a valid one).

    static bool dfu_enter_check(void)
    {
        if (!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 method used in our buttonless DFU application example is the NRF_BL_DFU_ENTER_METHOD_GPREGRET, see the ble_dfu_buttonless_bootloader_start_finalize() function below.

    uint32_t ble_dfu_buttonless_bootloader_start_finalize(void)
    {
        uint32_t err_code;
    
        NRF_LOG_DEBUG("In ble_dfu_buttonless_bootloader_start_finalize\r\n");
    
        err_code = sd_power_gpregret_clr(0, 0xffffffff);
        VERIFY_SUCCESS(err_code);
    
        err_code = sd_power_gpregret_set(0, BOOTLOADER_DFU_START);
        VERIFY_SUCCESS(err_code);
    
        // Indicate that the Secure DFU bootloader will be entered
        m_dfu.evt_handler(BLE_DFU_EVT_BOOTLOADER_ENTER);
    
        // Signal that DFU mode is to be enter to the power management module
        nrf_pwr_mgmt_shutdown(NRF_PWR_MGMT_SHUTDOWN_GOTO_DFU);
    
        return NRF_SUCCESS;
    }

Related