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

custom DFU package

Hi,

I am using nRF51822, SDK 10, SoftDevice S110 v.8

I am strugling with DFU over BLE using custom DFU package.

I am able to flash bootloader and update FW with pregenerated files in SDK using nrf Connect(\dfu\ble_dfu_send_hex\test_images_update_nrf51\dfu_test_app_hrm_s110.zip).

But strugling with custom made package. Update of application is good enough for me. I do not need to update softdevice nor bootloader.

I use these commands in nrfutil:

nrfutil keys generate privatekey.pem
nrfutil pkg generate --hw-version 51 --sd-req 0x64 --application-version 4 --application nrf51422_xxac_s110.hex --key-file privatekey.pem app_dfu_package.zip

DFU fails in both nrf Connect and nRF Toolbox. Error is: disconnected by remote device .

I followed this tutorial: https://devzone.nordicsemi.com/nordic/short-range-guides/b/software-development-kit/posts/setting-up-device-firmware-updatedfu-on-the-nrf5-d

But there is not much about generating of custom DFU packages. I think problem could be signing. (I do not understand it properly and I am probably missing something... I sign the package but how does the application currently running on nRF51822 know right key?) 

Could you please guide me?

Thanks,

Mila

  • Hello,

    You must use nrfutil version 0.5.x to generate DFU packages for our legacy DFU solution (ie everything pre-SDK version 12). And instructions on how to generate a legacy DFU packet can be found in the SDK documentation here: Creating an image file

    Note that the legacy bootloader did not support FW signing, so the private key will not be needed.

    Old nrfutil executable:

    https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-caeda5fe0e86403d96fd321fac1e3bfd/nrfutil.exe

  • Thank you. Right version of nrfutil helped me to create right package.

    I am now able to perform DFU over BLE several times when I create packege from example project. But i do have issue with my project. I can perform DFU over BLE with my project but only once. Once my application is running I can not update it with anything.

    It is modified ble_app_hrs S110 with DFU example I added Nordic UART service and app_timers for communication with sensors. I did no change to device manager, nor parts of code with compiler switch DFU.

    DFU always fails with this error: [DFU] Disconnected by the remote device

    Log from nrf Connect is attached. Where do you think the issue could be?

    Thank you

    nRF Connect, 2020-06-17
    PEPA (E2:E3:43:E4:49:7D)
    V	23:44:04.176	Connecting to E2:E3:43:E4:49:7D...
    D	23:44:04.176	gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, preferred PHY = LE 1M)
    D	23:44:04.894	[Callback] Connection state changed with status: 0 and new state: CONNECTED (2)
    I	23:44:04.894	Connected to E2:E3:43:E4:49:7D
    D	23:44:04.895	[Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED
    V	23:44:04.912	Discovering services...
    D	23:44:04.912	gatt.discoverServices()
    I	23:44:05.232	Connection parameters updated (interval: 7.5ms, latency: 0, timeout: 5000ms)
    D	23:44:05.687	[Callback] Services discovered with status: 0
    I	23:44:05.687	Services discovered
    V	23:44:05.707	Generic Access (0x1800)
    - Device Name [R W] (0x2A00)
    - Appearance [R] (0x2A01)
    - Peripheral Preferred Connection Parameters [R] (0x2A04)
    Generic Attribute (0x1801)
    - Service Changed [I] (0x2A05)
       Client Characteristic Configuration (0x2902)
    Nordic UART Service (6e400001-b5a3-f393-e0a9-e50e24dcca9e)
    - TX Characteristic [N] (6e400003-b5a3-f393-e0a9-e50e24dcca9e)
       Client Characteristic Configuration (0x2902)
    - RX Characteristic [W WNR] (6e400002-b5a3-f393-e0a9-e50e24dcca9e)
    Heart Rate (0x180D)
    - Heart Rate Measurement [N] (0x2A37)
       Client Characteristic Configuration (0x2902)
    - Body Sensor Location [R] (0x2A38)
    Device Firmware Update Service (00001530-1212-efde-1523-785feabcd123)
    - DFU Packet [WNR] (00001532-1212-efde-1523-785feabcd123)
    - DFU Control Point [N W] (00001531-1212-efde-1523-785feabcd123)
       Client Characteristic Configuration (0x2902)
    - DFU Version [R] (00001534-1212-efde-1523-785feabcd123)
    D	23:44:05.707	gatt.setCharacteristicNotification(00002a05-0000-1000-8000-00805f9b34fb, true)
    D	23:44:05.710	gatt.setCharacteristicNotification(6e400003-b5a3-f393-e0a9-e50e24dcca9e, true)
    D	23:44:05.712	gatt.setCharacteristicNotification(00002a37-0000-1000-8000-00805f9b34fb, true)
    I	23:44:05.738	Connection parameters updated (interval: 48.75ms, latency: 0, timeout: 5000ms)
    I	23:44:15.617	Connection parameters updated (interval: 1998.75ms, latency: 0, timeout: 32000ms)
    V	23:44:16.554	Reading characteristic 00002a38-0000-1000-8000-00805f9b34fb
    D	23:44:16.554	gatt.readCharacteristic(00002a38-0000-1000-8000-00805f9b34fb)
    I	23:44:21.190	Read Response received from 00002a38-0000-1000-8000-00805f9b34fb, value: (0x) 03
    A	23:44:21.190	"Finger" received
    V	23:44:34.104	[DFU] DFU service started
    V	23:44:34.104	[DFU] Opening file...
    I	23:44:34.104	[DFU] Firmware file opened successfully
    V	23:44:34.104	[DFU] Connecting to DFU target...
    D	23:44:34.107	[DFU] gatt = device.connectGatt(autoConnect = false)
    I	23:44:34.110	[DFU] Connected to E2:E3:43:E4:49:7D
    V	23:44:34.111	[DFU] Discovering services...
    D	23:44:34.111	[DFU] gatt.discoverServices()
    I	23:44:34.113	[DFU] Services discovered
    D	23:44:34.120	[DFU] wait(1000)
    V	23:44:35.117	[DFU] Reading DFU version number...
    D	23:44:35.117	[DFU] gatt.readCharacteristic(00001534-1212-efde-1523-785feabcd123)
    I	23:44:37.163	[DFU] Read Response received from 00001534-1212-efde-1523-785feabcd123, value (0x): 01-00
    A	23:44:37.163	[DFU] Version number read: 0.1
    W	23:44:37.165	[DFU] Application with buttonless update found
    V	23:44:37.165	[DFU] Jumping to the DFU Bootloader...
    V	23:44:37.165	[DFU] Enabling notifications for 00001531-1212-efde-1523-785feabcd123
    D	23:44:37.165	[DFU] gatt.setCharacteristicNotification(00001531-1212-efde-1523-785feabcd123, true)
    D	23:44:37.166	[DFU] gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x01-00)
    I	23:44:41.161	[DFU] Data written to descr.00001531-1212-efde-1523-785feabcd123, value (0x): 01-00
    V	23:44:41.161	[DFU] Notifications enabled for 00001531-1212-efde-1523-785feabcd123
    A	23:44:41.161	[DFU] Notifications enabled
    D	23:44:41.161	[DFU] wait(1000)
    V	23:44:42.178	[DFU] Writing to characteristic 00001531-1212-efde-1523-785feabcd123
    D	23:44:42.178	[DFU] gatt.writeCharacteristic(00001531-1212-efde-1523-785feabcd123)
    D	23:45:12.175	[Callback] Connection state changed with status: 22 and new state: DISCONNECTED (0)
    E	23:45:12.175	Error 22 (0x16): GATT CONN TERMINATE LOCAL HOST
    I	23:45:12.175	Disconnected
    A	23:45:12.175	[DFU] Jump to bootloader sent (Op Code = 1, Upload Mode = 4)
    I	23:45:12.176	[DFU] Disconnected by the remote device
    D	23:45:12.203	[DFU] gatt.refresh() (hidden)
    D	23:45:12.203	[DFU] gatt.close()
    V	23:45:12.213	[DFU] DFU service started
    I	23:45:12.213	[DFU] Firmware file opened successfully
    D	23:45:12.213	[DFU] wait(1000)
    D	23:45:13.214	[DFU] wait(1000)
    V	23:45:14.217	[DFU] Connecting to DFU target...
    D	23:45:14.258	[DFU] gatt = device.connectGatt(autoConnect = false)
    D	23:45:15.177	[Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED
    D	23:45:15.183	[DFU] [Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED
    D	23:45:16.361	[Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED
    D	23:45:16.362	[DFU] [Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED
    I	23:45:16.369	[DFU] Connected to E2:E3:43:E4:49:7D
    V	23:45:16.369	[DFU] Discovering services...
    D	23:45:16.369	[DFU] gatt.discoverServices()
    I	23:45:17.210	[DFU] Services discovered
    D	23:45:17.227	[DFU] wait(1000)
    V	23:45:18.219	[DFU] Reading DFU version number...
    D	23:45:18.219	[DFU] gatt.readCharacteristic(00001534-1212-efde-1523-785feabcd123)
    I	23:45:18.307	[DFU] Read Response received from 00001534-1212-efde-1523-785feabcd123, value (0x): 01-00
    A	23:45:18.308	[DFU] Version number read: 0.1
    W	23:45:18.309	[DFU] Application with buttonless update found
    V	23:45:18.309	[DFU] Jumping to the DFU Bootloader...
    V	23:45:18.309	[DFU] Enabling notifications for 00001531-1212-efde-1523-785feabcd123
    D	23:45:18.309	[DFU] gatt.setCharacteristicNotification(00001531-1212-efde-1523-785feabcd123, true)
    D	23:45:18.311	[DFU] gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x01-00)
    I	23:45:18.405	[DFU] Data written to descr.00001531-1212-efde-1523-785feabcd123, value (0x): 01-00
    V	23:45:18.405	[DFU] Notifications enabled for 00001531-1212-efde-1523-785feabcd123
    A	23:45:18.405	[DFU] Notifications enabled
    D	23:45:18.405	[DFU] wait(1000)
    V	23:45:19.426	[DFU] Writing to characteristic 00001531-1212-efde-1523-785feabcd123
    D	23:45:19.426	[DFU] gatt.writeCharacteristic(00001531-1212-efde-1523-785feabcd123)
    A	23:45:19.478	[DFU] Jump to bootloader sent (Op Code = 1, Upload Mode = 4)
    I	23:45:19.586	[DFU] Disconnected by the remote device
    D	23:45:19.587	[DFU] gatt.refresh() (hidden)
    D	23:45:19.588	[DFU] gatt.close()
    D	23:45:19.589	[Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED
    D	23:45:19.592	[DFU] [Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED
    V	23:45:19.597	[DFU] DFU service started
    I	23:45:19.597	[DFU] Firmware file opened successfully
    D	23:45:19.597	[DFU] wait(1000)
    D	23:45:20.598	[DFU] wait(1000)
    V	23:45:21.602	[DFU] Connecting to DFU target...
    D	23:45:21.639	[DFU] gatt = device.connectGatt(autoConnect = false)
    D	23:45:22.113	[Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED
    D	23:45:22.114	[DFU] [Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED
    I	23:45:22.117	[DFU] Connected to E2:E3:43:E4:49:7D
    V	23:45:22.118	[DFU] Discovering services...
    D	23:45:22.118	[DFU] gatt.discoverServices()
    I	23:45:22.915	[DFU] Services discovered
    D	23:45:22.943	[DFU] wait(1000)
    V	23:45:23.946	[DFU] Reading DFU version number...
    D	23:45:23.946	[DFU] gatt.readCharacteristic(00001534-1212-efde-1523-785feabcd123)
    I	23:45:24.011	[DFU] Read Response received from 00001534-1212-efde-1523-785feabcd123, value (0x): 01-00
    A	23:45:24.011	[DFU] Version number read: 0.1
    W	23:45:24.013	[DFU] Application with buttonless update found
    V	23:45:24.013	[DFU] Jumping to the DFU Bootloader...
    V	23:45:24.013	[DFU] Enabling notifications for 00001531-1212-efde-1523-785feabcd123
    D	23:45:24.013	[DFU] gatt.setCharacteristicNotification(00001531-1212-efde-1523-785feabcd123, true)
    D	23:45:24.016	[DFU] gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x01-00)
    I	23:45:24.109	[DFU] Data written to descr.00001531-1212-efde-1523-785feabcd123, value (0x): 01-00
    V	23:45:24.109	[DFU] Notifications enabled for 00001531-1212-efde-1523-785feabcd123
    A	23:45:24.109	[DFU] Notifications enabled
    D	23:45:24.109	[DFU] wait(1000)
    V	23:45:25.127	[DFU] Writing to characteristic 00001531-1212-efde-1523-785feabcd123
    D	23:45:25.127	[DFU] gatt.writeCharacteristic(00001531-1212-efde-1523-785feabcd123)
    A	23:45:25.180	[DFU] Jump to bootloader sent (Op Code = 1, Upload Mode = 4)
    I	23:45:25.290	[DFU] Disconnected by the remote device

  • chladm said:
    DFU always fails with this error: [DFU] Disconnected by the remote device

    This indicates that the device is not entering bootloader DFU mode as it's supposed to. I suggest you try to debug the application while sending the DFU start command and see if the program reaches bootloader_start() in dfu_app_handler.c

  • It reaches bootloader_start() function.

    It reaches the end of this function but I realized err_code = sd_ble_gatts_sys_attr_get(...);  does not return NRF_SUCCESS. I do not know if it is a problem.

  • Thanks for confirming. Have you enabled the service changed characteristic in your application like in the ble_app_hrs_with_dfu example (this line: ble_enable_params.gatts_enable_params.service_changed = IS_SRVC_CHANGED_CHARACT_PRESENT;)?

    You may also consider commenting out the call to "dfu_app_peer_data_set" in bootloader_start(). This will make the bootloader advertise openly (no whitelisting or directed advertising)

Related