Skip to content

boot: boot_serial: add optional mcumgr parameters command#3

Closed
JPHutchins wants to merge 1 commit into
mainfrom
feature-zephyr-mcumgr-params
Closed

boot: boot_serial: add optional mcumgr parameters command#3
JPHutchins wants to merge 1 commit into
mainfrom
feature-zephyr-mcumgr-params

Conversation

@JPHutchins
Copy link
Copy Markdown
Collaborator

Summary

Adds an optional, Kconfig-gated mcumgr MCUmgr parameters command to the
serial-recovery SMP server (OS management group 0, command ID 6,
read-only), mirroring the command provided by Zephyr's SMP server.

When CONFIG_BOOT_MGMT_MCUMGR_PARAMS is enabled the server answers with the
CBOR 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_count is 1 because serial recovery reassembles one command at a time
into 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_size consistent, the option
depends on BOOT_MAX_LINE_INPUT_LEN = 128 — setting a different line length
makes Kconfig refuse the option.

Compatibility

Identical wire contract to upstream Zephyr's os_mgmt_mcumgr_params — same
group/id, read-only, same buf_size/buf_count keys and zcbor_uint32_put
encoding — so existing SMP clients read it unchanged.

ROM / RAM cost

Measured on nrf52840dk/nrf52840 with serial_recovery.conf, with vs.
without the option: +116 B flash, +0 B RAM.

Test coverage

Added CONFIG_BOOT_MGMT_MCUMGR_PARAMS=y to the serial_recovery_all_options
twister scenario, so the feature is build-covered on every PR via the existing
Zephyr twister CI.

🤖 Generated with Claude Code

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
Copilot AI review requested due to automatic review settings May 29, 2026 22:57
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_params handler in boot_serial.c and a new NMGR_ID_MCUMGR_PARAMS (6) dispatch case, all guarded by MCUBOOT_BOOT_MGMT_MCUMGR_PARAMS.
  • New Kconfig option BOOT_MGMT_MCUMGR_PARAMS (with the BOOT_MAX_LINE_INPUT_LEN = 128 dependency) and corresponding mcuboot_config.h macro mapping.
  • Sample/twister scenario, release note, and serial_recovery.md updates 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.

@JPHutchins
Copy link
Copy Markdown
Collaborator Author

Superseded by the upstream PR mcu-tools#2746 (this was an internal fork PR opened by mistake).

@JPHutchins JPHutchins closed this May 29, 2026
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.

2 participants