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

The problem of Uploading Zip file with DFU

Hi there.

board : MBN52832

SDK : 15.3.0

Softdevice : S132, Ver 6.1.1

example file : ....\examples\dfu\bootloader_secure_ble

(refer) Nordic Documents : https://infocenter.nordicsemi.com/index.jsp , Nordic Blog : //devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/getting-started-with-nordics-secure-dfu-bootloader)

my command are : 

1.Generate Keys : nrfutil keys generate ...\Desktop\pip\private_key.pem

2.Generate Public Keys : nrfutil keys display --key pk --format code ...\Desktop\pip\private_key.pem --out_file private_key.c

3.Build bootloader : 

GNU Make ver 3.81 - Make the eUCC Library. there are two file(...\SDK 15.3.0\external\micro-ecc), nrf52hf_keil and nrf52nf_keil,  i used nrf52hf_keil.

and delete example key and replace private_key.c and build.

4. Generate DFU zip packet : nrfutil pkg generate --hw-version 52 --application-version 0 --application ...\Desktop\pip\nrf52832_xxaa.hex --sd-req 0xB7 --key-file ...\Desktop\pip\private_key.pem App_DFU_Test.zip (nrf52832_xxaa.hex is the uart example)

5.Test DFU : Flash bootloader and softdevice using nRF connect, and copy the zip file in my phone. and upload zipfile.

but uploading is file.

what should i do?

this is the log file.

