-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Image upload Write missing len parameter #19
Comments
It seems that the SMP docs (latest version from zephyr) mentions that for off = 0, len should be used. |
This is correct, and this is what the provided upload routine does. It makes one initial request that contains the information that is only used by the first request: len, sha, and upgrade: smpclient/smpclient/__init__.py Lines 57 to 69 in 9279cd7
Subsequent requests do not include the len, sha, or upgrade fields.
I suspect that the root cause of the issue is the MCUBoot SMP MTU. smpmgr and the other tools will default to 4096 whereas your version of MCUBoot may be lower. Here is some info from Kconfig.serial_recovery:
I've been using
And get ~20-55KBps depending on the hardware. From rereading the Kconfig info I see that my config is wrong. Seems that it should be
Looks like tldr; try with Cheers, |
Unrelated, this should be investigated more. Why a default of 8 buffers? This only makes sense to me if the MCUBoot serial driver was smart enough to be doing async RX on a DMA while it's writing the new image to flash - it is not doing that. Everything should be synchronous:
The SMP client would not be sending the next upload request until it has received the next offset. I don't see a reason for more than one buffer, yet I see 10 (8 in serial_adapter.c and 2 in boot_serial.c) in the default implementation. |
I am actually using mtu of 128. I am prototyping with CAN as a transport layer getting around 4 kb/s with 1 MHz , 8 bytes DLC. I will try to increase the buffer size. Problem is my mcu has around 16 kb sram. |
CAN, very cool! This explains the problem and it is the same as what I saw in the shell transport. The fix is to remove the hash from the first request and use —MTU 128. Or to increase your MTU in FW to ~256. I don’t know of an SMP server that uses the hash - they should, LMAO. How are you building MCUBoot and what options are available to you? I am only familiar with Zephyrs SMP server implementation but can look at others. I am very curious if you're using Zephyr with 16K of RAM. |
Looking at serial_adapter.c next. It's sorta complicated and I can see why multiple buffers may be required for a poorly behaved client. Seems like changing the CONFIG_BOOT_MAX_LINE_INPUT_LEN to be larger might get you by. I don't see the need for 8 buffers of it, try 2 maybe. |
I am building MCUBoot for Zephyr with sysbuild. I am actually using the default options provided by MCUboot and using a single application slot ( You can see my forked version here. I basically copied the serial transport adapter from zephyr and use the can api instead.
The MCU has 32 K but they are not contigous. The SoC definition provided by NXP only uses half of it. The other half requires an extra linker file to be used for buffers,etc. So far my application and bootloader work with 16 K but perhaps I will need to enable the second half. |
Zephyr with only 32K of RAM is wild 🔥 I've used single application slot and would like to make you aware of this: mcu-tools/mcuboot#1931 |
Thanks, this is something good to be aware of! For my use case I have an external GPIO to get into the bootloader. I will try the buffer recommendation and see if that makes mcuboot happy. Btw, thanks a lot for the project! This has allowed me to prototype a CAN MCuboot loader really fast. |
This is awesome! I'd love to see it upstreamed to MCUBoot though I understand that's a lot of time. Since you have control over the defaults, I recommend proceeding to the larger buffer sizes. If the Last thing - I'm unclear if you tried running And keep me posted if smpclient needs a CAN transport. Sounds like you're using some adapter for now. |
The buffer increase did the trick! Changed it to 512 max line input, 2 buffers and now I am getting around 15 Kb/s. |
I am testing the smpmgr and found a possible bug (?) when uploading an image to mcuboot over zephyr.
If the
ImageUploadWrite
packet does not include thelen
parameter, when the bootloader decodes thelen
parameter it gets the maximumuint32_t
number. This in turn makes mcuboot returnMGMT_ERR_EINVAL
and makes the upload from smpmgr fail as the offset field is not sent since rc == 3.Mcuboot fails because the first chunk uses the
len
field to check if the length of the image fits in the partition (here).If I add the len field here, then mcuboot complies and works correctly. Something such as
I tested this with the latest mucboot repo from zephyr. In specific this commit.
Smpmgr options
upgrade zephyr.signed.hex
The text was updated successfully, but these errors were encountered: