From a90341d9dbde948458b4fb9182f9525a33c7db11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Br=C3=A1zio?= <264365+jbrazio@users.noreply.github.com> Date: Wed, 25 Nov 2026 10:18:26 +0000 Subject: [PATCH] feat(nrf52): reboot straight into the GDFU bootloader on start ota When the bootloader version starts with "gdfu-", reply with the GDFU beacon target_id and reset into the bootloader after 2 s instead of starting the BLE DFU service, which a GDFU image does not provide. --- src/helpers/NRF52Board.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/helpers/NRF52Board.cpp b/src/helpers/NRF52Board.cpp index f2fa7743a..d21bf19cb 100644 --- a/src/helpers/NRF52Board.cpp +++ b/src/helpers/NRF52Board.cpp @@ -409,7 +409,26 @@ bool NRF52Board::getBootloaderVersion(char* out, size_t max_len) { return false; } +static SoftwareTimer gdfu_reset_timer; +static void gdfu_reset_cb(TimerHandle_t) { enterOTADfu(); } + bool NRF52Board::startOTAUpdate(const char *id, char reply[]) { + // GDFU bootloader (https://github.com/jbrazio/gdfu-bootloader) receives firmware over an + // SX1262 GFSK radio link from a GDFU proxy (https://github.com/jbrazio/gdfu-proxy) instead + // of BLE. Its image ships a single OTA transport, so there is no BLE DFU to hand off to: + // the BLE DFU service below would never complete. Reboot straight into the bootloader, + // which then beacons over GFSK and waits for the proxy. + char bl_ver[32]; + if (getBootloaderVersion(bl_ver, sizeof(bl_ver)) && strncmp(bl_ver, "gdfu-", 5) == 0) { + // Defer reset so the CLI reply can still go out. + gdfu_reset_timer.begin(2000, gdfu_reset_cb, NULL, false); + gdfu_reset_timer.start(); + // Reply with the target_id the GDFU bootloader beacons (low 32 bits of the BLE MAC), so the + // user can pick this node out of the targets the GDFU client discovers. + sprintf(reply, "OK: 0x%08lx", (unsigned long)NRF_FICR->DEVICEADDR[0]); + return true; + } + // Config the peripheral connection with maximum bandwidth // more SRAM required by SoftDevice // Note: All config***() function must be called before begin()