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

How to do buttonless dfu

Hi, 

I am using nRF52832 and sdk 16

I am done secure bootloader dfu. By generating the new firmware application. Zip  , this part is working fine

Now I want to do buttonless dfu.  How to generate the bootloader settings? 

2.i have merged all the hex file into single hex file which include bootloader, softdevice, and application

3.how can I make my device to switch to dfu mode? 

Please suggest me an answer. 

Thanks

  1. Pspavi
Parents
  • Hi pspavi,

    In order to enter DFU mode you have to use th Buttonless Secure DFU Service. the service will accept a data value (a characteristic) and write it to a register that is persistent across a device reset. The bootloader then reads this register to determine if it should continue with the DFU function, or pass control back to the application.

    You can start by looking the ble_app_buttonless_dfu example. There are several things you have to do during integration. This is a great tutorial to follow

    Hope that helps

    Nick

  • Thank you for you response Nikosant 

    yeah i followed the tutorial which you shared , i am getting undefined reference nrf_dfu_set_adv_name_svci_async_t

     i have done all the steps as per above tutorial

  • Provide the following preprocessor definitions

    add the following files

    and include the following headers

    #include "ble_dfu.h"
    #include "nrf_bootloader_info.h"
    #include "nrf_dfu_ble_svci_bond_sharing.h"
    #include "nrf_svci_async_function.h"
    #include "nrf_svci_async_handler.h"

    Do not forget to add also the User Include Directories in preprocessor

    Nick

  • Hi, Nikosant 

    yes i have done above all the process added the header files too i am getting the error 

    and enabled the sdk configuration . 

    ../../../../../../components/libraries/bootloader
    ../../../../../../components/libraries/bootloader/dfu
    ../../../../../../components/libraries/bootloader/ble_dfu
    
    
    #define BLE_DFU_ENABLED 1 // was 0 
    #define NRF_PWR_MGMT_CONFIG_AUTO_SHUTDOWN_RETRY 1 // was 0 
    #define NRF_SDH_BLE_VS_UUID_COUNT 2 // was 1
    #define NRF_SDH_BLE_SERVICE_CHANGED 1 // was 0

  •  as per above link i have modified the ble_app_uart program  . getting the same error 

    /**@brief Function for handling DFU events
    *
    * @details This function is called when entering buttonless DFU
    *
    * @param[in] event Buttonless DFU event.
    Add Nordic Semiconductor DFU to SDK Example - Application note
    UBX-19050198 - R01 Buttonless DFU Page 23 of 32
    */
    static void ble_dfu_buttonless_evt_handler(ble_dfu_buttonless_evt_type_t event)
    {
     switch (event)
     {
     case BLE_DFU_EVT_BOOTLOADER_ENTER_PREPARE:
     NRF_LOG_INFO("Device is preparing to enter bootloader mode\r\n");
     break;
     case BLE_DFU_EVT_BOOTLOADER_ENTER:
     NRF_LOG_INFO("Device will enter bootloader mode\r\n");
     break;
     case BLE_DFU_EVT_BOOTLOADER_ENTER_FAILED:
     NRF_LOG_ERROR("Device failed to enter bootloader mode\r\n");
     break;
     default:
     NRF_LOG_INFO("Unknown event from ble_dfu.\r\n");
     break;
     }
    }
    /**@brief Function for handling bootloader power management events
    *
    * @details This function is called to set a persistent register which informs the
    * bootloader it should continue or pass control back to the application
    *
    * @param[in] event Power management event.
    */
    static bool app_shutdown_handler(nrf_pwr_mgmt_evt_t event)
    {
     switch (event)
     {
     case NRF_PWR_MGMT_EVT_PREPARE_DFU:
     NRF_LOG_INFO("Power management wants to reset to DFU mode\r\n");
     // Change this code to tailor to your reset strategy.
     // Returning false here means that the device is not ready
     // to jump to DFU mode yet.
     //
     // Here is an example using a variable to delay resetting the device:
     //
     /* if (!im_ready_for_reset)
     {
     return false;
     }
     */
     break;
     default:
     // Implement any of the other events available
     // from the power management module:
     // -NRF_PWR_MGMT_EVT_PREPARE_SYSOFF
     // -NRF_PWR_MGMT_EVT_PREPARE_WAKEUP
     // -NRF_PWR_MGMT_EVT_PREPARE_RESET
     return true;
     }
     NRF_LOG_INFO("Power management allowed to reset to DFU mode\r\n");
     return true;
    }
    
    
    static void services_init(void)
    {
     uint32_t err_code;
     ble_nus_init_t nus_init;
     nrf_ble_qwr_init_t qwr_init = {0};
    // Initialize Queued Write Module.
     qwr_init.error_handler = nrf_qwr_error_handler;
     err_code = nrf_ble_qwr_init(&m_qwr, &qwr_init);
     APP_ERROR_CHECK(err_code);
    // Initialize NUS (Nordic UART Service)
     memset(&nus_init, 0, sizeof(nus_init));
     nus_init.data_handler = nus_data_handler;
     err_code = ble_nus_init(&m_nus, &nus_init);
     APP_ERROR_CHECK(err_code);
    // BEGIN Block Added for DFU
    // ONLY ADD THIS BLOCK TO THE EXISTING FUNCTION
    // Initialize the DFU service
     ble_dfu_buttonless_init_t dfus_init =
     {
     .evt_handler = ble_dfu_buttonless_evt_handler
     };
     err_code = ble_dfu_buttonless_init(&dfus_init);
     APP_ERROR_CHECK(err_code);
    // END Block Added for DFU
    }

Reply Children
Related