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

Entering Serial DFU mode from the application layer

Hi, I am try to implement UART SERIAL Bootloader for my device and I just need to perform DFU using uart serial

I have tested the code and bootloader. My query is

Without pressing BUTTON_4 and Power reset how to enter to DFU mode from the application layer

Buttonless UART Serial Bootloader!!

Parents
  • Hi,

    I assume you are referring to the nRF5 SDK now? In that case, you can use GPREGRET to enter DFU mode, in the same way as is used with the BLE buttonless DFU service. Essentially you just ensure that NRF_BL_DFU_ENTER_METHOD_GPREGRET is set to 1 in the bootloader's sdk_config.h and write BOOTLOADER_DFU_START to GPREGRET just as in ble_dfu_buttonless_bootloader_start_finalize() in components\ble\ble_services\ble_dfu\ble_dfu.c before you do a soft reset.

Reply
  • Hi,

    I assume you are referring to the nRF5 SDK now? In that case, you can use GPREGRET to enter DFU mode, in the same way as is used with the BLE buttonless DFU service. Essentially you just ensure that NRF_BL_DFU_ENTER_METHOD_GPREGRET is set to 1 in the bootloader's sdk_config.h and write BOOTLOADER_DFU_START to GPREGRET just as in ble_dfu_buttonless_bootloader_start_finalize() in components\ble\ble_services\ble_dfu\ble_dfu.c before you do a soft reset.

Children
  • Hi,

    Yes, It is working in nRF5 SDK

    these lines

    write BOOTLOADER_DFU_START to GPREGRET just as in ble_dfu_buttonless_bootloader_start_finalize() in components\ble\ble_services\ble_dfu\ble_dfu.c before you do a soft reset.

    where i need to perform

    In Application code?

  • Sunil vignesh said:

    these lines

    write BOOTLOADER_DFU_START to GPREGRET just as in ble_dfu_buttonless_bootloader_start_finalize() in components\ble\ble_services\ble_dfu\ble_dfu.c before you do a soft reset.

    where i need to perform

    In Application code?

     Yes

  • i worked in BLE buttonless

    there i use  code

    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");        
            break;
            default:       
            return true;
        }
        NRF_LOG_INFO("Power management allowed to reset to DFU mode\r\n");
        return true;
    }
    
    NRF_PWR_MGMT_HANDLER_REGISTER(app_shutdown_handler, 0);
    
    
    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;
        }
    }
    
    
    static void dfu_init(void)
    {
        ret_code_t             err_code;
        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);
    }
    

    dfu_init() i called in service_init()

    ble_dfu_buttonless_bootloader_start_finalize()

    where i can use this

  • You do not need to do all that. To just enter DFU mode, simply:

        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);
    
        NVIC_SystemReset();

  • in

    void main()

    {

    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);

        NVIC_SystemReset();

    ...

    ..

    }

Related