Enabling USB passthrough to Android container

Greetings everyone,

My question is very straightforward, bordering on trivial, as it pertains to the Android container in Sailfish OS X. If I remember correctly, the Android container is implemented as an LXC container. On Linux systems, it is possible to passthrough a USB device by using the mount --bind command, but a better way to achieve this is with an OverlayFS command such as:


mount -t overlay overlay -o lowerdir=/var/lib/lxc/container/rootfs,upperdir=/host/overlay,workdir=/host/work /var/lib/lxc/container/rootfs

As such, my question is: Can a similar mount be performed in SFOS? To be honest, I have been trying, but have not found the required paths.

Moreover, if we want to fully passthrough a USB device to the LXC container, one possible workaround is the following:

  1. Identify the USB Device: Find the right device node, for example, /dev/bus/usb/001/002.

  2. Modify the Container Configuration: Change the container’s configuration file so that device passthrough is enabled. For example, include the following line:

lxc.cgroup.devices.allow = c 189:* rwm  

lxc.mount.entry = /dev/bus/usb/001/002 dev/bus/usb/001/002 none bind,optional,create=file  

This means that the container is granted access to the device and the mount is performed inside the container.

  1. Restart or Update the Container: If possible, try to use these changes at runtime, or restart the container.

This approach ensures the container has direct access to the USB device, which could be a key step in enabling Android Auto functionality in my car.

Thanks in advance for your help!

1 Like

My layman’s opinion is the device would have to be present before you start Appsupport.

Also where and how did you implement these changes and were they reflected in the journal (you need to keep monitoring the journal, SFOS does not store it by default)?

1 Like

Well, it seems like I was attempting something that’s either impossible or doesn’t work that way. Unfortunately, I’m unable to provide detailed logs at the moment.

Regarding the second method I mentioned, which typically works in more standard Linux distributions and doesn’t require restarting the Android subsystem if configured before its startup:

Sailfish OS doesn’t seem to have any devices under /dev/bus/usb, and I haven’t been able to locate where USB devices are managed. Mobile Linux can indeed be quite a mysterious world.

If anyone has insights on how to access USB devices in Sailfish OS or how to correctly set up passthrough to the Android LXC container, I’d greatly appreciate the advice.

Thanks.

On my 10 II currently connect to a laptop:

devel-su find /dev -iname '*usb*'
/dev/at_usb1
/dev/at_usb0
/dev/usb_accessory
/dev/mtp_usb
/dev/usb-ffs
/dev/bus/usb
/dev/__properties__/u:object_r:vendor_usb_prop:s0
/dev/__properties__/u:object_r:vendor_usb_config_prop:s0
/dev/usbmon0