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

DFU example problem : [DFU] Error (0x85): GATT ERROR

Hello,

First of all, here is my setup :

- SoC : nRF52832

- Board : BLE nano v2

- SDK : 12.3.0 version

- SD_Version : s132_nRF52_3.0.0

- Compiler : GCC

- Smartphone : GT-I9195

My problem is the following one :

I'm stuck since two weeks on a problem with the secure bootloader example I found in the SDK. I think i have all done correctly but i still can't send package to my "DfuTarg" device. When I try to send a zip file, I see "Initializing...", then "Strating DFU...", but the progress bar stay at 0% and finally I see "Disconnecting...". I don't find any solution at the step to my problem. For information, I followed this tutorial step by step : https://devzone.nordicsemi.com/b/blog/posts/getting-started-with-nordics-secure-dfu-bootloader

Here is below the commands i use before using my smarthpone and the logs I see on my smartphone when I'm proceeding the update of the firmware.

Commands :

nrfutil keys generate private_key.key

nrfutil keys display --key pk --format code private_key.key --out_file public_key.c

nrfjprog --program $(SDK_ROOT)/components/softdevice/s132/hex/s132_nrf52_3.0.0_softdevice.hex -f nrf52 --sectorerase

nrfjprog --program $(BOOT_DIRECTORY)/nrf52832_xxaa.hex -f nrf52 --sectorerase

nrfutil pkg generate --hw-version 52 --application-version 1 --application $(OUTPUT_DIRECTORY)/nrf52832_xxaa.hex --sd-req 0x8C --key-file $(KEY_DIRECTORY)/private_key.key app_v1_dfu_package.zip

Logs :

nRF Connect, 2019-02-21
DfuTarg (CA:33:98:66:97:AB)
I	11:57:20.589	[Server] Server started
V	11:57:20.622	Secure DFU Service (0xFE59)
V	11:57:21.037	Connecting to CA:33:98:66:97:AB...
D	11:57:21.037	gatt = device.connectGatt(autoConnect = false)
D	11:57:21.105	[Server callback] Connection state changed with status: 0 and new state: CONNECTED (2)
I	11:57:21.106	[Server] Device with address CA:33:98:66:97:AB connected
D	11:57:21.115	[Callback] Connection state changed with status: 0 and new state: CONNECTED (2)
I	11:57:21.115	Connected to CA:33:98:66:97:AB
V	11:57:21.134	Discovering services...
D	11:57:21.134	gatt.discoverServices()
D	11:57:22.464	[Callback] Services discovered with status: 0
I	11:57:22.464	Services discovered
V	11:57:22.492	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)
- DFU Packet [WNR] (8ec90002-f315-4f60-9fb8-838830daea50)
- DFU Control Point [N W] (8ec90001-f315-4f60-9fb8-838830daea50)
 Client Characteristic Configuration (0x2902)
V	11:57:36.869	[DFU] DFU service started
V	11:57:36.870	[DFU] Opening file...
I	11:57:37.492	[DFU] Firmware file opened successfully
V	11:57:37.492	[DFU] Connecting to DFU target...
D	11:57:37.492	[DFU] gatt = device.connectGatt(autoConnect = false)
I	11:57:37.542	[DFU] Connected to CA:33:98:66:97:AB
V	11:57:37.542	[DFU] Discovering services...
D	11:57:37.543	[DFU] gatt.discoverServices()
I	11:57:37.558	[DFU] Services discovered
D	11:57:37.579	[DFU] wait(1000)
V	11:57:38.573	[DFU] Enabling notifications for 8ec90001-f315-4f60-9fb8-838830daea50
D	11:57:38.573	[DFU] gatt.setCharacteristicNotification(8ec90001-f315-4f60-9fb8-838830daea50, true)
D	11:57:38.573	[DFU] gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x01-00)
I	11:57:38.650	[DFU] Data written to descr.8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 01-00
V	11:57:38.650	[DFU] Notifications enabled for 8ec90001-f315-4f60-9fb8-838830daea50
A	11:57:38.650	[DFU] Notifications enabled
D	11:57:38.650	[DFU] wait(1000)
V	11:57:39.654	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50
D	11:57:39.654	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50)
D	11:58:09.714	[Server callback] Connection state changed with status: 0 and new state: DISCONNECTED (0)
I	11:58:09.714	[Server] Device disconnected
D	11:58:09.780	[Callback] Connection state changed with status: 0 and new state: DISCONNECTED (0)
I	11:58:09.780	Disconnected
D	11:58:09.782	gatt.refresh() (hidden)
E	11:58:09.783	[DFU] Error (0x85): GATT ERROR
V	11:58:09.783	[DFU] Disconnecting...
D	11:58:09.784	[DFU] gatt.disconnect()
I	11:58:09.856	[DFU] Disconnected
D	11:58:09.856	[DFU] gatt.refresh() (hidden)
D	11:58:09.856	[DFU] gatt.close()
D	11:58:09.856	[DFU] wait(600)
D	11:58:10.420	gatt.close()
D	11:58:10.421	wait(200)
V	11:58:10.624	Connecting to CA:33:98:66:97:AB...
D	11:58:10.624	gatt = device.connectGatt(autoConnect = false)
D	11:58:15.632	[Server callback] Connection state changed with status: 0 and new state: DISCONNECTED (0)
I	11:58:15.632	[Server] Device disconnected
D	11:58:15.711	[Callback] Connection state changed with status: 133 and new state: CONNECTED (2)
E	11:58:15.711	Error 133 (0x85): GATT ERROR
V	11:58:17.000	Cancelling connection...
D	11:58:17.000	gatt.disconnect()
I	11:58:17.002	Disconnected
D	11:58:17.002	gatt.close()
D	11:58:17.033	wait(200)

