Open beriberikix opened 2 years ago
Have you looked at supporting WebUSB, Web Serial and/or WebHID? That would expand the utility of this library to devices that don't have BT connectivity.
Haha, I didn't know "Web Serial" was a thing, I might take a look at that one.
Yup, and it works pretty well! CC @reillyeon
That would be awesome to add. I don't have a device I can test it with, but I'm ready to help.
Contact me if you would like to add USB functionality. I'm very interested in implementing it, but I need your help about setting up a development environment for it.
I decided to finally take a stab at building something with WebSerial. I've cobbled together a proof-of-concept branch for the mcumgr SMP over console transport on my branch here (demo page). I only have an mcuboot device to test with, but listing images and uploading seem to work okay.
I believe I'm handling the mcumgr serial framing correctly, but I'm pretty sure my first stab at the WebSerial portion could use some refinement.
So cool! I tested it with a known-good MCUBoot image and device (ESP32, docs here.) Uploading never started. Is there anything I can capture to help troubleshoot?
Nothing noteworthy in chrome://device-log
.
Hmm, no obvious errors / unexpected exceptions. My guess would be that either the device never responded for some reason, or else the first upload message never got sent for some reason.
Actually, this might be user error. What device were you using? Espressif devices are "special."
I'm testing on a non-mainline device with the mcuboot single-slot serial recovery mode, which uses a subset of the normal mcumgr commands. I'm sure it's possible to enable the mcumgr shell/console transport in normal application builds, I just haven't quite figured out the right configuration yet.
From some further testing with a frankenstein mashup of the shell sample and the smp_svr sample, I can get an ESP32 to at least respond with MGMT_ERR_ENOTSUP
(8) if I change the image status / list command to encode an empty map instead of a null payload (to closer match what the mcumgr cli does), but no luck getting non-error responses to even the echo command, either with the mcumgr cli or with webserial.
I'll have to do some further poking tomorrow and probably switch to some hardware that I can connect to with the debugger to see why it's always failing to handle the commands even though I'm pretty sure the config is correct.
Wow, I really glad about your contribution. I won't be able to test it short term, but tell me if you think it's "ready", and we can merge it.
I guess I didn't mash things up the right way, but it turns out no modifications to the Zephyr examples were really needed.
The right sequence of commands to build and flash an mcuboot-compatible image for the ESP32 with a multiplexed command shell / mcumgr SMP pipe is:
west build -b esp32 -- -DOVERLAY_CONFIG="overlay-shell.conf"
west sign -t imgtool -- --key path\to\your\mcuboot\signing-key\root-rsa-2048.pem
west flash
That image will respond to echo commands without any modifications. With the tweak to send an empty map instead of an empty payload in the image state command, it responds as expected. I was able to upload an image, mark it for test, manually reset to install it (maybe the mcumgr reset command would have sufficed; I got impatient) and confirm it after it swapped the slots.
First off, this is an awesome project! We're going to try it with a Zephyr-based project.
Have you looked at supporting WebUSB, Web Serial and/or WebHID? That would expand the utility of this library to devices that don't have BT connectivity.