NordicSemiconductor / Android-DFU-Library

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

Error (0x85) (133): GATT ERROR on Android 13 #398

Closed VNGames closed 1 year ago

VNGames commented 1 year ago

Reproduces every time

DFU Bootloader version):

Device information (please complete the following information):

Logs (read from bottom to top)

2023/08/14 21:14:21:882  DFU Lib Log: [DFU] [Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED
2023/08/14 21:14:21:881  DFU Lib Log: [DFU] gatt.disconnect()
2023/08/14 21:14:21:865  Process State Changed: Device Disconnecting
2023/08/14 21:14:21:864  DFU Lib Log: [DFU] Disconnecting...
2023/08/14 21:14:21:863  DFU Lib Log: [DFU] Error (0x85): GATT ERROR
2023/08/14 21:14:15:865  DFU Lib Log: [DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50)
2023/08/14 21:14:15:865  DFU Lib Log: [DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50
2023/08/14 21:14:15:865  DFU Lib Log: [DFU] Command object sent (CRC = D07D4A81)
2023/08/14 21:14:15:864  DFU Lib Log: [DFU] Data written to 8ec90002-f315-4f60-9fb8-838830daea50, value (0x): 12-8A-01-0A-44-08-01-12-40-08-01-10-34-1A-02-80-02-20-00-28-00-30-00-38-A0-F3-0B-42-24-08-03-12-20-72-E4-76-44-39-63-C2-AD-64-D3-68-86-42-5E-A7-23-D2-78-B1-F1-5C-84-85-A0-48-71-4B-BC-A3-A6-49-54-48-00-52-04-08-01-12-00-10-00-1A-40-60-82-38-B4-70-71-7A-56-52-89-B8-DC-C2-50-ED-4F-60-AC-8D-82-5A-DC-82-10-13-62-B0-88-60-B9-D3-08-22-22-D6-A6-C8-62-80-62-9F-A5-D7-41-0B-8D-73-95-AE-C8-A1-21-D1-28-E0-A4-83-CB-DA-A2-05-A9-7A-79
2023/08/14 21:14:15:861  DFU Lib Log: [DFU] gatt.writeCharacteristic(8ec90002-f315-4f60-9fb8-838830daea50)
2023/08/14 21:14:15:861  DFU Lib Log: [DFU] Writing to characteristic 8ec90002-f315-4f60-9fb8-838830daea50
2023/08/14 21:14:15:860  DFU Lib Log: [DFU] Command object created
2023/08/14 21:14:15:860  DFU Lib Log: [DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-01-01
2023/08/14 21:14:15:860  DFU Lib Log: [DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 01-01-8D-00-00-00
2023/08/14 21:14:15:830  DFU Lib Log: [DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50)
2023/08/14 21:14:15:830  DFU Lib Log: [DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50
2023/08/14 21:14:15:830  DFU Lib Log: [DFU] Packet Receipt Notif disabled (Op Code = 2, Value = 0)
2023/08/14 21:14:15:830  DFU Lib Log: [DFU] Notification received from 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-02-01
2023/08/14 21:14:15:829  DFU Lib Log: [DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 02-00-00
2023/08/14 21:14:15:799  DFU Lib Log: [DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50)
2023/08/14 21:14:15:799  DFU Lib Log: [DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50
2023/08/14 21:14:15:799  DFU Lib Log: [DFU] Command object info received (Max size = 512, Offset = 0, CRC = 00000000)
2023/08/14 21:14:15:798  DFU Lib Log: [DFU] Data written to 8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 60-06-01-00-02-00-00-00-00-00-00-00-00-00-00
2023/08/14 21:14:15:798  DFU Lib Log: [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
2023/08/14 21:14:15:765  DFU Lib Log: [DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50)
2023/08/14 21:14:15:764  DFU Lib Log: [DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50
2023/08/14 21:14:14:766  DFU Lib Log: [DFU] wait(1000)
2023/08/14 21:14:14:764  DFU Lib Log: [DFU] Notifications enabled
2023/08/14 21:14:14:764  DFU Lib Log: [DFU] Notifications enabled for 8ec90001-f315-4f60-9fb8-838830daea50
2023/08/14 21:14:14:764  DFU Lib Log: [DFU] Data written to descr.8ec90001-f315-4f60-9fb8-838830daea50, value (0x): 01-00
2023/08/14 21:14:14:737  DFU Lib Log: [DFU] gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x01-00)
2023/08/14 21:14:14:735  DFU Lib Log: [DFU] gatt.setCharacteristicNotification(8ec90001-f315-4f60-9fb8-838830daea50, true)
2023/08/14 21:14:14:735  DFU Lib Log: [DFU] Enabling notifications for 8ec90001-f315-4f60-9fb8-838830daea50
2023/08/14 21:14:14:735  DFU Lib Log: [DFU] MTU changed to: 247
2023/08/14 21:14:14:711  DFU Lib Log: [DFU] gatt.requestMtu(517)
2023/08/14 21:14:14:711  DFU Lib Log: [DFU] Requesting new MTU...
2023/08/14 21:14:13:710  DFU Lib Log: [DFU] wait(1000)
2023/08/14 21:14:13:705  Process State Changed: DFU Process Starting
2023/08/14 21:14:13:705  Process State Changed: Device Connected
2023/08/14 21:14:13:704  DFU Lib Log: [DFU] Services discovered
2023/08/14 21:14:12:721  DFU Lib Log: [DFU] gatt.discoverServices()
2023/08/14 21:14:12:720  DFU Lib Log: [DFU] Discovering services...
2023/08/14 21:14:12:717  DFU Lib Log: [DFU] Connected to ED:3D:EB:0C:23:98
2023/08/14 21:14:12:715  DFU Lib Log: [DFU] [Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED
2023/08/14 21:14:12:380  DFU Lib Log: [DFU] gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, preferredPhy = LE_1M | LE_2M)
2023/08/14 21:14:12:360  Process State Changed: Device Connecting
2023/08/14 21:14:12:358  DFU Lib Log: [DFU] Connecting to DFU target...
2023/08/14 21:14:11:357  DFU Lib Log: [DFU] wait(1000)
2023/08/14 21:14:10:357  DFU Lib Log: [DFU] wait(1000)
2023/08/14 21:14:10:357  DFU Lib Log: [DFU] Firmware file opened successfully
2023/08/14 21:14:10:357  DFU Lib Log: [DFU] DFU service started
2023/08/14 21:14:10:347  DFU Lib Log: [DFU] DFU Bootloader found with address ED:3D:EB:0C:23:98
2023/08/14 21:14:10:152  DFU Lib Log: [DFU] Scanning for the DFU Bootloader...
2023/08/14 21:14:10:146  DFU Lib Log: [DFU] gatt.close()
2023/08/14 21:14:10:144  DFU Lib Log: [DFU] [Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED
2023/08/14 21:14:10:140  DFU Lib Log: [DFU] gatt.disconnect()
2023/08/14 21:14:10:135  DFU Lib Log: [DFU] gatt.refresh() (hidden)
2023/08/14 21:14:10:134  DFU Lib Log: [DFU] Disconnected by the remote device
2023/08/14 21:14:04:956  DFU Lib Log: [DFU] Response received (Op Code = 1, Status = 1)
2023/08/14 21:14:04:956  DFU Lib Log: [DFU] Notification received from 8ec90003-f315-4f60-9fb8-838830daea50, value (0x): 20-01-01
2023/08/14 21:14:04:956  DFU Lib Log: [DFU] Enter bootloader sent (Op Code = 1)
2023/08/14 21:14:04:847  DFU Lib Log: [DFU] gatt.writeCharacteristic(8ec90003-f315-4f60-9fb8-838830daea50)
2023/08/14 21:14:04:847  DFU Lib Log: [DFU] Writing to characteristic 8ec90003-f315-4f60-9fb8-838830daea50
2023/08/14 21:14:04:830  Process State Changed: Enabling DFU Mode
2023/08/14 21:14:03:829  DFU Lib Log: [DFU] wait(1000)
2023/08/14 21:14:03:829  DFU Lib Log: [DFU] Indications enabled
2023/08/14 21:14:03:829  DFU Lib Log: [DFU] Notifications enabled for 8ec90003-f315-4f60-9fb8-838830daea50
2023/08/14 21:14:03:828  DFU Lib Log: [DFU] Data written to descr.8ec90003-f315-4f60-9fb8-838830daea50, value (0x): 02-00
2023/08/14 21:14:03:764  DFU Lib Log: [DFU] gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x02-00)
2023/08/14 21:14:03:762  DFU Lib Log: [DFU] gatt.setCharacteristicNotification(8ec90003-f315-4f60-9fb8-838830daea50, true)
2023/08/14 21:14:03:762  DFU Lib Log: [DFU] Enabling indications for 8ec90003-f315-4f60-9fb8-838830daea50
2023/08/14 21:14:03:762  DFU Lib Log: [DFU] Jumping to the DFU Bootloader...
2023/08/14 21:14:03:762  DFU Lib Log: [DFU] Application with buttonless update found
2023/08/14 21:14:02:761  DFU Lib Log: [DFU] wait(1000)
2023/08/14 21:14:02:739  Process State Changed: DFU Process Starting
2023/08/14 21:14:02:738  Process State Changed: Device Connected
2023/08/14 21:14:02:737  DFU Lib Log: [DFU] Services discovered
2023/08/14 21:14:00:156  DFU Lib Log: [DFU] [Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED
2023/08/14 21:14:00:150  DFU Lib Log: [DFU] gatt.discoverServices()
2023/08/14 21:14:00:149  DFU Lib Log: [DFU] Discovering services...
2023/08/14 21:14:00:148  DFU Lib Log: [DFU] Connected to ED:3D:EB:0C:23:97
2023/08/14 21:13:57:163  DFU Lib Log: [DFU] gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, preferredPhy = LE_1M | LE_2M)
2023/08/14 21:13:57:162  DFU Lib Log: [DFU] Connecting to DFU target...
2023/08/14 21:13:57:162  DFU Lib Log: [DFU] Firmware file opened successfully
2023/08/14 21:13:57:094  DFU Lib Log: [DFU] Opening file...
2023/08/14 21:13:57:094  DFU Lib Log: [DFU] DFU service started
jeffaman commented 1 year ago

We see this too - DFU trouble, won't start the uploading process, under Android 13, when performing DFU on a nRF5 SDK 17.2. Works on ios (with Nordic's ios app), and android 9 (again with Nordic's ios app), but not when tried under android 13.

philips77 commented 1 year ago

Have a look at this fragment:

2023/08/14 21:14:15:865  DFU Lib Log: [DFU] Command object sent (CRC = D07D4A81)
2023/08/14 21:14:15:865  DFU Lib Log: [DFU] Writing to characteristic 8ec90001-f315-4f60-9fb8-838830daea50
2023/08/14 21:14:15:865  DFU Lib Log: [DFU] gatt.writeCharacteristic(8ec90001-f315-4f60-9fb8-838830daea50
2023/08/14 21:14:21:863  DFU Lib Log: [DFU] Error (0x85): GATT ERROR

The library has sent the Init packet and is trying to execute it. The device should reply with a notification with status success. Instead, for looks like sending the Execute command ends with an error after 6 seconds. This is abnormal behavior from the device side. Perhaps it has hung or reset?

Possible solutions would be to add a small delay before sending the Execute command, but this only depends on the root cause of the lack of response. If the device dies, nothing would help. But if it needed some time to process the data, there's a chance.

Could you try that and report if it helped?

philips77 commented 1 year ago

This may be the same issue as #339. Try disabling MTU using the solution provided here.