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

Help with buttonless DFU

Hello!

nRF52832, SDK15, SES

I'm working on a project where DFU is activated by receiving a command from the app. I took ble_app_buttonless_dfu as reference. 

For starters, I will first explain what i added to my project.

Functions:

    -app_shutdown_handler()

    -NRF_PWR_MGMT_HANDLER_REGISTER

    -buttonless_dfu_sdh_state_observer()

    -NRF_SDH_STATE_OBSERVER

    -ble_dfu_evt_handler()

In the services_init() i added

   -ble_dfu_buttonless_init_t dfus_init = {0};
    // Initialize the async SVCI interface to bootloader.
    err_code = ble_dfu_buttonless_async_svci_init();
    APP_ERROR_CHECK(err_code);

    dfus_init.evt_handler = ble_dfu_evt_handler;

    err_code = ble_dfu_buttonless_init(&dfus_init);
    APP_ERROR_CHECK(err_code);

What I thought to do is to force a call on ble_dfu_buttonless_on_ble_evt, something like this:

if(p_evt_write->data[0] == 0x01)
{
       //START DFU
       ble_dfu_buttonless_on_ble_evt(BLE_GATTS_EVT_HVC, NULL);
}

But i'm sure that's not how it's supposed to be done. Can i get some guidance about this? (I have already check Getting started with Nordic's Secure DFU bootloader, a step by step guide and they use an older SDK)

  • You should add your service to buttonless DFU example. it's easier

  • Hi,

    It seems like you have done what you need. Does it not work? You can find a detailed description of the Buttonless DFU service and how to add it to your application in the Buttonless Secure DFU Service documentation.

  • Sorry for the late reply,

    I was testing the documentation you sent me and I had some issues.

    1.- If I enable the DFU Service with bonds in the secure_bootloader project, it doesn´t advertise so I can´t upload the application.

    2.- When without bonds, I can upload the .zip to the DFUTarg and works perfectly. But when trying to upload a new version it crashes. I will upload the log from nrfconnect

    Thank you.

    nRF Connect, 2018-10-09
    buttonlessDFUtest (D1:3E:99:5A:EE:82)
    V 16:18:39.776
    Connecting to D1:3E:99:5A:EE:82...
    D 16:18:39.776
    gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE)
    D 16:19:09.808
    [Callback] Connection state changed with status: 133 and new state: DISCONNECTED (0)
    E 16:19:09.808
    Error 133 (0x85): GATT ERROR
    I 16:19:09.808
    Disconnected
    D 16:19:20.021
    gatt.close()
    D 16:19:20.022
    wait(200)
    V 16:19:20.229
    Connecting to D1:3E:99:5A:EE:82...
    D 16:19:20.229
    gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE)
    D 16:19:29.573
    [Callback] Connection state changed with status: 0 and new state: CONNECTED (2)
    I 16:19:29.573
    Connected to D1:3E:99:5A:EE:82
    D 16:19:29.621
    [Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED
    V 16:19:29.634
    Discovering services...
    D 16:19:29.634
    gatt.discoverServices()
    D 16:19:29.647
    [Callback] Services discovered with status: 0
    I 16:19:29.647
    Services discovered
    V 16:19:29.668
    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)
    Secure DFU Service (0xFE59)
    - Buttonless DFU [I W] (8ec90003-f315-4f60-9fb8-838830daea50)
       Client Characteristic Configuration (0x2902)
    Device Information (0x180A)
    - Manufacturer Name String [R] (0x2A29)
    - PnP ID [R] (0x2A50)
    Unknown Service (f3641400-00b0-4240-ba50-05ca45bf8abc)
    - Unknown Characteristic [N R W] (f3641401-00b0-4240-ba50-05ca45bf8abc)
       Client Characteristic Configuration (0x2902)
    D 16:19:29.669
    gatt.setCharacteristicNotification(8ec90003-f315-4f60-9fb8-838830daea50, true)
    D 16:19:29.673
    gatt.setCharacteristicNotification(f3641401-00b0-4240-ba50-05ca45bf8abc, true)
    V 16:19:36.838
    [DFU] DFU service started
    V 16:19:36.838
    [DFU] Opening file...
    I 16:19:37.685
    [DFU] Firmware file opened successfully
    V 16:19:37.685
    [DFU] Connecting to DFU target...
    D 16:19:37.685
    [DFU] gatt = device.connectGatt(autoConnect = false)
    I 16:19:37.685
    [DFU] Connected to D1:3E:99:5A:EE:82
    V 16:19:37.685
    [DFU] Discovering services...
    D 16:19:37.685
    [DFU] gatt.discoverServices()
    I 16:19:37.685
    [DFU] Services discovered
    D 16:19:37.685
    [DFU] wait(1000)
    W 16:19:38.692
    [DFU] Application with buttonless update found
    V 16:19:38.693
    [DFU] Jumping to the DFU Bootloader...
    V 16:19:38.693
    [DFU] Enabling indications for 8ec90003-f315-4f60-9fb8-838830daea50
    D 16:19:38.693
    [DFU] gatt.setCharacteristicNotification(8ec90003-f315-4f60-9fb8-838830daea50, true)
    D 16:19:38.693
    [DFU] gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x02-00)
    I 16:19:39.246
    [DFU] Data written to descr.8ec90003-f315-4f60-9fb8-838830daea50, value (0x): 02-00
    V 16:19:39.246
    [DFU] Notifications enabled for 8ec90003-f315-4f60-9fb8-838830daea50
    A 16:19:39.246
    [DFU] Indications enabled
    D 16:19:39.246
    [DFU] wait(1000)
    V 16:19:40.272
    [DFU] Writing to characteristic 8ec90003-f315-4f60-9fb8-838830daea50
    D 16:19:40.272
    [DFU] gatt.writeCharacteristic(8ec90003-f315-4f60-9fb8-838830daea50)
    I 16:19:40.864
    Indication received from 8ec90003-f315-4f60-9fb8-838830daea50, value: (0x) 20-01-01
    A 16:19:40.864
    "Response for: Enter bootloader
    Status: Success" received
    I 16:19:40.877
    [DFU] Notification received from 8ec90003-f315-4f60-9fb8-838830daea50, value (0x): 20-01-01
    A 16:19:40.877
    [DFU] Enter bootloader sent (Op Code = 1)
    A 16:19:40.877
    [DFU] Response received (Op Code = 1, Status = 1)
    D 16:19:49.445
    [Callback] Connection state changed with status: 8 and new state: DISCONNECTED (0)
    E 16:19:49.445
    Error 8 (0x8): GATT CONN TIMEOUT
    I 16:19:49.445
    Disconnected
    I 16:19:49.485
    [DFU] Disconnected by the remote device
    D 16:19:49.485
    [DFU] gatt.refresh() (hidden)
    D 16:19:49.485
    [DFU] gatt.close()
    V 16:19:49.485
    [DFU] Scanning for the DFU Bootloader...
    D 16:19:49.499
    [Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED
    D 16:19:49.528
    [DFU] [Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED
    I 16:19:49.725
    [DFU] DFU Bootloader found with address D1:3E:99:5A:EE:82
    V 16:19:49.745
    [DFU] DFU service started
    I 16:19:49.745
    [DFU] Firmware file opened successfully
    D 16:19:49.745
    [DFU] wait(1000)
    D 16:19:50.755
    [DFU] wait(1000)
    V 16:19:51.786
    [DFU] Connecting to DFU target...
    D 16:19:51.787
    [DFU] gatt = device.connectGatt(autoConnect = false)
    I 16:19:52.055
    [DFU] Connected to D1:3E:99:5A:EE:82
    V 16:19:52.055
    [DFU] Discovering services...
    D 16:19:52.055
    [DFU] gatt.discoverServices()
    D 16:19:52.056
    [Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED
    D 16:19:52.074
    [DFU] [Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED
    I 16:19:54.454
    [DFU] Services discovered
    D 16:19:54.491
    [DFU] wait(1000)
    W 16:19:55.472
    [DFU] Application with buttonless update found
    V 16:19:55.472
    [DFU] Jumping to the DFU Bootloader...
    V 16:19:55.472
    [DFU] Enabling indications for 8ec90003-f315-4f60-9fb8-838830daea50
    D 16:19:55.472
    [DFU] gatt.setCharacteristicNotification(8ec90003-f315-4f60-9fb8-838830daea50, true)
    D 16:19:55.472
    [DFU] gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x02-00)
    I 16:19:55.568
    [DFU] Data written to descr.8ec90003-f315-4f60-9fb8-838830daea50, value (0x): 02-00
    V 16:19:55.568
    [DFU] Notifications enabled for 8ec90003-f315-4f60-9fb8-838830daea50
    A 16:19:55.568
    [DFU] Indications enabled
    D 16:19:55.568
    [DFU] wait(1000)
    V 16:19:56.577
    [DFU] Writing to characteristic 8ec90003-f315-4f60-9fb8-838830daea50
    D 16:19:56.578
    [DFU] gatt.writeCharacteristic(8ec90003-f315-4f60-9fb8-838830daea50)
    D 16:19:56.674
    [Callback] Connection state changed with status: 0 and new state: CONNECTED (2)
    I 16:19:56.674
    Connected to D1:3E:99:5A:EE:82
    I 16:19:56.675
    Indication received from 8ec90003-f315-4f60-9fb8-838830daea50, value: (0x) 20-01-01
    A 16:19:56.676
    "Response for: Enter bootloader
    Status: Success" received
    A 16:19:56.689
    [DFU] Enter bootloader sent (Op Code = 1)
    I 16:19:56.689
    [DFU] Notification received from 8ec90003-f315-4f60-9fb8-838830daea50, value (0x): 20-01-01
    A 16:19:56.689
    [DFU] Response received (Op Code = 1, Status = 1)
    V 16:19:56.689
    Discovering services...
    D 16:19:56.689
    gatt.discoverServices()
    D 16:19:56.705
    [Callback] Services discovered with status: 0
    I 16:19:56.705
    Services discovered
    V 16:19:56.741
    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)
    Secure DFU Service (0xFE59)
    - Buttonless DFU [I W] (8ec90003-f315-4f60-9fb8-838830daea50)
       Client Characteristic Configuration (0x2902)
    Device Information (0x180A)
    - Manufacturer Name String [R] (0x2A29)
    - PnP ID [R] (0x2A50)
    Unknown Service (f3641400-00b0-4240-ba50-05ca45bf8abc)
    - Unknown Characteristic [N R W] (f3641401-00b0-4240-ba50-05ca45bf8abc)
       Client Characteristic Configuration (0x2902)
    D 16:19:56.741
    gatt.setCharacteristicNotification(8ec90003-f315-4f60-9fb8-838830daea50, true)
    D 16:19:56.744
    gatt.setCharacteristicNotification(f3641401-00b0-4240-ba50-05ca45bf8abc, true)

  • Hi,

    1. I cannot say for sure what is happening without more information. The bootloader should advertise. If it does not, then you could probably find some information by debugging (I would start with logging).

    2. The log shows a disconnect due to timeout. Can you say more about what you do? And can you upload a log from the bootloader side (you will get RTT logging by using the pca10040_ble_debug project.

  • I figured it out. I will explain what i did if someone else get the same issue.

    First of all i added my code to the buttonless DFU example as Giang suggested. 

    Then my mistake was to think that pressing the DFU button on nRF connect was gonna do all the job and the app was trying to upload the new version not in the secure_bootloader. So i had to go the services in my application and restore to bootloader there and connect to DFUTarg again and upload the new version of my application.

    I guess the app i make for the phone will have to do all that in the background.

Related