boot: boot_serial: add optional mcumgr parameters command#3
Conversation
Add support for the mcumgr OS management group "MCUmgr parameters" command (group 0, command ID 6), gated behind the new CONFIG_BOOT_MGMT_MCUMGR_PARAMS option. The read-only command reports the SMP transport buffer parameters as a CBOR map, mirroring the command provided by Zephyr's SMP server so that existing SMP clients can query them unchanged. The serial recovery reassembles one command at a time into a single buffer, so the response reports a buf_size of CONFIG_BOOT_SERIAL_MAX_RECEIVE_SIZE and a buf_count of 1. The parameters do not carry the transport line length, which SMP serial clients assume to be 128 bytes, so the option depends on CONFIG_BOOT_MAX_LINE_INPUT_LEN remaining at its default of 128. Signed-off-by: JP Hutchins <jp@intercreate.io> Assisted-By: Claude:opus-4.8
There was a problem hiding this comment.
Pull request overview
Adds an optional, Kconfig-gated mcumgr "MCUmgr parameters" command (OS group, command ID 6) to MCUboot's serial-recovery SMP server. When enabled, it replies with a CBOR map {buf_size, buf_count} so that SMP clients can auto-negotiate serial fragmentation, mirroring Zephyr's os_mgmt_mcumgr_params command. The option is gated on BOOT_MAX_LINE_INPUT_LEN = 128 to keep the advertised buffer size consistent with the 128-byte fragment size assumed by SMP serial clients.
Changes:
- New
bs_mcumgr_paramshandler inboot_serial.cand a newNMGR_ID_MCUMGR_PARAMS(6) dispatch case, all guarded byMCUBOOT_BOOT_MGMT_MCUMGR_PARAMS. - New Kconfig option
BOOT_MGMT_MCUMGR_PARAMS(with theBOOT_MAX_LINE_INPUT_LEN = 128dependency) and correspondingmcuboot_config.hmacro mapping. - Sample/twister scenario, release note, and
serial_recovery.mdupdates documenting the new optional command.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| boot/boot_serial/src/boot_serial.c | Implements bs_mcumgr_params and wires it into the OS-group dispatch switch under the new ifdef. |
| boot/boot_serial/src/boot_serial_priv.h | Adds the NMGR_ID_MCUMGR_PARAMS (6) command-ID constant. |
| boot/zephyr/Kconfig.serial_recovery | Adds the BOOT_MGMT_MCUMGR_PARAMS Kconfig option, depending on BOOT_MAX_LINE_INPUT_LEN = 128. |
| boot/zephyr/include/mcuboot_config/mcuboot_config.h | Maps the Kconfig symbol to the port-agnostic MCUBOOT_BOOT_MGMT_MCUMGR_PARAMS macro. |
| boot/zephyr/sample.yaml | Enables the new option in the serial_recovery_all_options twister scenario for build coverage. |
| docs/serial_recovery.md | Documents the new command in the supported-MCUmgr-commands list. |
| docs/release-notes.d/serial-recovery-mcumgr-params.md | Adds a release note for the new option. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Superseded by the upstream PR mcu-tools#2746 (this was an internal fork PR opened by mistake). |
Summary
Adds an optional, Kconfig-gated mcumgr MCUmgr parameters command to the
serial-recovery SMP server (OS management group
0, command ID6,read-only), mirroring the command provided by Zephyr's SMP server.
When
CONFIG_BOOT_MGMT_MCUMGR_PARAMSis enabled the server answers with theCBOR map
{"buf_size": <CONFIG_BOOT_SERIAL_MAX_RECEIVE_SIZE>, "buf_count": 1},allowing SMP clients (e.g. smpclient)
to auto-negotiate serial fragmentation instead of hardcoding buffer sizes.
buf_countis1because serial recovery reassembles one command at a timeinto a single buffer.
Why the 128-byte line-length requirement
mcumgr parameters do not carry the transport line length (MTU); SMP serial
clients assume 128-byte fragments and derive
line_buffers = buf_size // 128.To keep the advertised
buf_sizeconsistent, the optiondepends on BOOT_MAX_LINE_INPUT_LEN = 128— setting a different line lengthmakes Kconfig refuse the option.
Compatibility
Identical wire contract to upstream Zephyr's
os_mgmt_mcumgr_params— samegroup/id, read-only, same
buf_size/buf_countkeys andzcbor_uint32_putencoding — so existing SMP clients read it unchanged.
ROM / RAM cost
Measured on
nrf52840dk/nrf52840withserial_recovery.conf, with vs.without the option: +116 B flash, +0 B RAM.
Test coverage
Added
CONFIG_BOOT_MGMT_MCUMGR_PARAMS=yto theserial_recovery_all_optionstwister scenario, so the feature is build-covered on every PR via the existing
Zephyr twister CI.
🤖 Generated with Claude Code