Since commit b4affea, the -m/--mtu argument is treated as the size of the data inside CBOR-serialized ImageUploadReq struct rather than the maximum serial frame limit.
CBOR serialization, 8-byte SMP header, 2-byte CRC plus 2-byte length field, Base64 encoding and the serial framing inflates the total size.
With a Zephyr/MCUBoot device configured with CONFIG_BOOT_SERIAL_MAX_RECEIVE_SIZE=4096, setting -m 4096 -l 8192 (as in the README) causes the base64 serial frame to exceed 4096 bytes. This causes the target to silently drop trailing data exceeding the buffer limit, truncating the serial frame and failing the upload.
To make it work i had to change the parameters to mcumgr-client -m 4016 -l 4096 ... (which even makes the transfer slightly faster).
It is unclear to me whether this is a bug in the code or an intentional design shift and the README was not updated. As the zephyr docs mention this:
SMP protocol over serial is fragmented into MTU size frames; each frame consists of two byte start marker, body and terminating newline character.
Since all other references in the docs indicate MTU is the full frame and not just the payload, I suspect this is a code bug. That said, the overall specs and Zephyr implementation are quite confusing to me.
Since commit b4affea, the -m/--mtu argument is treated as the size of the data inside CBOR-serialized ImageUploadReq struct rather than the maximum serial frame limit.
CBOR serialization, 8-byte SMP header, 2-byte CRC plus 2-byte length field, Base64 encoding and the serial framing inflates the total size.
With a Zephyr/MCUBoot device configured with
CONFIG_BOOT_SERIAL_MAX_RECEIVE_SIZE=4096, setting -m 4096 -l 8192 (as in the README) causes the base64 serial frame to exceed 4096 bytes. This causes the target to silently drop trailing data exceeding the buffer limit, truncating the serial frame and failing the upload.To make it work i had to change the parameters to
mcumgr-client -m 4016 -l 4096 ...(which even makes the transfer slightly faster).It is unclear to me whether this is a bug in the code or an intentional design shift and the README was not updated. As the zephyr docs mention this:
SMP protocol over serial is fragmented into MTU size frames; each frame consists of two byte start marker, body and terminating newline character.Since all other references in the docs indicate MTU is the full frame and not just the payload, I suspect this is a code bug. That said, the overall specs and Zephyr implementation are quite confusing to me.