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

  • 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.

  • No, you will need to decrease IROM start address and increase the IROM size accordingly in the Keil memory or GCC linker script to fit the Logging module. You will also have to adjust the SR3 firmware so that it soes not overwrite the bootloader.  I think that setting the bootloader memory settings to IROM1 Start: 0x77000 Size: 0x7000 should do.

  • Hi Bjorn.

    I change the IROM as your suggestion(can see log in bootloader now),and I also use app: nRF connect to send 0x01 to SR3 to put it into DFU mode successfully.

    But still can't put SR3 into DFU mode by a combo key function. I go back to check m_coms_ble_dfu_fs_evt_handler(), nrf_atomic_flag_clear(&m_dfu_flash_busy) I didnt add it in my combo key function,should I add it ?

    Thanks.

    Ralph  

  • Hi, Bjorn 

    I omit the problem of combo key function first. 

    I use the same method in sdk13 to package a DFU zip file.

    nrfutil pkg generate --hw-version 52 --sd-req 0xA5 --application-version 0x0000 --application my_app.hex --key-file my_key.pem my_zipfile.zip

    And then I click uplaod to update the app by nrf_toolbox.

    But there is a quick error comes out : "Client did not have the Service Changed indication set to enabled.ERROR: BLE_ERROR_INVALID_CONN_HANDLE" in service_changed_send() in nrf_ble_dfu.c.  nrf_toolbox also shows the error message: invalid gatt service handle at the same time.

    Did I package the zip file wrong? But the error seems not even validate my package format.

Related