How to access USB with Torizon Visual Code Extension (python)

in my situation, on my Colibri, I have a USB-to-Serial device (/dev/ttyUSB0) and a flash drive (/dev/sda) that can be plugged into 2 separate USB connectors at any time.

If these USB devices can be plugged in and removed at any time then you need to use something called bind-mount propagation: Bind mounts | Docker Docs

This should allow changes in bind-mounts to be propagated to the container. For example when you plug your flash drive in it creates in /dev/sda entry. With Bind mount propagation this change in /dev should transfer into the container.

This post has an example of how you would configure this in the extension: Configuring docker dynamic USB memory access with --mount option in VS Code Torizon Extension

I reviewed the torizon best practices guide and unfortunately I’m still uncertain about mounting the /dev folder as a volume.

Could you clarify why you are uncertain? If you need /dev/ttyUSB0 inside the container then you need to bind mount this from the host. But since you just stated these USB devices can be plugged at any time and therefore may not be available at container start time you need to then bind-mount all of /dev and propagate the changes with bind mount propagation.

Maybe it’s simpler to just experiment with docker run on the command-line and figure out what arguments and flags you need for the bind-mounts to fit your use-case. Then when you figure out the correct flags you can transfer this into the extension.

Best Regards,
Jeremias