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

Buttonless DFU with bond not working

Hi,

I'm struggling to get Buttonless DFU with bond enabled working.

Setup details:

1) SDK 14.2

2) DK board - nrf52832

3) nrfconnect app on Android phone (8.0) :

DFU settings = Pkts receipt notification procedure : ON

Number of packets : 10

MBR : 4096

Keep bond information: ON

External MCU DFU : OFF

4) Custom app with bond enabled, BLE_GAP_ADDR_TYPE_RANDOM_STATIC(C1:C1:C1:C1:C1:C1), MITM enabled,

Followed the steps to generate bootloader keys and everything seems to be fine. Flashed SD, BL, APP onto DK board and I can see the app running.

Connected nrfconnect to my custom app, paired succesfully. I can see secure DFU service with Secure buttonless DFU.

After enabling the indication, I write value "0x01" and send to switch to DFU mode. I see device moved to DFU mode but with BD addr = EA:F8:73:D2:B8:CC.

Connected nrfconnect to DfuTarg and if I try to DFU, I think device switches to my custom app and I don't see DFU happening any more.

I'm wondering what would be wrong and I believe encryption fails due to different BD address used in DFU and app mode. What am I missing?

Tried looking into Nordic blogs, dev support but could not move forward. Also, I tried to see the DFU NRF log but I don't see any log messages

All I see on power ON is

<info> µ˜°: Setting vector table to bootloader: 0x00066000
<info> µ˜°: Setting vector table to main app: 0x00023000
<info> µ˜°: Record ID:    0x0001
<info> µ˜°: File ID:    0xF020
<info> µ˜°: Record key:    0x7010

I did used \nRF5_SDK_14.2.0_17b948a\examples\dfu\bootloader_secure_ble\pca10040_debug\armgcc\Makefile with logger enabled and optimization is -O0 in makefile. I'm not sure DFU logger does not show up in RTT viewer.

Attached are the config,make files for reference.

Your help is highly appreciated.

dfu.rarapp.rar

