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

How to enter DFU mode with SR3v1.2

Hi, 

I'm tring to enter DFU mode by combo keys by KEY_COMBO_TWO_KEY_REGISTER().

In v1.1, I used m_pwr_mgmt_shutdown(M_PWR_MGMT_SHUTDOWN_TYPE_DFU) to enter DFU mode directly. 

Now it is not work anymore, and I  find that there is a function called  static void m_coms_ble_dfu_fs_evt_handler(nrf_fstorage_evt_t *p_evt) in M_coms_ble_dfu.c  references  nrf_pwm_mgmt_shutdown(NRF_PWR_MGMT_SHUTDOWN_GOTO_DFU), and has some works before nrf_pwm_mgmt_shutdown(), I guess it is for buttonless dfu mode .

I want to ask 2 questions :

1. What is fstorage event handler: m_coms_ble_dfu_fs_evt_handler?  how can I use it properly? 

2. Can I use simpler way as before in sr3v1.1 to activate DFU instead of using m_coms_ble_dfu_fs_evt ? 

Thanks.

Ralph

Parents
  • Hi Ralph, 

    the Smart Remote v1.2 firmware supports peer data sharing,i.e. it stores the peer address and encryption keys in to flash settings page so that the bootloader can use it to re-connect to the central after the reset to enter DFU mode. Writing to flash is asynchronous so the m_coms_ble_dfu_fs_evt_handler is there to ensure that the peer data is correctly written to flash, i.e. NRF_FSTORAGE_EVT_WRITE_RESULT event is received  prior to initiating the shutdown procedure. 

    You I think you should still be able to use the nrf_pwr_mgmt_shutdown(NRF_PWR_MGMT_SHUTDOWN_GOTO_DFU) to put the remote in DFU mode. However, the bootloader will then perform undirected advertisement if the peer data is not written to flash. 

     

    ret_code_t status = sd_power_gpregret_clr(0, 0xFF);
    if (status == NRF_SUCCESS)
    {
        status = sd_power_gpregret_set(0, BOOTLOADER_DFU_START);
    }
    
    if (status == NRF_SUCCESS)
    {
    
        nrf_pwr_mgmt_shutdown(NRF_PWR_MGMT_SHUTDOWN_GOTO_DFU);
    }

     

  • Hi ,Bjorn 

    I used these 3 lines yesterday, but not work and I didnt check the status is NRF_SUCCESS or others,I will check again. 

    I also want to check whether it enters the boot loader, so I enable the  NRF_LOG_ENABLED && NRF_LOG_BACKEND_RTT_ENABLED in sdk_config.h in boot loader projec to seek some info from the log.

    But  comes out these Errors: L6406E: No space in execution regions with .ANY selector matching nrf_log_backend_rtt.o(i.nrf_log_backend_rtt_flush).Guess the space is not enough to fit the feature of log.

  • 0> <info> sr3_bootloader: In the bootloader=================
    0> <debug> app: In nrf_bootloader_init
    0> <debug> app: in weak nrf_dfu_init_user
    0> <debug> app: In real nrf_dfu_init
    0> <debug> nrf_dfu_settings: Enter nrf_dfu_settings_init
    0> <debug> nrf_dfu_flash: Calling nrf_dfu_flash_init(false)...
    0> <debug> nrf_dfu_flash: Initializing nrf_fstorage_nvmc backend.
    0> <debug> dfu_utils: Enter nrf_dfu_continue
    0> <debug> dfu_utils: Valid App
    0> <debug> app: Application sent bootloader request
    0> <debug> dfu_utils: App is valid
    0> <debug> app: Running Service Changed config
    0> <debug> app: Finished running Service Changed config
    0> <debug> app: Enabling SoftDevice.
    0> <debug> app: SoftDevice enabled.
    0> <debug> app: Device address set
    0> <debug> app: Regular adv name
    0> <debug> app: ##### Setting adv with peer data ####
    0> <debug> app: ##### IRK Found. Setting whitelist ####
    0> <debug> app: Finished initializing BLE DFU transport
    0> <debug> app: After nrf_dfu_transports_init
    0> <debug> nrf_dfu_flash: Calling nrf_dfu_flash_init(true)...
    0> <debug> nrf_dfu_flash: dfu_fstorage_evt_handler calls 0x00077025.
    0> <info> app: ble_evt_handler m_conn_handle:0----------------------------------------------
    0> <debug> app: == conn sec update request
    0> <debug> app: Sending Service Changed indication
    0> <info> app: service_changed_send M_CONN_HANDLE:0-------------------------------
    0> <warning> app: Client did not have the Service Changed indication set to enabled. Error: 0x00000008
    0> <debug> app: == We are finished handling conn sec update

    These two values of m_conn_handle only show while establishing connection after entering DFU mode.

    And then the error : 0x00000008, not upload the zip file yet.

    About the sniffer, I can check that later.

  • Hi, Bjorn

    I passed the issue that using combo key to enter DFU mode .

    In bootloader's sdk_config.c ,there is a define called NRF_DFU_BLE_REQUIRES_BONDS 

    Its default value is 1, I clear it. 

    Guess SR might only receive the DFU command from paired central if NRF_DFU_BLE_REQUIRES_BONDS  is set. If the command is sent from other paths, it omits the command. 

    Hope there is a better explanation.

    Thanks.

  • Hi Ralph, 

    I apologize for the late reply. I've been out of office on vacation.  

    So setting NRF_DFU_BLE_REQUIRES_BONDS to 0 resolved the 

    Client did not have the Service Changed indication set to enabled. Error: 0x00000008

    error in the bootloader? 

    Setting NRF_DFU_BLE_REQUIRES_BONDS to 0 means that unbonded devices are able to connect to the bootloade, however, as long as they do not have a signed DFU image to upload they will not be able to perform a DFU of the remote. 

    Best regards

    Bjørn

  • Hi, Bjorn, 

    Sorry for my very late response,too. The notification didn't show up and I also forgot to review this.

     Yes, setting NRF_DFU_BLE_REQUIRES_BONDS to 0 resolved the 

    Client did not have the Service Changed indication set to enabled. Error: 0x00000008

    error in the bootloader.

    1.So if I set  NRF_DFU_BLE_REQUIRES_BONDS to 1, the device have to bond with bootloader(DFU_Target)first, so the whole process of DFU can go down?

    2.We recently change our chip from 52832 to 52810, and I find out even changing the HW_VERSION in 52810's config from 0x20031 to 0x20023, Log in secure DFU Service still tells me the hw verson is wrong.

    Seems it has to be 0x20031 instead of other values? Isn't hw version relating to the PCB of RCU likes pca63519 and pca20023 with same chip 52832? 

  • The bonds must be created in the main application, see this answer. The FW have CONFIG_DFU_HW_VERSION set to 0x20031 for nRF52810. Where did you set the HW_VERSION, and how did it tell you that the HW version is wrong?

Reply Children
Related