dotbot/firmware: reset the device last, and through CTRL-AP - #281
Merged
Conversation
Flashing left the bot off the network until someone pressed reset. Two causes: `--reset` is a SysResetReq, which the SwarmIT bootloader refuses via SCB_AIRCR.SYSRESETREQS, and the config-page readback halts the network core, so a reset done before it left the device programmed but stopped. Program every image first, read back, then reset once over CTRL-AP and start the core. Verified over three consecutive flashes with no button press. AI-assisted: Claude Opus 5
Attaching the debugger to the network core resets it, and the application core does not notice, so the bot keeps running with no radio and looks dead until the whole device is reset. `device info` now says so and asks before reading, takes -y to skip, and resets the device afterwards so it comes back on its own. The device id moves to the application core's FICR, which reads back with no side effect at all. AI-assisted: Claude Opus 5
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #281 +/- ##
===========================================
- Coverage 83.50% 83.50% -0.01%
===========================================
Files 121 121
Lines 11237 11266 +29
Branches 570 569 -1
===========================================
+ Hits 9384 9408 +24
- Misses 1850 1854 +4
- Partials 3 4 +1
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
After
dotbot device flash-swarmit-sandbox, the DotBot did not rejoin the network until someone physically pressed reset. Same fordotbot device info, which left a running bot off the air indefinitely - looking exactly like dead hardware.Two independent causes, both here in the flasher.
1. The reset never landed.
nrfjprog --resetissues a SysResetReq, and the SwarmIT bootloader setsSCB_AIRCR.SYSRESETREQSso non-secure code cannot reboot the robot mid-experiment. That is a deliberate sandbox guarantee and should stay, so the flasher has to reset from the debug domain instead (--debugreset, CTRL-AP), which firmware cannot veto.2. The reset was not last - the dominant cause.
flash_roleread the config page back after resetting. That read attaches the debugger to the network core, which resets it, and the application core never notices: the bot keeps running with no radio. CTRL-AP alone did not fix anything until this ordering was corrected.The approach
Program every image first, read back, then perform a single CTRL-AP reset plus an explicit
--runas the genuinely final device operation. Resetting between writes would boot the cores against a half-provisioned device, so the two flash helpers takereset=Falseand the caller owns the one reset at the end.device infogets the same treatment from the other side: it now states that reading the network id resets the device, asks before doing it (-yskips, matchingswarm flash), and resets afterwards so the bot comes back on its own instead of being stranded.read_device_idmoves to the application core's FICR, which reads back with no side effect at all, leaving the network id as the only destructive read - so the prompt guards one narrow thing rather than the whole command.Worth a reviewer's attention
lockupinRESETREAS. That register accumulates until the bootloader clears it, and the bit is set during programming while the application core executes from flash being erased. It is self-limiting to that one boot; the device is healthy.Validation
On hardware, bot
A23EFBCB596212AEwith a bootloader built from unmodified sources: three consecutive flashes joined with no button press, and an OTA app flash + start runs.device info -yreads correctly and the bot returns on its own within ~15 s. 41 unit tests pass, including new coverage that declining the prompt leaves the device untouched, that-yskips it, and thatread_device_idnever passesCP_NETWORK.flash-mari-gatewayshares this code path so it likely benefits too, but the gateway runs different firmware and was not tested.