Repository navigation
Enforce bootloader discovery deadline - #2140
amilcarlucas wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
Review effort: Lite
Findings: 1
Open (3)
On the deadline-expired path,_restore_transport_timeout(...)is skipped. Since the transport was… · New The PR description says to reject discovery when legacy fallback finishes after the global… · New This test advances time based on how many timesread()is called while_replyis non-empty.… · New
What changed in this PR
Enforces the global bootloader discovery deadline by rejecting legacy-fallback identification that finishes too late, and adds a regression test to ensure the held bootloader is safely rebooted and flashing does not proceed.
Changes:
- Add a post-identification check to fail discovery if the global enumeration deadline has expired.
- Add a regression test simulating a slow legacy bootloader response that exhausts the discovery budget.
| File | Description |
|---|---|
ardupilot_methodic_configurator/backend_flightcontroller_bootloader.py |
Rejects late bootloader discovery attempts after the global deadline is exceeded. |
tests/test_backend_flightcontroller_bootloader.py |
Adds a regression test for deadline exhaustion during legacy fallback and verifies safe reboot/no flash writes. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| info = client.identify(deadline=attempt_deadline) | ||
| if self._clock() >= deadline: | ||
| msg = _("bootloader discovery deadline expired") | ||
| raise BootloaderProtocolError(msg) | ||
| _restore_transport_timeout(transport, self._timeout) | ||
| return client, info |
| if self._clock() >= deadline: | ||
| msg = _("bootloader discovery deadline expired") | ||
| raise BootloaderProtocolError(msg) |
| return super().write(data) | ||
|
|
||
| def read(self, size: int = 1) -> bytes: | ||
| if self.requests and self.requests[-1][:1] == bl.GET_DEVICE: | ||
| body = self.requests[-1][1:-1] | ||
| if body in {bl.INFO_BOARD_ID, bl.INFO_BOARD_REV, bl.INFO_FLASH_SIZE} and self._reply: | ||
| now[0] += 0.1 | ||
| return super().read(size) | ||
|
|
☂️ Code Coverage
Overall Coverage
New FilesNo new covered files... Modified FilesNo covered modified files...
|
Test Results 4 files - 1 4 suites - 1 50m 10s ⏱️ - 10m 31s For more details on these failures, see this check. Results for commit dcc6ee9. ± Comparison against base commit 05cc87e. This pull request removes 3 and adds 1 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
Previous review (2026-09-30)Automated review note — AI-generated (Claude), validated against the live diff. Please sanity-check before acting. Reviewed at head Thanks. Rejecting identification that completes after the discovery deadline looks right, and the new test covers it. One problem on the new path (https://github.com/ArduPilot/MethodicConfigurator/pull/2140/files#diff-c70ba4e2c02221763c9b3aa2459177b4b9c861b23571197bfac7e7c484f537a9R823): the deadline error goes into the recovery handler, which always calls abort_before_erase(expect_ack=True). A revision-2 bootloader reboots without an ACK. With a late legacy rev-2 board, the device does reboot, but the user gets 'could not confirm reboot ... power-cycle', bootloader_rebooted is not set, and upload_apj_firmware skips the automatic reconnect. info is known at that point, so passing expect_ack=info.protocol_revision != 2 there (as BootloaderClient.upload does) would fix it. Keep expect_ack=True when identify itself failed. Smaller suggestion: the new raise skips _restore_transport_timeout, so the reboot write runs with the shortened open timeout. Restoring the timeout at the start of the except block would cover this and the existing identify-failure path. FYI, pre-EXTF bootloaders that appear in the last ~2 s of the 15 s window will now always be rejected, because identify() waits out the deadline on the INSYNC/INVALID EXTF reply. Your test docstring suggests that is intended, so this is just a note. Not checked: real hardware and serial timing. |
Reject bootloader discovery when legacy external-flash fallback finishes after the global enumeration deadline. Reboot the held bootloader through the existing recovery path instead of allowing firmware upload to proceed after the discovery budget has expired. Add a regression test covering a delayed legacy bootloader response, deadline exhaustion, safe reboot, and prevention of flash writes.
c71289f to
dcc6ee9
Compare
|
Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting. Reviewed at head Still requesting changes: the revision-2 recovery bug is unchanged. Blocking
Should fix
Minor (2)
Copilot's Not checked: real hardware and serial timing. |
Coverage Report for CI Build 45185854679Coverage increased (+0.009%) to 96.147%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |


Description
Reject bootloader discovery when legacy external-flash fallback finishes after the global enumeration deadline. Reboot the held bootloader through the existing recovery path instead of allowing firmware upload to proceed after the discovery budget has expired.
Add a regression test covering a delayed legacy bootloader response, deadline exhaustion, safe reboot, and prevention of flash writes.
Checklist
git commit --signoff)Testing
Describe how you tested these changes: