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

DFU upgrade

Regarding DFU upgrade, I have the following questions(sdk14.2):
1.nrf52832 will be paired and bound after connecting with the mobile phone, then in the sdk_config.h file NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS is not necessarily set to 1, not set to 1 what will be the consequences?
2. I added buttonless dfu to my program code, but the ble_dfu_buttonless_async_svci_init() function returns the error NRF_ERROR_NO_MEM, I have defined NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS as 1, how do I need to modify it?
3. When debugging the program, I burned the protocol stack and the BootLoader program and debug it in Keil. I can't run it. What are the possible reasons? Should I program the BootLoader program when debugging?

Parents
  • Hello,

    1: I recommend setting NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS to 0, since if you for some reason loose the bonding information while you are in DFU mode, then the device is bricked (unless you can erase the chip and reprogram it), so not using bonds while in DFU is recommended, if not security is really important.

    2: again, set NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS to 0 if not needed. Can you try to enable logging, and see if you get some warning regarding RAM start and RAM size? If so, can you try to change the RAM settings accordingly, and see whether the issue persists?

    3: Regarding debugging the ble_app_buttonless_dfu example, please see this post.

     

    Best regards,

    Edvin

  • If nrf52832 is already bound to the phone, can you upgrade it directly to DFU? Or must you manually ignore the bindings in your phone?

  • If you use NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS = 0, then when you enter DFU mode, the device will advertise with a new address = old_address + 1. This is done because the phone will think of it as a new device, and it will do a service discovery, and it will find out that it has the DFU service. So you don't have to remove the bonding data on your phone.

     

    The device will advertise with the advertising name DfuTarg, and you can assume that the address is incremented by 1, so that you know what device to connect to, if you write a custom app for the phone.

     

    Best regards,

    Edvin

  • Buttonless dfu example from the application into the bootloader, the system is not reset, the data in RAM will still be saved, then bootloader dfu completed after entering the new application again, the previous RAM data will be lost? Also, after switching from application to bootloader, does the peripheral need to be reinitialized?