Parents
  • Hi,

    By default, the SoftDevice will use DEVICEADDR[0] and (half of) DEVICEADDR[1] as the MAC address. This will be used by both the bootloader and application unless you explicitly set some other address. If you set another address in your application (why?), then you must do so in the bootloader as well.

    The example without bond sharing however, does not rely on having the same address. In fact, it needs to have a different address and will therefore typically be the default mac address (from  DEVICEADDR) incremented by one.

  • Hi,

    >> If you set another address in your application (why?), 

    To have unique address for different products. After doing as per your suggestion, I could progress little bit but now I get dfu error "Remote DFU error: INVALID OBJECT". I believe it is for Execute Opcode i.e. dfu_decode_commmand() returning false. I see log message in the dfu code as "Handler: Invalid protocol buffer stream". Not sure what I'm missing.

    Attached log file captured.

    Appreciate your help

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    nRF Connect, 2018-06-25
    Aquapark_N (C0:C0:C0:C0:C0:C0)
    V 20:24:34.320 Connecting to C0:C0:C0:C0:C0:C0...
    D 20:24:34.321 gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, preferred PHY = LE 1M)
    D 20:24:34.394 [Callback] Connection state changed with status: 0 and new state: CONNECTED (2)
    I 20:24:34.394 Connected to C0:C0:C0:C0:C0:C0
    D 20:24:34.398 [Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED
    V 20:24:34.431 Discovering services...
    D 20:24:34.431 gatt.discoverServices()
    I 20:24:35.204 PHY updated (TX: LE 2M, RX: LE 2M)
    I 20:24:35.657 Connection parameters updated (interval: 7.5ms, latency: 0, timeout: 5000ms)
    D 20:24:35.909 [Callback] Services discovered with status: 0
    I 20:24:35.909 Services discovered
    V 20:24:35.943 Generic Access (0x1800)
    - Device Name [R W] (0x2A00)
    - Appearance [R] (0x2A01)
    - Peripheral Preferred Connection Parameters [R] (0x2A04)
    - Central Address Resolution [R] (0x2AA6)
    Generic Attribute (0x1801)
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • But I don't have your application. Can you please upload the full project, then I may test it. I assume that you haven't changed anything in the bootloader? So I can combine the sdk_config for the bootloader with the bootloader project in the SDK.

     

    But please upload the application that you have modified.

    BR,

    Edvin

  • Hi Edvin,

    The application has IP in it but anyway I will try to remove the IP part and I can share it if you make this thread private please.

    In bootloader I have changed to take the static random address and I will share this part as well.

    Thank you

    Regards

    Suresh

  • Hello,

    You can send me a PM.

    I suspect that there is something wrong in the setup of the Buttonless_DFU service (After you changed the application-version to 1 higher than the currently running application).

     

    BR,

    Edvin

  • Hi,

    Attached is the APP. U need to run the batch file(part of .rar) to burn UICR before flashing program.

    Expecting your reply.

    Regards

    Suresh

    power_strip.rar

  • I will not have time to look at your application today. We are a bit short staffed these days. What you can do in the meantime is to start with a standard case of buttonless_dfu with bonding, as I described in a previous post, and try to change one thing at the time, and see where it fails. You have a better overview than me what changes you have done. I suspect that there are some issues in the way that the address is changed. Maybe the board performing the DFU doesn't look for the correct address? What happens if you don't change the address?

     

    BR,

    Edvin

Reply
  • I will not have time to look at your application today. We are a bit short staffed these days. What you can do in the meantime is to start with a standard case of buttonless_dfu with bonding, as I described in a previous post, and try to change one thing at the time, and see where it fails. You have a better overview than me what changes you have done. I suspect that there are some issues in the way that the address is changed. Maybe the board performing the DFU doesn't look for the correct address? What happens if you don't change the address?

     

    BR,

    Edvin

Children
  • All I did in bootloader and app is changed the BD address to static random instead of default one. If bootloader address is default i can't dfu because application is bonded with static random address.

    Mean time will try with default button less app as suggested.

    I will wait for your inputs.

    Thank you

    Regards

    Suresh

  • Hello,

    Have you changed the address in the bootloader like you did in the application in file ble_app.c on line 545-548?

    If you have, can you send the bootloader project as well, so I can replicate the error?

     

    Edit:

    I tried to change the address like you did in the bootloader project (hard coded), and now the DFU worked. Not an elegant fix, but you can do this for testing. In the file nrf_ble_dfu.c in the bootloader_secure_ble project, change the gap_params_init() function to the following:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    static uint32_t gap_params_init(void)
    {
    uint32_t err_code;
    ble_gap_conn_params_t gap_conn_params = {0};
    ble_gap_conn_sec_mode_t sec_mode;
    uint8_t const * device_name;
    uint32_t name_len;
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
    #if !defined(NRF_DFU_BLE_REQUIRES_BONDS) || (NRF_DFU_BLE_REQUIRES_BONDS == 0)
    err_code = gap_address_change();
    VERIFY_SUCCESS(err_code);
    if ((m_flags & DFU_BLE_FLAG_USE_ADV_NAME) != 0)
    {
    NRF_LOG_DEBUG("Setting adv name: %s, length: %d", (uint32_t)m_adv_name.name, m_adv_name.len);
    device_name = m_adv_name.name;
    name_len = m_adv_name.len;
    }
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

     

    If that works, read out the address from the register, as you do in the app that you sent me.

    The problem for me was that the bootloader didn't use the custom address, and started advertising as DfuTarg with a random address, so the kit that performed the DFU with nRF Connect couldn't find the bootloader board (because it doesn't expect it to change address if bonding is required).

     

    Best Regards,

    Edvin

  • ble_dfu.rar

    Hi,

    I did changes as per your suggestion but still I see GATT WRITE ERROR.

    V             06:03:45.817      [DFU] Enabling indications for 8ec90004-f315-4f60-9fb8-838830daea50

    D            06:03:45.817      [DFU] gatt.setCharacteristicNotification(8ec90004-f315-4f60-9fb8-838830daea50, true)

    D            06:03:45.819      [DFU] gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x02-00)

    E             06:03:45.891      [DFU] Error (0x03): GATT WRITE NOT PERMIT

    V             06:03:45.891      [DFU] Disconnecting...

    D            06:03:45.913      [DFU] gatt.disconnect()

    I              06:03:45.913      [DFU] Disconnected

    D            06:03:45.913      [DFU] gatt.close()

    My steps(used pca10040_debug of BL):

    After building app, bootloader I use "flash_sd_bl_app" command from makefile to flash a fresh chip i.e. SD + BL + APP at one go.

    I change the APP_VERSION to 2, re-build app and generate DFU package using "generate_dfu_pkg" command from makefile.

    I connect nrfconnect from Android phone to device, pair, click on DFU icon and choose the generted dfu package (from above). I see GATT WRITE ERROR as above(check attached dfu_bond.docx file for more info).

    Could you let me the detailed steps using Android phone if you succeed in getting DFU working.

    I'm wondering if I'm doing something stupid.

    Thank you

  • It looks like you are not bonded. Are you sure that you are?

    Could it be that there are other devices in the same area advertising with the same address (C0:C0:C0:C0:C0:C0)?

    Try to change the address to something else, something random that no other device in the area is using. Remember to change to that device in the bootloader as well.

     

    When you get the GATT WRITE NOT PERMIT, what LEDs on the DK is on? (LED1 and LED3) or (LED2 and LED3)? 

    If it is LED1 and LED3, this suggests that you are not connected to the correct device, because it should change to LED2 and LED3 when it is connected.

     

    I just ran the DFU process with your application and with the modified bootloader where the address is changed in nRF Connect for iOS, and it works. 

     

    BR,

    Edvin

  • I see the device is connected to Android phone in bootloader mode( Led 2 and 3 are ON). I suspect Android_8.0 phone is not encrypting the link when connecting to device in bootloader mode( will confirm with sniffer). When I try to enable or disable dfu service indication I see GAtt write error  and trying to read char configuration of dfu service gives ""expected 16bit but got 128  bit" error message. Do I need to change the bootloader device name "DfuTarg" to match with application device name? Does having different name makes phone to think different device in bootloader mode even though BD address is same?

    Could you share your bootloader sdk_config.h file please?

    Regards

    Suresh