NordicSemiconductor / Android-DFU-Library

Device Firmware Update library and Android app
http://www.nordicsemi.com/dfu
BSD 3-Clause "New" or "Revised" License
753 stars 263 forks source link

Dfu Failing #437

Closed archie94 closed 2 months ago

archie94 commented 4 months ago

Version

2.4.1 (Latest)

Ask the question

Do you know why this device is not able to update the firmware version?

Logs attached.

Relevant log output

1709629380, DfuActivity, v, address = FC:AD:B5:0E:45:DB; msg = [DFU] DFU service started
1709629380, DfuActivity, v, address = FC:AD:B5:0E:45:DB; msg = [DFU] Opening file...
1709629380, DfuActivity, i, address = FC:AD:B5:0E:45:DB; msg = [DFU] Firmware file opened successfully
1709629380, DfuActivity, v, address = FC:AD:B5:0E:45:DB; msg = [DFU] Connecting to DFU target...
1709629380, DfuActivity, d, address = FC:AD:B5:0E:45:DB; msg = [DFU] gatt = device.connectGatt(autoConnect = false; TRANSPORT_LE; preferredPhy = LE_1M | LE_2M)
1709629380, DfuActivity, i, address = FC:AD:B5:0E:45:DB; msg = [DFU] Connected to FC:AD:B5:0E:45:DB
1709629380, DfuActivity, d, address = FC:AD:B5:0E:45:DB; msg = [DFU] wait(1600)
1709629382, DfuActivity, v, address = FC:AD:B5:0E:45:DB; msg = [DFU] Discovering services...
1709629382, DfuActivity, d, address = FC:AD:B5:0E:45:DB; msg = [DFU] gatt.discoverServices()
1709629382, DfuActivity, i, address = FC:AD:B5:0E:45:DB; msg = [DFU] Services discovered
1709629382, DfuActivity, v, address = FC:AD:B5:0E:45:DB; msg = [DFU] Reading Service Changed CCCD value...
1709629382, DfuActivity, d, address = FC:AD:B5:0E:45:DB; msg = [DFU] gatt.readDescriptor(00002902-0000-1000-8000-00805f9b34fb)
1709629382, DfuActivity, i, address = FC:AD:B5:0E:45:DB; msg = [DFU] Read Response received from descr.00002a05-0000-1000-8000-00805f9b34fb; value (0x): 02-00
1709629382, DfuActivity, d, address = FC:AD:B5:0E:45:DB; msg = [DFU] Service Changed indications enabled
1709629382, DfuActivity, w, address = FC:AD:B5:0E:45:DB; msg = [DFU] Application with buttonless update found
1709629382, DfuActivity, v, address = FC:AD:B5:0E:45:DB; msg = [DFU] Jumping to the DFU Bootloader...
1709629382, DfuActivity, v, address = FC:AD:B5:0E:45:DB; msg = [DFU] Enabling indications for 8ec90003-f315-4f60-9fb8-838830daea50
1709629382, DfuActivity, d, address = FC:AD:B5:0E:45:DB; msg = [DFU] gatt.setCharacteristicNotification(8ec90003-f315-4f60-9fb8-838830daea50; true)
1709629382, DfuActivity, d, address = FC:AD:B5:0E:45:DB; msg = [DFU] gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb; value=0x02-00)
1709629382, DfuActivity, i, address = FC:AD:B5:0E:45:DB; msg = [DFU] Data written to descr.8ec90003-f315-4f60-9fb8-838830daea50
1709629382, DfuActivity, v, address = FC:AD:B5:0E:45:DB; msg = [DFU] Notifications enabled for 8ec90003-f315-4f60-9fb8-838830daea50
1709629382, DfuActivity, d, address = FC:AD:B5:0E:45:DB; msg = [DFU] Indications enabled
1709629382, DfuActivity, v, address = FC:AD:B5:0E:45:DB; msg = [DFU] Writing to characteristic 8ec90003-f315-4f60-9fb8-838830daea50; value (0x): 01
1709629382, DfuActivity, d, address = FC:AD:B5:0E:45:DB; msg = [DFU] gatt.writeCharacteristic(8ec90003-f315-4f60-9fb8-838830daea50)
1709629382, DfuActivity, d, address = FC:AD:B5:0E:45:DB; msg = [DFU] Enter bootloader sent (Op Code = 1)
1709629382, DfuActivity, i, address = FC:AD:B5:0E:45:DB; msg = [DFU] Notification received from 8ec90003-f315-4f60-9fb8-838830daea50; value (0x): 20-01-01
1709629382, DfuActivity, d, address = FC:AD:B5:0E:45:DB; msg = [DFU] Response received (Op Code = 1; Status = 1)
1709629382, DfuActivity, v, address = FC:AD:B5:0E:45:DB; msg = [DFU] Disconnecting...
1709629382, DfuActivity, d, address = FC:AD:B5:0E:45:DB; msg = [DFU] gatt.disconnect()
1709629382, DfuActivity, i, address = FC:AD:B5:0E:45:DB; msg = [DFU] Disconnected
1709629382, DfuActivity, d, address = FC:AD:B5:0E:45:DB; msg = [DFU] gatt.disconnect()
1709629382, DfuActivity, d, address = FC:AD:B5:0E:45:DB; msg = [DFU] gatt.close()
1709629382, DfuActivity, v, address = FC:AD:B5:0E:45:DB; msg = [DFU] Scanning for the DFU Bootloader... (timeout 5000 ms)
1709629385, DfuActivity, i, address = FC:AD:B5:0E:45:DB; msg = [DFU] DFU Bootloader found with address FC:AD:B5:0E:45:DC
1709629385, DfuActivity, v, address = FC:AD:B5:0E:45:DC; msg = [DFU] DFU service started
1709629385, DfuActivity, i, address = FC:AD:B5:0E:45:DC; msg = [DFU] Firmware file opened successfully
1709629385, DfuActivity, v, address = FC:AD:B5:0E:45:DC; msg = [DFU] Connecting to DFU target...
1709629385, DfuActivity, d, address = FC:AD:B5:0E:45:DC; msg = [DFU] gatt = device.connectGatt(autoConnect = false; TRANSPORT_LE; preferredPhy = LE_1M | LE_2M)
1709629386, DfuActivity, i, address = FC:AD:B5:0E:45:DC; msg = [DFU] Connected to FC:AD:B5:0E:45:DC
1709629386, DfuActivity, d, address = FC:AD:B5:0E:45:DC; msg = [DFU] [Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED
1709629386, DfuActivity, v, address = FC:AD:B5:0E:45:DC; msg = [DFU] Discovering services...
1709629386, DfuActivity, d, address = FC:AD:B5:0E:45:DC; msg = [DFU] gatt.discoverServices()
1709629386, DfuActivity, i, address = FC:AD:B5:0E:45:DC; msg = [DFU] Services discovered
1709629386, DfuActivity, v, address = FC:AD:B5:0E:45:DC; msg = [DFU] Requesting new MTU...
1709629386, DfuActivity, d, address = FC:AD:B5:0E:45:DC; msg = [DFU] gatt.requestMtu(517)
1709629386, DfuActivity, i, address = FC:AD:B5:0E:45:DC; msg = [DFU] MTU changed to: 247
1709629386, DfuActivity, v, address = FC:AD:B5:0E:45:DC; msg = [DFU] Enabling notifications for 8ec90001-f315-4f60-9fb8-838830daea50
1709629386, DfuActivity, d, address = FC:AD:B5:0E:45:DC; msg = [DFU] gatt.setCharacteristicNotification(8ec90001-f315-4f60-9fb8-838830daea50; true)
1709629386, DfuActivity, d, address = FC:AD:B5:0E:45:DC; msg = [DFU] gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb; value=0x01-00)
1709629387, DfuActivity, i, address = FC:AD:B5:0E:45:DC; msg = [DFU] Data written to descr.8ec90001-f315-4f60-9fb8-838830daea50
1709629387, DfuActivity, v, address = FC:AD:B5:0E:45:DC; msg = [DFU] Notifications enabled for 8ec90001-f315-4f60-9fb8-838830daea50
1709629387, DfuActivity, d, address = FC:AD:B5:0E:45:DC; msg = [DFU] Notifications enabled
1709629387, DfuActivity, v, address = FC:AD:B5:0E:45:DC; msg = [DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50; value (0x): 06-01
1709629387, DfuActivity, d, address = FC:AD:B5:0E:45:DC; msg = [DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50)
1709629387, DfuActivity, i, address = FC:AD:B5:0E:45:DC; msg = [DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50
1709629387, DfuActivity, i, address = FC:AD:B5:0E:45:DC; msg = [DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50; value (0x): 60-06-01-00-02-00-00-8F-00-00-00-B8-AF-1C-23
1709629387, DfuActivity, d, address = FC:AD:B5:0E:45:DC; msg = [DFU] Command object info received (Max size = 512; Offset = 143; CRC = 231CAFB8)
1709629387, DfuActivity, d, address = FC:AD:B5:0E:45:DC; msg = [DFU] Received CRC match Init packet
1709629387, DfuActivity, v, address = FC:AD:B5:0E:45:DC; msg = [DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50; value (0x): 04
1709629387, DfuActivity, d, address = FC:AD:B5:0E:45:DC; msg = [DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50)
1709629387, DfuActivity, i, address = FC:AD:B5:0E:45:DC; msg = [DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50
1709629387, DfuActivity, i, address = FC:AD:B5:0E:45:DC; msg = [DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50; value (0x): 60-04-01
1709629387, DfuActivity, d, address = FC:AD:B5:0E:45:DC; msg = [DFU] Command object executed
1709629387, DfuActivity, v, address = FC:AD:B5:0E:45:DC; msg = [DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50; value (0x): 06-02
1709629387, DfuActivity, d, address = FC:AD:B5:0E:45:DC; msg = [DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50)
1709629387, DfuActivity, i, address = FC:AD:B5:0E:45:DC; msg = [DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50
1709629387, DfuActivity, i, address = FC:AD:B5:0E:45:DC; msg = [DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50; value (0x): 60-06-01-00-10-00-00-00-00-00-00-00-00-00-00
1709629387, DfuActivity, d, address = FC:AD:B5:0E:45:DC; msg = [DFU] Data object info received (Max size = 4096; Offset = 0; CRC = 00000000)
1709629387, DfuActivity, v, address = FC:AD:B5:0E:45:DC; msg = [DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50; value (0x): 01-02-00-10-00-00
1709629387, DfuActivity, d, address = FC:AD:B5:0E:45:DC; msg = [DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50)
1709629387, DfuActivity, i, address = FC:AD:B5:0E:45:DC; msg = [DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50
1709629387, DfuActivity, i, address = FC:AD:B5:0E:45:DC; msg = [DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50; value (0x): 60-01-01
1709629387, DfuActivity, d, address = FC:AD:B5:0E:45:DC; msg = [DFU] Data object (1/51) created
1709629387, DfuActivity, d, address = FC:AD:B5:0E:45:DC; msg = [DFU] wait(300)
1709629387, DfuActivity, d, address = FC:AD:B5:0E:45:DC; msg = [DFU] Uploading firmware...
1709629387, DfuActivity, v, address = FC:AD:B5:0E:45:DC; msg = [DFU] Sending firmware to characteristic 8ec90002-f315-4f60-9fb8-838830daea50...
1709629387, DfuActivity, v, address = FC:AD:B5:0E:45:DC; msg = [DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50; value (0x): 03
1709629387, DfuActivity, d, address = FC:AD:B5:0E:45:DC; msg = [DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50)
1709629389, BleManager, d, [Callback] Connection state changed with status: 8 and new state: 0 (DISCONNECTED)
1709629389, BleManager, d, Error: (0x8): GATT CONN TIMEOUT
philips77 commented 4 months ago

You may try the following:

  1. Disabling MTU request
  2. Enabling PRN=1

You may try both methods using the nRF DFU app on Google Play and going to Settings. There may be several reasons why a device would fail like that.

AliMoal commented 4 months ago

You may try the following:

  1. Disabling MTU request
  2. Enabling PRN=1

You may try both methods using the nRF DFU app on Google Play and going to Settings. There may be several reasons why a device would fail like that.

Could you explain more? Because I got stuck in the same situation.

philips77 commented 4 months ago

DLE negotiations failure

Some devices, for example Samsung Tab A8, have an issue with the DLE (Data Length Extension, maximum size of a packet that they can send in a single packet). During connection negotiation they claim to support only 27 bytes, while later they send more, which gets ignored by the peer. To workaround that it's possible to disable MTU request, which will default to 27 bytes.

If you're using nRF DFU app:

  1. Go to Settings.
  2. Check "disable MTU request".
  3. Try updating a device.

When you implement DFU in your app: https://github.com/NordicSemiconductor/Android-DFU-Library/blob/ee04574dcc438bf067505327eebb37018ee908b8/lib/dfu/src/main/java/no/nordicsemi/android/dfu/DfuServiceInitiator.java#L426-L435

[!Note] With MTU request disabled DFU will be significantly slower.

Packet Receipt Notifications

PRNs, or Packet Receipt Notifications are used to synchronize transmitter with the receiver. Every N packets the transmitter would pause upload and wait for a notification from the receiver with a current offset and CRC. PRNs make sure the transmitter doesn't send data faster than they can be stored on the device.

  1. Go to Settings
  2. Enable "Packet receipt notification" and set the "Number of packets" to 1 or some other small number.
  3. Try updating your device.

When you implement DFU in the app: https://github.com/NordicSemiconductor/Android-DFU-Library/blob/ee04574dcc438bf067505327eebb37018ee908b8/lib/dfu/src/main/java/no/nordicsemi/android/dfu/DfuServiceInitiator.java#L221-L252

[!Note] Just like with MTU, the lower PRNs, the more time sending them takes, so the DFU process gets slower.

archie94 commented 4 months ago

Thank you so much for these detailed explanation. I am going to try these out and let you know.

AliMoal commented 4 months ago

Thank you so much for these detailed explanation. I am going to try these out and let you know.

Thank you but form my side I should say It was a bug in the library I used. I could not test it without PRNs because I don't have enough memory to buffer the input data, so I should've tested it with PRN = 1. When I received a packet, I did not send CRC response notification. It was my problem. Thanks again for your attention.