Repository navigation
Integration coverage: MCUboot serial-recovery MCUmgr params negotiation (Auto buf_size) #120
Description
mcu-tools/mcuboot#2746 — "boot: boot_serial: add optional mcumgr parameters command" (merged) — gives MCUboot's serial-recovery SMP server an optional MCUmgr parameters command (CONFIG_BOOT_MGMT_MCUMGR_PARAMS). This is a behavior change for us: until now MCUboot serial recovery never advertised params, and we hardcode that assumption —
src/smpclient/transport/serial/encoded.py(Auto docstring): "For servers that do not advertise MCUmgr params (e.g. MCUboot serial recovery)…"tests/integration/test_serial_recovery.py/test_serial_recovery_raw.py: "recovery does not advertise MCUmgr params", so they pass an explicitBufferSize(buf_size=1024)/ pinmtu.
With the option enabled, a recovery server can report {buf_size, buf_count: 1}. SMPClient._initialize already consumes that (src/smpclient/__init__.py:556): it issues MCUMgrParametersRead and, on success, calls transport.initialize(buf_size); on an SMP error it warns, and on timeout it warns and the transport simply keeps its existing buffer size (the implicit fallback). What's missing is any integration coverage of the success path against a bootloader recovery server.
Blocked on
intercreate/smp-server-fixtures#10 — the recovery fixtures must be rebuilt with CONFIG_BOOT_MGMT_MCUMGR_PARAMS=y, and that issue also decides how the manifest surfaces the recovery server's advertised buf_size/buf_count (which differs from the fixture's app-side buf_size).
Harness work (smpclient side)
-
Re-vendor the updated
serial_recovery+serial_recovery_raw(mps2) fixtures once published — refreshtests/fixtures/smp-server/{manifest.json,SHA256SUMS,VERSION}the way test(integration): MCUboot raw serial recovery (SMPSerialRawTransport) #119 did. -
Cover the negotiated path (in addition to, not replacing, the explicit-
BufferSizepath — params remain optional, so params-less recovery servers must still work). Intest_serial_recovery.pyandtest_serial_recovery_raw.py, after re-entering recovery, assertMCUMgrParametersReadnow succeeds withbuf_count == 1andbuf_sizeequal to the recovery server's advertised value (from the manifest field added by feat: add shell management group #10), and thatAutonegotiation produces the expected cap:- encoded console recovery →
max_unencoded_size == buf_size − 4(the length prefix + CRC16 share the decoded frame); - raw recovery →
max_unencoded_size == buf_size(no base64/length/CRC framing; the transport inherits theSMPTransportbase that usesbuf_sizedirectly).
The advertised value is a decoded ceiling (mcuboot's
BOOT_SERIAL_MAX_RECEIVE_SIZE, default 1024), so this finally pins the encoded-vs-decodedbuf_sizequestion empirically against a real recovery server. - encoded console recovery →
-
Update the now-outdated assumptions. The "recovery does not advertise MCUmgr params" wording in the
encoded.pyAuto docstring and in both recovery tests is no longer universally true — qualify it (params are now optionally advertised by recovery, gated on the bootloader Kconfig). -
Raw test:
test_serial_recovery_raw.pycurrently pins the cap viaQemuSocketSerialRawTransport(..., mtu=mtu). Add a leg that lets the client readbuf_sizeand asserts the resultingmax_unencoded_size, alongside the fixed-mtuparametrization.
Acceptance
A recovery upload runs with the buffer size negotiated from the bootloader's params (not the explicit BufferSize / mtu fallback), for both encoded and raw recovery, green in CI — while the params-less recovery path still passes.
Refs: mcu-tools/mcuboot#2746, #81, #118 / #106 (raw recovery), #119 (raw-recovery test scaffolding this extends).
Activity