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.

  • Hi,Bjorn

    Same error message. 

    Yes , my hw version is PCA20023. 

  • Hmm, I did a quick test with a clean install of SR3 and i did not see any issues

    Generate a private key with nrfutil using 

    nrfutil keys generate private_key.pem

    and then generated the public key using 

    nrfutil keys display --key pk --format code --out_file bootloader_key_custom.c private_key.pem

    and then I generated a custom DFU image using 

    nrfutil pkg generate --application PCA20023-SR3_nRF52832_Product_Example.hex --application-version 1 --hw-version 0x20023 --sd-req 0xA5 --key-file private_key.pem sr3_dfu_pkg.zip 

    I then perform the DFU with nRF Connect for Desktop according to the instructions in the SR3 documentation under Running DFU ( doc found under C:\Nordic Semiconductor\nRFready Smart Remote 3 nRF52 v1.2.1alpha by clicking Firmware Documentation shourtcut 


  • Alright, I will check again where  I did wrong. 

    Thanks.

    Ralph

  • Hi, Bjorn

    When you ran DFU test last time,was the app area empty or not?

    After testing, DFU can be done when the device only has softdevice and bootloader.

    But after that, I can't run another DFU again with the same error message.

    Thanks.

    Ralph  

  • Hi Ralph, 

    Yes, the SR3 application FW was present when I performed the DFU. Are you using the  SR3 application FW that you have modified or are you using the default example?

    The SR3 bootloader requires you to bond with the application in order to perform DFU, so make sure that you have done that prior to starting the DFU. 

    Did the error message show up in nRF Connect for Desktop /iOS/ Android? Or are you still using nRF Toolbox?

    Best regards

    Bjørn

Reply
  • Hi Ralph, 

    Yes, the SR3 application FW was present when I performed the DFU. Are you using the  SR3 application FW that you have modified or are you using the default example?

    The SR3 bootloader requires you to bond with the application in order to perform DFU, so make sure that you have done that prior to starting the DFU. 

    Did the error message show up in nRF Connect for Desktop /iOS/ Android? Or are you still using nRF Toolbox?

    Best regards

    Bjørn

Children
  • Hi, Bjorn

    I use both : my own modified project base on example and default example.

    nRF Connect would bond it automatically when the device is in application mode, after entering DFU mode,I have to reconnect it, otherwise the DFU icon on the right corner won't show up.

    I use nRF Connect for Android cellphone, the error message doesn't show up in nRF connect but does in RTT viewer.

    Will changing the sections' boundary of the memory(APP,BL) cause the problem?

    Or nrfutil's parameters like bootloader version ,app version,etc ? 

  • I am not seeing any "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.  error message when performing DFU with nRF Connect for Android and monitoring the RTT log output

    No, changing the memory layout should not affect the Service Changed indication. Nor should the nrfutil parameters. 

    Which version of the nRF Connect app are you using? Could you try to use nRF Connect for Desktop as well and see if you get the same behaviour?

  • Hi, Bjorn 

    I borrow another Android smart phone from my colleague,and it works to upload my zip file.

    My Android smart phone's specification:

    Redmi 5 , Android 7.1.2  BT 4.2

    My colleague's specification:

    LG V10 , Android 5.1.1 BT 4.1 

    nRF CONNECT versions I guess are the same, I downloaded it last week, 

    he downloaded it today. 

  • OK, so the issue is only present on your phone i.e. Redmi 5, Android 7.1.2 supporting BT 4.2 and not your colleague's LG V10 , Android 5.1.1 supporting BT 4.1. 

    Could you print the m_conn_handle variable when you get the BLE_GAP_EVT_CONNECTED in ble_evt_handler() in nrf_ble_dfu.c after connecting with the Redmi phone and then print it again in service_changed_send() prior to calling sd_ble_gatts_service_changed? 

    I would like to see it the connection handle is changed in between these two calls. 

    Best regards

    Bjørn 

     

  • Hi, Bjorn 

    I will check it next week.

    BTW, I also use the third smart phone to try it,and this one can't even show all the GATT services but only the first two services GENERIC Access & Generic Attribute. 

    Its spec is sony XA  Android 7.0 BT 4.1 

    If you want to know .  

    Thanks.

    Ralph

Related