I'm open to any help because I got no more ideas. Futhermore, the bootloader works correctly without DFU. I mean I can go in bootloader or application when I want when I simulate the pression on a button by connecting pin0_4. The problem is just when I try to send a zip to update the firmware.

I hope my description will be sufficient. If not, tell me what you need to know and I will answer as fast as possible.

PS : If I flash both bootloader_settings and a version 1 of the application in addition to softdevice and bootloader, the updating isn't working and I see same logs on my smartphone, even if I link the good version of the app to the bootloader_settings.

Parents
  • I was able to make it work. I used nRF52832, SoftDevice s132 V3.0.0 and SDK 12.3.0

    This was my approach:

    • Added the uECC library
    • Created the private key and put the public key into nRF5_SDK_12.3.0_d7731ad\examples\dfu\bootloader_secure
    • Built the bootloader
    • Built the ble_app_uart project and copied the hex file located in nRF5_SDK_12.3.0_d7731ad\examples\ble_peripheral\ble_app_uart\pca10040\s132\arm5_no_packs\_build into my working folder
    • Copied the private.key into the same folder and generated the .zip file by running the following command:
      • nrfutil pkg generate --hw-version 52 --application-version 1 --application nrf52832_xxaa.hex --sd-req 0x8C --key-file private.key apdfu_package.zip
    • Flashed the bootloader and SoftDevice using nRF Connect (for the computer) and the Programmer app:
      • Add both of the files
      • Click "Erase & write"
    • Then I transferred the ZIP file to my phone and performed DFU by using nRF Connect (for the phone)
    • The DFU completed successfully, and I confirmed that the ble_app_uart project worked properly by seeing it advertising

    Try following the exact approach as me, and if it still doesn't work, I will look further into it.

    However, I would recommend you to use the newest SDK (15.2.0)

    Best regards,

    Simon

Reply
  • I was able to make it work. I used nRF52832, SoftDevice s132 V3.0.0 and SDK 12.3.0

    This was my approach:

    • Added the uECC library
    • Created the private key and put the public key into nRF5_SDK_12.3.0_d7731ad\examples\dfu\bootloader_secure
    • Built the bootloader
    • Built the ble_app_uart project and copied the hex file located in nRF5_SDK_12.3.0_d7731ad\examples\ble_peripheral\ble_app_uart\pca10040\s132\arm5_no_packs\_build into my working folder
    • Copied the private.key into the same folder and generated the .zip file by running the following command:
      • nrfutil pkg generate --hw-version 52 --application-version 1 --application nrf52832_xxaa.hex --sd-req 0x8C --key-file private.key apdfu_package.zip
    • Flashed the bootloader and SoftDevice using nRF Connect (for the computer) and the Programmer app:
      • Add both of the files
      • Click "Erase & write"
    • Then I transferred the ZIP file to my phone and performed DFU by using nRF Connect (for the phone)
    • The DFU completed successfully, and I confirmed that the ble_app_uart project worked properly by seeing it advertising

    Try following the exact approach as me, and if it still doesn't work, I will look further into it.

    However, I would recommend you to use the newest SDK (15.2.0)

    Best regards,

    Simon

Children
Related