feat(repeater): dfu [uf2|serial|ota] — deterministic reboot into the bootloader

The 1200-baud touch was the wrong mechanism, not an unreliable one. The
Adafruit bootloader chooses its mode from GPREGRET at boot, and the core
already exposes exactly that (cores/nRF5/wiring.c):

  enterUf2Dfu()    0x57  DFU_MAGIC_UF2_RESET          -> mass-storage drive
  enterSerialDfu() 0x4e  DFU_MAGIC_SERIAL_ONLY_RESET  -> CDC only, no drive
  enterOTADfu()    0xA8  DFU_MAGIC_OTA_RESET          -> BLE DFU

The touch only ever requests the *serial* one. That is why no UF2 drive ever
appeared however long we waited for it, and it is the real reason today's
flashes kept going sideways -- I read "coin flip" into what was simply a
request for a different mode, and then wedged two boards proving it.

`dfu` writes the magic and resets, so the board lands in the mode you asked
for, every time. The reply goes out first and the reset happens ~700 ms later
from loop(), since reset_mcu() never returns and over BLE the notification
still has to be pumped out of the TX ring.

LOCAL ONLY (sender_timestamp == 0, the same physical-presence test CommonCLI
uses for `erase` and `set freq`). Over the mesh this would park a node in a
bootloader that waits forever, on a mast, with no way back but a visit.

Builds clean; NOT yet exercised on hardware -- the boards that could test it
are the ones still running firmware without the command.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
tthandClaude Opus 5 committed 2026-08-04 12:53:20 +02:00
1 parent 59e974854f
commit 3c27e7745f
2 files changed
+75

No files matched your search

+4
View File
@@ -1629,6 +1629,10 @@ void MyMesh::handleCommand(uint32_t sender_timestamp, char *command, char *reply
// since a board with no data cable and no BLE cannot be identified at all.
extern bool identHandleCommand(const char* command, char* reply);
if (identHandleCommand(command, reply)) return;
// CUSTOM (TeTeHacko): `dfu [uf2|serial|ota]` — deterministic reboot into the
// bootloader (GPREGRET magic, same as the core's enterUf2Dfu). Local only.
extern bool dfuHandleCommand(uint32_t sender_timestamp, const char* command, char* reply);
if (dfuHandleCommand(sender_timestamp, command, reply)) return;
// CUSTOM (TeTeHacko): `txpwr [dBm]` — set output power and report RadioLib's
// verdict, which `set tx` swallows. See main.cpp.
extern bool txPwrHandleCommand(const char* command, char* reply);