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

DFU is Failed on nrf connect for desktop, when use public device address.

I modified,
 My application's bdaddr is set public device address.
 secure bootloader's bdaddr is set same public device address.

When run DFU on nrf connect for desktop,
nrf connect for desktop is hung up.

When use nrf connect for mobile(Android), It's no problem.

  • Hi,

    I have not been able to reproduce this issue. Can you double check that the nRF uses the expected address when in bootloader mode? Depending on NRF_DFU_BLE_REQUIRES_BONDS, that should be either your public address or public address + 1. nRF Connect for mobile can also use device name to separate devices so it might work even if the address is not correct.

  • 1.  Connect to Allication.

    2. run the DFU. wait a bit. (nrf connect is down to white screen.)


    3. rescan and connect.

    Aditional,
    If you execute DFU on DfuTarg, it will work normally.

  • Hi,

    Now I see the problem. You have the exact same address in bootloader mode and in normal mode, but nRF Connect will assume that the address is incremented by one when not using bonding in the bootloader.

    Where did you set the public BLE address in the bootloader? Referring to components\libraries\bootloader\ble_dfu\nrf_dfu_ble.c you have a gap_address_change() function there, which takes the address and increments it (when not using bonding in bootloader). You should change your address immediately before that runs, or modify that function to set it to your public address + 1. (I admit though that this approach is a bit odd with public addresses as there is a higher likelihood of having a device in range with this +1 address, but that is how this has been solved).

  • I added the following:,

    nrf_dfu_ble.c
    ................
    static uint32_t advertising_init(uint8_t adv_flags, ble_gap_adv_params_t const * const p_adv_params)
    {
        uint32_t err_code;
        uint16_t actual_device_name_length = BLE_GAP_ADV_SET_DATA_SIZE_MAX - APP_ADV_DATA_HEADER_SIZE;
    
        /* This needs to be static because of SoftDevice API requirements. */
        static uint8_t m_enc_advdata[BLE_GAP_ADV_SET_DATA_SIZE_MAX];
    
        ble_gap_adv_data_t m_adv_data =
        {
            .adv_data =
            {
                .p_data = m_enc_advdata,
                .len    = APP_ADV_DATA_HEADER_SIZE,
            }
        };
     /****** Add start ********/
        ble_gap_addr_t bdaddr;
        bdaddr.addr_id_peer = 0;
        bdaddr.addr_type = BLE_GAP_ADDR_TYPE_PUBLIC;
        memcpy(&bdaddr.addr, PUBLIC_DEVICE_ADDRESS, BLE_GAP_ADDR_LEN);
        sd_ble_gap_addr_set(&bdaddr);
     /****** Add end   ********/
    

    Please tell me the best place to set BDADDR.
    (top of gap_params_init()?)

  • Hi,

    loquat said:
    Please tell me the best place to set BDADDR.

    The problem here is that you set the address after it has allready been set by the bootloader, which reads the address increments by one and writes it. This is done in gap_address_change() in nrf_dfu_ble.c. I suggest you either change that function directly, or add another function that is called immediately before it, that sets the public address, and then gap_address_change() will be called to increment it again by 1 only if appropriate (which is when not using bonding in the bootloader, which is the most sensible in most cases).

Related