Skip to content

Commit 2490e19

Browse files
committed
fkclaude: prefer an application command over patching the core's touch handler
enterUf2Dfu() is declared in the core's public cores/nRF5/wiring.h, so an application can call it directly - a MeshCore command "reboot to UF2" needs no core change at all. That is strictly better than patching TinyUSB_Port_EnterDFU(), which changes what a 1200-baud touch means for every application built on that core; since the touch is the normal Arduino upload path, on Windows a removable drive would appear on every upload, with an indexer or antivirus scanning a freshly mounted FAT volume while a serial DFU is in flight. Recorded the measurement that argument needs: serial DFU does work with MSC mounted - the XIAO was flashed from UF2 mode in 28.33 s, 928 marks, Device programmed. So MSC is a nuisance there, not a breakage. Also corrected an overstatement from the previous note. meshcore-dev/MeshCore is as much an upstream as oltaco's bootloader; a command added there needs its own PR. The asymmetry that survives is the cost of carrying the change until it lands - the command sits in a fork already maintained and built from, while the core patch would need a fork of meshcore-dev/Adafruit_nRF52_Arduino and a re-pinned platformio.ini, or PlatformIO overwrites it. And the three routes are not redundant: an application command covers a running application, PR 47's recovery covers an invalid one, and only PR 50 covers a bootloader already sitting in serial-only DFU.
1 parent d86545d commit 2490e19

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

fkclaude/fcl_readme_dfu_recovery.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,37 @@ separate problems - the patch only solves the first.
149149
Currently **not applied** anywhere, confirmed by measurement: a 1200-baud touch on the XIAO brings up
150150
CDC with no mass storage, i.e. the unpatched `enterSerialDfu()`.
151151

152+
### A third route, which is better than the patch
153+
154+
`enterUf2Dfu()` is declared in the core's **public** header `cores/nRF5/wiring.h`, next to
155+
`enterSerialDfu()` and `enterOTADfu()`. So the **application can call it itself** - a MeshCore command
156+
"reboot to UF2" needs no core change at all.
157+
158+
That is strictly better than patching `TinyUSB_Port_EnterDFU()`. The patch changes what a 1200-baud
159+
touch means for every application built on that core, and since the touch *is* the normal Arduino
160+
upload path, on Windows a removable drive would appear on **every upload** - drive letter, Explorer,
161+
and an indexer or antivirus scanning a freshly mounted FAT volume exactly while a serial DFU is in
162+
flight. That is the first objection a maintainer would raise, and it is a fair one.
163+
164+
Worth knowing for that argument: serial DFU **does** work with MSC mounted. The XIAO was flashed from
165+
UF2 mode (`PID_0045` + mass storage) in 28.33 s, 928 marks, `Device programmed.` - so MSC is a
166+
nuisance here, not a breakage.
167+
168+
Neither route makes the others redundant, because the three device states do not overlap:
169+
170+
| device state | what reaches UF2 mode |
171+
|---|---|
172+
| application running | a MeshCore command calling `enterUf2Dfu()` |
173+
| application invalid, or a transfer was interrupted | recovery (PR #47) comes up CDC + MSC by itself |
174+
| bootloader already sitting in serial-only DFU | **only `DFU_REBOOT_PACKET` (PR #50)**, else a physical double tap |
175+
176+
One caution against over-optimism: `meshcore-dev/MeshCore` is as much an upstream as
177+
`oltaco/…Bootloader` - a command added there needs its own PR and its own maintainer's agreement. The
178+
difference is not the upstream, it is the cost of carrying the change until it lands: the command sits
179+
in the MeshCore fork that is already maintained and built from, whereas the core patch would mean
180+
forking `meshcore-dev/Adafruit_nRF52_Arduino` and re-pinning `platformio.ini` - or being overwritten
181+
by PlatformIO on the next framework reinstall.
182+
152183
## Verification
153184

154185
All on a ProMicro nRF52840 + J-Link, verdicts read from the device (`bank_0` over SWD), never

0 commit comments

Comments
 (0)