Reply Children
  • You can find some info on the buttonless dfu here.

     

    As you see there, the RAM is retained when you enter DFU mode.

    Since the buttonless DFU doesn't do a softReset, I am not sure what the reset handler of the bootloader does with the peripherals. Have you tested?

     

    BR,

    Edvin

  • I still want to know that when I set NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS to 1, DFU can successfully update the software after pairing with iphone, but when using Android phone and nrf52832 to update with nRF Toolbox, “Upload failed: GATT WRITE NOT PERMIT” will appear. Error message. By log view, the reason seems to be "Client did not have the Service Changed indication set to enabled"
    The settings related to DFU in application's sdk_config.h are as follows:
    1.#define BLE_DFU_ENABLED 1
    2.#define NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS 1
    3.#define NRF_SDH_BLE_SERVICE_CHANGED 1
    DFU related settings in sdk_config.h in bootloader are as follows
    1.#define NRF_DFU_BLE_REQUIRES_BONDS 1
    2.#define NRF_SDH_BLE_SERVICE_CHANGED 1

    In addition, the relevant log output information is as follows, please help look at what is the problem? Thank you!

    0> <debug> nrf_sdh_ble: BLE event: 0x50.
    0> <info> app: Received indication state 1
    0> <debug> nrf_sdh_soc: SoC event: 0x2.
    0> <debug> nrf_sdh_soc: SoC event: 0x2.
    0> <debug> nrf_sdh_soc: SoC event: 0x2.
    0> <debug> nrf_sdh_soc: SoC event: 0x2.
    0> <debug> nrf_sdh_soc: SoC event: 0x2.
    0> <debug> nrf_sdh_ble: BLE event: 0x51.
    0> <info> app: Writing peer data to the bootloader
    0> <info> app: ---------------system attribute table: 8--------------
    0> <debug> nrf_sdh_soc: SoC event: 0x2.
    0> <info> app: Inside main
    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: Running nrf_dfu_settings_init(sd_irq_initialized=false).
    0> <debug> nrf_dfu_flash: Calling nrf_dfu_flash_init(sd_irq_initialized=false)...
    0> <debug> nrf_dfu_flash: Initializing nrf_fstorage_nvmc backend.
    0> <debug> app: Initializing the clock.
    0> <debug> app: Enter nrf_dfu_continue
    0> <debug> app: Valid App
    0> <debug> app: Application sent bootloader request
    0> <debug> app: In nrf_dfu_transports_init
    0> <debug> app: num transports: 1
    0> <debug> app: Initializing BLE DFU transport
    0> <debug> app: Copying peer data
    0> <debug> app: vector table: 0x00073000
    0> <debug> app: vector table: 0x00073000
    0> <debug> app: Error code - sd_softdevice_vector_table_base_set: 0x00000000
    0> <debug> app: Running Service Changed config
    0> <debug> app: Finished running Service Changed config
    0> <debug> app: Enabling SoftDevice.
    0> <warning> nrf_sdh_ble: RAM starts at 0x20002830, can be adjusted to 0x20001FF0.
    0> <warning> nrf_sdh_ble: RAM size can be adjusted to 0xE010.
    0> <debug> app: SoftDevice enabled.
    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(sd_irq_initialized=true)...
    0> <debug> nrf_dfu_flash: Initializing nrf_fstorage_sd backend.
    0> <debug> app: Waiting for events
    0> <debug> app: == conn sec update request
    0> <debug> app: Sending Service Changed indication
    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
    0> <debug> app: DFU reset due to inactivity timeout.
    0> <info> app: Inside main
    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: Running nrf_dfu_settings_init(sd_irq_initialized=false).
    0> <debug> nrf_dfu_flash: Calling nrf_dfu_flash_init(sd_irq_initialized=false)...
    0> <debug> nrf_dfu_flash: Initializing nrf_fstorage_nvmc backend.
    0> <debug> app: Initializing the clock.
    0> <debug> app: Enter nrf_dfu_continue
    0> <debug> app: Valid App
    0> <debug> app: Enter nrf_dfu_app_is_valid
    0> <debug> app: Return true. App was valid
    0> <debug> nrf_dfu_settings_svci: Erasing settings page additional data.
    0> <debug> app: Enter nrf_dfu_app_is_valid
    0> <info> app: started
    0> <debug> nrf_sdh: State request: 0x00000000
    0> <debug> nrf_sdh: Notify observer 0x0003B22C => ready
    0> <debug> nrf_sdh: State change: 0x00000000
    0> <debug> nrf_sdh: State change: 0x00000001
    0> <debug> nrf_sdh_ble: RAM starts at 0x20001FF0
    0> <info> app: Setting vector table to bootloader: 0x00073000
    0> <info> app: Setting vector table to main app: 0x00023000

  • Hello,

    GATT WRITE NOT PERMIT is usually related to insufficient encryption of the link. Are you sure that the android phone is encrypting the link? Maybe you can compare the two logs for the Android and iPhone and see if you can find any difference.

     

    Just a small side note:

    You should update your RAM start and RAM size according to the log warnings. This is to prevent unexpected errors. However, it doesn't look like this is the source of the issue.

     

    Let me rephrase my first answer in this post:

    You can use NRF_DFU_BLE_BUTTONLESS_SUPPORTS_BONDS = 1. Just be aware that if you use this in a product without a programming chip, and someone manages to delete bonding information on e.g. the phone while the device is in DFU mode, then the device will be bricked. It would have to be programmed with a programmer in order to be restored. As long as you are aware of this, there is no problem using bonding in DFU.

     

    It looks like in your log that the Android doesn't enable indications for the Service Changed, so the phone does not notice that the device enters DFU mode, and the device times out the DFU session due to inactivity timeout.

     

    Can you compare this log with the log from the iPhone, and see if you get any noticeable difference? Does it say that the link is encrypted when you connect with the iPhone? And does it say that "Client did not have the Service Changed indication set to enabled. Error: 0x00000008"

     

    Best regards,

    Edvin

Related