Skip to content

test(integration): cover MCUboot serial-recovery MCUmgr params negotiation#121

Merged
JPHutchins merged 2 commits into
mainfrom
feat/issue-120-recovery-params-negotiation
Jun 25, 2026
Merged

test(integration): cover MCUboot serial-recovery MCUmgr params negotiation#121
JPHutchins merged 2 commits into
mainfrom
feat/issue-120-recovery-params-negotiation

Conversation

@JPHutchins

Copy link
Copy Markdown
Collaborator

Closes #120. Unblocked by intercreate/smp-server-fixtures#11 (merged) → release 27c54835.

MCUboot serial recovery now advertises the MCUmgr params command (mcu-tools/mcuboot#2746), so a client can negotiate the recovery buffer instead of being told it out of band. This covers that path against a real recovery server and verifies the negotiated packet sizes end to end.

Re-vendor

serial_recovery + serial_recovery_raw (mps2) are re-vendored from release 27c54835 (the first built with CONFIG_BOOT_MGMT_MCUMGR_PARAMS). The recovery server advertises {buf_size: 1024, buf_count: 1}, surfaced in manifest.json as the new recovery_buf_size / recovery_buf_count fields (distinct from the app netbuf buf_size/buf_count, which the recovery image reports in app mode). The serial_recovery_buf<N> matrix stays on 0eae053d — it's exercised in app mode, where recovery params don't apply.

Coverage

Each test reboots into recovery, asserts the advertised params (buf_count == 1, buf_size == recovery_buf_size), and uploads filling the negotiated buffer:

  • encodedAuto reads buf_size and fills buf_size − 4 = 1020 B decoded, which base64 + 128-byte line framing expands to ~1404 B on the wire (12 line packets ≤128 B each — matching the bootloader's BOOT_MAX_LINE_INPUT_LEN=128); the server decodes it incrementally back into its 1024 B buffer. An explicit BufferSize override is also exercised.
  • raw — the cap is the advertised buf_size itself: 1024 B per message verbatim (no base64/length/CRC framing).

Verified against real QEMU (mps2/an385); the DEBUG log shows the recovery server returning buf_size=1024 buf_count=1 and the client auto-configuring max_unencoded_size=1020 (encoded) / sending 1024-byte messages (raw).

Notes

  • The fixed-mtu raw legs are dropped: against a params-advertising server SMPClient.connect() always negotiates (the raw transport adopts buf_size unconditionally via the base initialize), so a "fixed mtu honored" leg no longer reflects real client behavior. The transport's pre-negotiation mtu fallback remains unit-tested.
  • Reboot-into-recovery boilerplate is factored into conftest.reboot_into_recovery.
  • Recovery uploads use a more generous per-chunk timeout (RECOVERY_UPLOAD_TIMEOUT_S) — recovery erases flash as it writes, slower than app-mode netbuf writes under emulation/load (a tight 5 s timeout flaked once under a loaded full-suite run).
  • Corrected the now-outdated "recovery does not advertise params" wording in the encoded BufferSize docstring.

ruff / pydoclint / mypy --strict / unit tests green; the recovery integration tests (encoded + raw, app-mode + recovery-mode) pass against QEMU.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KKXy7L2Udjw929nie2c363

…ation

Re-vendor serial_recovery + serial_recovery_raw (mps2) from smp-server-fixtures
27c54835 -- the first release built with CONFIG_BOOT_MGMT_MCUMGR_PARAMS
(mcu-tools/mcuboot#2746, intercreate/smp-server-fixtures#10). The bootloader's
recovery SMP server now advertises {buf_size: 1024, buf_count: 1}, surfaced in
the manifest as recovery_buf_size / recovery_buf_count (distinct from the app
netbuf). The serial_recovery_buf<N> matrix stays on 0eae053d (app-mode only).

Cover the negotiation path against a real recovery server:
- encoded: Auto reads buf_size and fills buf_size - 4 = 1020 B, which base64 +
  128-byte line framing expands to ~1400 B on the wire (the server decodes it
  incrementally back into its 1024 B buffer); an explicit BufferSize override is
  also exercised.
- raw: the cap is the advertised buf_size itself -- 1024 B per message verbatim,
  no base64/length/CRC framing.

Each asserts the advertised params (buf_count == 1, buf_size == recovery_buf_size)
and that the upload fills the negotiated buffer. The fixed-mtu raw legs are
dropped: against a params-advertising server SMPClient.connect() always
negotiates (the raw transport adopts buf_size unconditionally), so a
"fixed mtu honored" leg no longer reflects real client behavior.

Factor the reboot-into-recovery boilerplate into conftest.reboot_into_recovery,
and give recovery uploads a more generous per-chunk timeout (recovery erases
flash as it writes, slower than app-mode netbuf writes under emulation/load).
Update the now-outdated "recovery does not advertise params" wording in the
encoded BufferSize docstring.

Closes #120.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KKXy7L2Udjw929nie2c363
Copilot AI review requested due to automatic review settings June 24, 2026 22:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

…ry probes

reboot_into_recovery's "retry until the server answers" loop duplicated the
structure of _wait_until_answering -- the poll every connected() test already
relies on. Extract _poll_until_answering(client, probe), so both share one
retry/except/sleep implementation and each call site supplies only its probe
(echo round-trip vs image-list) and failure handling.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KKXy7L2Udjw929nie2c363
@JPHutchins JPHutchins merged commit 4970f3e into main Jun 25, 2026
29 checks passed
@JPHutchins JPHutchins deleted the feat/issue-120-recovery-params-negotiation branch June 25, 2026 00:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integration coverage: MCUboot serial-recovery MCUmgr params negotiation (Auto buf_size)

2 participants