nRF Connect, 2019-11-26
DfuTarg (EF:DD:61:C2:A6:C7)
V	21:30:02.807	Connecting to EF:DD:61:C2:A6:C7...
D	21:30:02.807	gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, preferred PHY = LE 1M)
D	21:30:02.878	[Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED
D	21:30:02.889	[Callback] Connection state changed with status: 0 and new state: CONNECTED (2)
I	21:30:02.889	Connected to EF:DD:61:C2:A6:C7
V	21:30:02.903	Discovering services...
D	21:30:02.903	gatt.discoverServices()
I	21:30:03.670	Connection parameters updated (interval: 15.0ms, latency: 0, timeout: 6000ms)
I	21:30:03.802	Connection parameters updated (interval: 7.5ms, latency: 0, timeout: 5000ms)
D	21:30:03.819	[Callback] Services discovered with status: 0
I	21:30:03.819	Services discovered
V	21:30:03.825	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)
I	21:30:03.872	Connection parameters updated (interval: 15.0ms, latency: 0, timeout: 6000ms)
V	21:30:11.989	[DFU] DFU service started
V	21:30:11.989	[DFU] Opening file...
I	21:30:12.778	[DFU] Firmware file opened successfully
V	21:30:12.778	[DFU] Connecting to DFU target...
D	21:30:12.779	[DFU] gatt = device.connectGatt(autoConnect = false)
I	21:30:12.786	[DFU] Connected to EF:DD:61:C2:A6:C7
V	21:30:12.786	[DFU] Discovering services...
D	21:30:12.786	[DFU] gatt.discoverServices()
I	21:30:12.792	[DFU] Services discovered
D	21:30:12.817	[DFU] wait(1000)
V	21:30:13.798	[DFU] Requesting new MTU...
D	21:30:13.798	[DFU] gatt.requestMtu(517)
I	21:30:13.832	[DFU] MTU changed to: 247
V	21:30:13.834	[DFU] Enabling notifications for 8ec90001-f315-4f60-9fb8-838830daea50
D	21:30:13.834	[DFU] gatt.setCharacteristicNotification(8ec90001-f315-4f60-9fb8-838830daea50, true)
D	21:30:13.835	[DFU] gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x01-00)
I	21:30:13.891	[DFU] Data written to descr.8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 01-00
V	21:30:13.891	[DFU] Notifications enabled for 8ec90001-f315-4f60-9fb8-838830daea50
A	21:30:13.891	[DFU] Notifications enabled
D	21:30:13.891	[DFU] wait(1000)
V	21:30:14.892	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50
D	21:30:14.892	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50)
I	21:30:14.925	[DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 06-01
I	21:30:14.927	[DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-06-01-00-02-00-00-00-00-00-00-00-00-00-00
A	21:30:14.928	[DFU] Command object info received (Max size = 512, Offset = 0, CRC = 00000000)
V	21:30:14.928	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50
D	21:30:14.928	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50)
I	21:30:14.956	[DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 02-00-00
I	21:30:14.957	[DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-02-01
A	21:30:14.957	[DFU] Packet Receipt Notif disabled (Op Code = 2, Value = 0)
V	21:30:14.957	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50
D	21:30:14.957	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50)
I	21:30:14.988	[DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 01-01-8D-00-00-00
I	21:30:14.990	[DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-01-01
A	21:30:14.990	[DFU] Command object created
V	21:30:14.990	[DFU] Writing to characteristic 8ec90002-f315-4f60-9fb8-838830daea50
D	21:30:14.990	[DFU] gatt.writeCharacteristic(8ec90002-f315-4f60-9fb8-838830daea50)
I	21:30:14.993	[DFU] Data written to 8ec90002-f315-4f60-9fb8-838830daea50, value (0x): 12-8A-01-0A-44-08-01-12-40-08-02-10-34-1A-02-B7-01-20-00-28-00-30-00-38-A0-D5-01-42-24-08-03-12-20-38-E1-A1-38-56-49-37-E6-10-91-18-48-BC-0F-91-92-27-D3-79-A2-42-97-85-58-F6-09-46-03-CF-D2-93-2A-48-00-52-04-08-01-12-00-10-00-1A-40-2E-6A-2E-0D-3B-09-EE-CD-A0-B2-20-90-DB-C6-2B-CA-01-B8-D0-A5-1F-27-52-45-27-61-2F-0D-CA-B4-1A-1C-3E-05-74-C2-41-4A-E5-77-DF-1F-B6-02-D7-4D-E5-63-0C-9E-B6-1E-22-F0-F1-1E-ED-56-7B-15-1B-8C-84-B9
A	21:30:14.994	[DFU] Command object sent (CRC = 336BAE4D)
V	21:30:14.994	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50
D	21:30:14.994	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50)
I	21:30:15.015	[DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 03
I	21:30:15.016	[DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-03-01-8D-00-00-00-4D-AE-6B-33
A	21:30:15.016	[DFU] Checksum received (Offset = 141, CRC = 336BAE4D)
V	21:30:15.017	[DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50
D	21:30:15.017	[DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50)
I	21:30:15.048	[DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 04
I	21:30:15.166	[DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-04-05
E	21:30:15.167	[DFU] Remote DFU error: INVALID OBJECT
V	21:30:15.167	[DFU] Disconnecting...
D	21:30:15.183	[DFU] gatt.disconnect()
I	21:30:15.192	[DFU] Disconnected
D	21:30:15.193	[DFU] gatt.refresh() (hidden)
D	21:30:15.194	[DFU] gatt.close()
D	21:30:15.202	[DFU] wait(600)
I	21:30:15.305	Connection parameters updated (interval: 7.5ms, latency: 0, timeout: 5000ms)
I	21:30:15.492	Connection parameters updated (interval: 15.0ms, latency: 0, timeout: 6000ms)

Parents
  • Hi, 

    Could you try follow my step by step guide here and check if you have the same issue ? 
    Could you try setting application version to 1 instead of 0 ? 

  • yes, I tried more than 20 times, with different solution base on official guide and others.

    I can't figure out what is the problem eventually.

    my test bed is

    1. IAR 8.30.1

    2. nRF5_SDK_15.3.0

    3. Chip: NRF52832

    4.version of make is 3.81

    5. version of urfutil is 6.0.0a1

    7. version of mergehex is 8.5.0

    8. and version of arm-none-eabi-gcc is 9.2.1

    I compiled bootloader project in foler "examples\dfu\secure_bootloader\pca10040_ble" and the debug version.

    and the app is come from "examples\ble_peripheral\ble_app_buttonless_dfu\pca10040".

    at the previous several times, I didn't change anything of these project to verify the dfu and OTA.

    all my test are failed at the end.

    but, only the example target file in folder “examples\dfu\secure_dfu_test_images\ble\nrf52832”  can be OTA 。


    I don't whether it is the issue related with "micro-ecc" .  but there is no any error reported during my test.

    And I found the example bootloader proect called the ecc lib of the folder "external\micro-ecc\nrf52hf_iar\armgcc\micro_ecc_lib_nrf52.a".  Help document from sdk said it is currect if I enable hardware FPU.

    And i also solved the issue "-short-char' related with "wchar_t" is 16bit or 32bit.


    besides, i tried with different application version and  --bl-settings-version, no one can give me a success result.

    i also checked the help of nrfutil,  --bl-settings-version should be 2 for SDK15.3.0,  and --sd-req should 0xB7. So I think my script might be no problem.

    I also tried the buttonless example with different version and other app example such as uart or hrs.but  no one can be successfully ota.

    here is my script related this process. I really don't know where I was wrong.

    ::step1 generateo private key-file
    nrfutil keys generate private.pem
    nrfutil keys display --key pk --format code private.pem

    ::step2
    nrfutil settings generate --family NRF52 --application app_ota.hex --application-version-string 0.0.0 --bootloader-version 0 --bl-settings-version 2 settings.hex 

    ::step3
    mergehex.exe --merge s132_nrf52_6.1.1_softdevice.hex bootloader.hex   --output ota_sd_boot.hex
    mergehex.exe --merge app_ota.hex ota_sd_boot.hex settings.hex         --output ota_all.hex
    
    del /f ota_sd_boot.hex 

    ::step4
    nrfjprog.exe --family NRF52 --eraseall
    nrfjprog.exe --family NRF52 --program ota_all.hex --verify
    nrfjprog.exe --family NRF52 --reset 
    

    ::step5
    nrfutil pkg generate --hw-version 52 --sd-req 0xB7 --application-version 1 --application app_ota.hex --key-file private.pem app_ota.zip
    

    here is error message form IOS and android during OTA.

    IOS error report

    android error report.

  • Hi CUI, 

    We need to debug the bootloader to check what went wrong here. 
    Please try testing with the bootloader _debug version where you can have the RTT log. 

    Make sure the log level is set to DEBUG in sdk_config.h 

    There are several reasons the DFU return INVALID_OBJECT. One of them is the signature is not correct , see nrf_dfu_validation_signature_check() in nrf_dfu_validation.c .
    Another option could be that the init packet was corrupted. 

    There are about 5-6 places where NRF_DFU_RES_CODE_INVALID_OBJECT returned. If the logging doesn't help, you can add breakpoints at those place to check what returned. 

    Since you mentioned that  "only the example target file in folder “examples\dfu\secure_dfu_test_images\ble\nrf52832”  can be OTA " , most likely you haven't updated the bootloader with your own PUBLIC key. 
    In this line, you should generate an output public key file: nrfutil keys display --key pk --format code private.pem 

    For example: 

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

    Then you include the public_key.c in your bootloader, replacing the dfu_public_key.c default in the bootloader. 

  • There is something wrong with how  nrfutil generates the `dfu_public_key.c` in newer versions of nrfutil. We used lot of time getting the examples run with our own keys, and eventually stumbled upon this thread which solved our issue: https://devzone.nordicsemi.com/f/nordic-q-a/52946/nrfutil-and-dfu---invalid-object . Using the older v3.5.1 of nrfutil generates `dfu_public_key.c` with the bytes in correct order for bootloader to work.

    I don't know how it suppose to work, but something inconsistent.

Reply Children
No Data
Related