im-tomu / fomu-workshop

Support files for participating in a Fomu workshop
https://workshop.fomu.im
Apache License 2.0
162 stars 64 forks source link

Micropython demo functionally unusable on Chrome OS via Crostini #18

Open mitchellharper12 opened 5 years ago

mitchellharper12 commented 5 years ago

Due to a (probable) bug in Chrome OS USB device handling, there is a crossvm state machine issue that prevents the fomu serial console from being usable after DFU flashing the micropython demo binary.

This issue is currently being tracked at https://bugs.chromium.org/p/chromium/issues/detail?id=996197

mitchellharper12 commented 5 years ago

I am on day 2 of trying to set up a reliable DFU toolchain on Chrome OS.

As per this comment, there is a "don't let users shoot themselves in the foot using this beta functionality"[1] whitelist of USB vendors that can be passed through to the VM as a serial device. Arduino is one of those. I attempted to use the DFU binary tools on the the micropython-fomu.dfu image to swap out the vendor ID for the whitelisted one, but ran into segfaults in the included static builds. I rebuilt dfu-utils from source and attempted to use them (but still ran into segfaults). Except when run under lldb where everything worked fine. Also was able to swap out the device ID in a different part of the image for good measure. Flashed the image, got the chance to use a serial console, poked the LED memory a bit, and restarted the fomu.

When the device came back up, it still had the Arduino vendor ID but in DFU mode. Which confused the heck out of some part of the usb integration stack. So from my device, the fomu is essentially unrecoverable, and I might need to drop by the hardware village to get it into a flashing harness.

It goes without saying I do not recommend attempting to get around the whitelisting by swapping the vendor ID for a whitelisted one. I am currently downloading the chromium tree(s) and build tools to attempt to rebuild the permissions broker because I also cannot hit the serial console on my conference badge due to the vendor whitelist.

[1] Attaching a remote sim that exposed itself over USB as a serial console to a low privileged VM would be a bad idea, for example

mitchellharper12 commented 5 years ago

So it turns out if you reboot Chrome OS, and unplug the fomu and reinsert, it comes back with the 1209 vendor ID. Which means I have a not entirely braindead flashing chain via byteswaps that at least allows the micropython demo to work. All the other demos that don't require serial console access seem to work as expected.

Still trying to work on swapping out the permissions broker for a longer-term fix, but also can file a PR with either instructions and/or the swapped binary micropython image if desired to give anyone working on a chromebook at some point in the future.

mitchellharper12 commented 5 years ago

I am abandoning hope of using Crostini until the time Chrome team lands a change to the device handling stack.

The toolchain works fine by default on Crouton (but that requires entering dev mode). Planning on writing up some small notes on that for future workshop participants.