| Crates.io | zephyr-mcumgr-cli |
| lib.rs | zephyr-mcumgr-cli |
| version | 0.7.0 |
| created_at | 2025-11-04 10:06:33.64199+00 |
| updated_at | 2026-01-24 14:12:04.228384+00 |
| description | Command-line interface for Zephyr's MCUmgr protocol |
| homepage | |
| repository | https://github.com/Finomnis/zephyr-mcumgr-client |
| max_upload_size | |
| id | 1916071 |
| size | 82,773 |
This crate provides a full Rust-based software suite for Zephyr's MCUmgr protocol.
It might be compatible with other MCUmgr/SMP-based systems, but it is developed with Zephyr in mind.
Specifically, it provides:
Its primary design goals are:
use static memory and large buffers to prioritize performance over memory footprint
see further down for more information regarding performance optimizations required on Zephyr side
use zephyr_mcumgr::MCUmgrClient;
use std::time::Duration;
fn main() {
let serial = serialport::new("COM42", 115200).open().unwrap();
let mut client = MCUmgrClient::new_from_serial(serial);
client.use_auto_frame_size().unwrap();
println!("{:?}", client.os_echo("Hello world!").unwrap());
}
"Hello world!"
To use this library in your project, enter your project directory and run:
cargo add zephyr-mcumgr
cargo install zephyr-mcumgr-cli
Send an echo over a serial connection:
$ zephyr-mcumgr --serial COM42 os echo "Hello world!"
Hello world!
Omit the command to run a simple connection test:
$ zephyr-mcumgr --serial COM42
Device alive and responsive.
Connect to a USB serial port using USB VID/PID:
$ zephyr-mcumgr --usb-serial 2fe3:0004
Device alive and responsive.
Or without an identifier to list all available ports:
$ zephyr-mcumgr --usb-serial
Available USB serial ports:
- 2fe3:0004:0 (/dev/ttyACM0) - Zephyr Project CDC ACM serial backend
You can even use a Regex if you want:
$ zephyr-mcumgr --usb-serial "2fe3:.*"
Device alive and responsive.
[!TIP]
2fe3:0004is the default VID/PID of Zephyr samples.
Zephyr's default buffer sizes are quite small and reduce the read/write performance drastically.
The central most important setting is MCUMGR_TRANSPORT_NETBUF_SIZE. Its default of 384 bytes is very limiting, both for performance and as cutoff for large responses, like os task_statistics or some shell commands.
Be aware that changing this value also requires an increase of MCUMGR_TRANSPORT_WORKQUEUE_STACK_SIZE to prevent overflow crashes.
In practice, I found that the following values work quite well (on i.MX RT1060) and give me 410 KB/s read and 120 KB/s write throughput, which is an order of magnitude faster than the default settings.
CONFIG_MCUMGR_TRANSPORT_NETBUF_SIZE=4096
CONFIG_MCUMGR_TRANSPORT_WORKQUEUE_STACK_SIZE=8192
If the experience differs on other chips, please open an issue and let me know.
Contributions are welcome!
I primarily wrote this crate for myself, so any ideas for improvements are greatly appreciated.