adafruit / Adafruit_nRF52_Bootloader

USB-enabled bootloaders for the nRF52 BLE SoC chips
MIT License
463 stars 416 forks source link

DFU OTA upgrade problem #269

Open AndreasLamparter opened 2 years ago

AndreasLamparter commented 2 years ago

Operating System

Windows 10

INFO_UF2.TXT

UF2 Bootloader 0.6.4 lib/nrfx (v2.0.0) lib/tinyusb (0.12.0-145-g9775e7691) lib/uf2 (remotes/origin/configupdate-9-gadbb8c7) Model: Adafruit Feather nRF52840 Sense Board-ID: nRF52840-Feather-Sense Date: May 17 2022 SoftDevice: S140 6.1.1

What happened ?

I want to update the application on my adafruit feather sense over DFU OTA. I use the firmware.zip created by PlatformIO and ArduinoIDE. I try nRFConnect and the DFU Upgrade tool with 3 different android versions. On both tools the upgrade stuck after firmware.zip upload is complete.

I use the dfu_ota.ino sketch to test.

#include <Arduino.h>

void setup() 
{
  enterOTADfu();
}

void loop() 
{
}

The PlatformIO cmd to create the firmeware.zip

tool-adafruit-nrfutil\adafruit-nrfutil.py dfu genpkg --dev-type 0x0052 --sd-req 0x00B6 --application .\firmware.hex .\firmware.zip

I checked the --sd-req 0x00B6 parameter, it should match with the SoftDevice S140 6.1.1

How to reproduce ?

  1. Connect the nRF Connect app with the device.
  2. Start DFU with select the firmeware.zip
  3. The update stuck after uploading the firmeware.

Debug Log

nRF Connect, 2022-07-05 AdaDFU (EF:DD:77:9B:F7:45) V 17:57:37.388 Connecting to EF:DD:77:9B:F7:45... D 17:57:37.388 gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, preferred PHY = LE 1M) D 17:57:37.677 [Callback] Connection state changed with status: 0 and new state: CONNECTED (2) I 17:57:37.677 Connected to EF:DD:77:9B:F7:45 D 17:57:37.690 [Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED V 17:57:37.699 Discovering services... D 17:57:37.700 gatt.discoverServices() I 17:57:38.017 Connection parameters updated (interval: 7.5ms, latency: 0, timeout: 5000ms) D 17:57:38.399 [Callback] Services discovered with status: 0 I 17:57:38.399 Services discovered V 17:57:38.422 Generic Access (0x1800)

Screenshots

No response

clonedesign commented 2 years ago

Hi, is there any update about this issue?

baconcheese113 commented 2 years ago

Getting the same error from the dfu_ota.ino example sketch.

I've tried using the .zip and .hex output from the Arduino IDE compilation at C:\Users\{user}\AppData\Local\Temp\arduino-sketch-3D6AB27382EB0CF2C59607F00AD8FAC1 As well as the .zip and .hex output from platformIO compilation at C:\Users\{user}\Documents\PlatformIO\Projects\{project}\.pio\build\{env}

But I get the same error with both.

With Bluefruit Connect the app is able to connect to my advertising device fine, it can read the GATT server correctly, but when trying to perform an OTA DFU it brings up a Starting DFU Update... window and freezes.

With nRF Connect the app is able to connect and read the GATT server, and shows the DFU option in the app bar, but then when performing the OTA DFU it freezes after transferring the whole file. It is able to get the board into bootloader mode, but gets stuck there. Future resets continue back to the bootloader and it has to be re-flashed to run the sketch again

Here is my UF2 info

UF2 Bootloader 0.6.2-12-g459adc9-dirty lib/nrfx (v2.0.0) lib/tinyusb (0.10.1-293-gaf8e5a90) lib/uf2 (remotes/origin/configupdate-9-gadbb8c7)
Model: Seeed XIAO nRF52840
Board-ID: Seeed_XIAO_nRF52840_Sense
Date: Nov 30 2021
SoftDevice: S140 7.3.0
aqibnasim commented 1 year ago

I have also observed the same issue. Apparently it seems that its due to latest Android versions. BLE DFU seems to work fine with nrf application deployed with older versions of Android: https://apkpure.com/nrf-toolbox-for-bluetooth-le/no.nordicsemi.android.nrftoolbox/download/78-APK

Montvydas commented 1 year ago

This seems to be the same problem as #287. The problem is created due to the changes to the Nordic secure bootloader, which now supports MTU sizes larger than 23. Before that it was always forcing MTU to be 23 regardless of the bootloader, but now it allows the bootloader to decide on the MTU size itself. The older unsecure booloader, such as the Adafruit one doesn't support MTU sizes other than 23, which is a problem since it requests MTU size of 247, which is incompatible and thus it breaks. There is a merge request #293, which should fix this issue.