Skip to content

Commit fb9611c

Browse files
committed
docs: add serial recovery throughput tuning guide
The serial recovery documentation did not mention the Kconfig options that control upload throughput (BOOT_SERIAL_MAX_RECEIVE_SIZE, BOOT_MAX_LINE_INPUT_LEN, BOOT_LINE_BUFS) or the host-side --mtu flag. With defaults, each SMP round-trip carries only ~228 bytes of image data, making large uploads unnecessarily slow. Document how to increase buffer sizes and pass a matching MTU for significantly faster uploads. Signed-off-by: Jay Beavers <jay@tolttechnologies.com>
1 parent d9c2ba1 commit fb9611c

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

docs/readme-zephyr.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,47 @@ The mapping of image number to partition is as follows:
250250
Use the ``CONFIG_ENABLE_MGMT_PERUSER=y`` Kconfig option to enable the following additional commands:
251251
* Storage erase - This command allows erasing the storage partition (enable with ``CONFIG_BOOT_MGMT_CUSTOM_STORAGE_ERASE=y``).
252252

253+
### Throughput tuning
254+
255+
Upload throughput is determined by how much image data fits in each SMP
256+
round-trip. Three Kconfig options control the receive-side buffer on the device:
257+
258+
| Option | Default | Description |
259+
|--------|---------|-------------|
260+
| ``CONFIG_BOOT_SERIAL_MAX_RECEIVE_SIZE`` | 1024 | Maximum reassembled SMP frame size (bytes) |
261+
| ``CONFIG_BOOT_MAX_LINE_INPUT_LEN`` | 128 | SMP serial line fragment size (bytes) |
262+
| ``CONFIG_BOOT_LINE_BUFS`` | 8 | Number of fragment reassembly buffers |
263+
264+
The product ``CONFIG_BOOT_MAX_LINE_INPUT_LEN × CONFIG_BOOT_LINE_BUFS`` should be at least
265+
``CONFIG_BOOT_SERIAL_MAX_RECEIVE_SIZE``. With the defaults, each upload request carries
266+
roughly 228 bytes of image data after base64 and CBOR overhead.
267+
268+
Increasing the receive buffer allows the host to send larger chunks per
269+
round-trip. For example, setting ``CONFIG_BOOT_SERIAL_MAX_RECEIVE_SIZE=4096``
270+
and ``CONFIG_BOOT_MAX_LINE_INPUT_LEN=512`` allows approximately 3 KB of image
271+
data per round-trip at the cost of roughly 6 KB additional RAM (the ``in_buf``
272+
and ``dec_buf`` static arrays in ``boot_serial.c``).
273+
274+
On the host side, pass a matching MTU in the ``mcumgr`` connstring:
275+
276+
``` console
277+
mcumgr --conntype serial --connstring "dev=/dev/ttyACM0,baud=115200,mtu=4096" image upload <image>
278+
```
279+
280+
The following table shows approximate upload times for a 374 KB image
281+
over USB CDC-ACM (tested on nRF52840 with
282+
[apache/mynewt-mcumgr-cli@5c56bd2](https://github.com/apache/mynewt-mcumgr-cli/commit/5c56bd24066c)):
283+
284+
| Configuration | Throughput | Approximate time |
285+
|---------------|-----------|------------------|
286+
| Default (no MTU) | ~1 KB/s | ~6 minutes |
287+
| mtu=4096 | ~4 KB/s | ~1.5 minutes |
288+
289+
**Note:** When using USB CDC-ACM as the serial transport, the baud rate
290+
parameter is ignored because USB bulk transfers are not rate-limited by a
291+
physical UART clock. The baud rate setting only affects physical UART
292+
transports.
293+
253294
### More configuration
254295

255296
For details on other available configuration options for the serial recovery protocol, check the Kconfig options (for example by using ``menuconfig``).

0 commit comments

Comments
 (0)