Hotplugging in USB passtru mode


In order to faciliate programming a TM4C123 development board, from a lxd container, I have done the following:

My configuration:

productid: 00fd
type: usb
vendorid: 1cbe

In my host computers /etc/udev/rules.d/71-lxd-ti.rules
ATTRS{idVendor}==“1cbe”, ATTRS{idProduct}==“00fd”, GROUP=“users”, MODE=“0666”

If the development board is plugged in before the container starts, the above configuration works and lm4flash program can access the development board.

Found ICDI device with serial: 0E20E60E
ICDI version: 9270

But however, if you unplug and plug back the dev board, or reset it:

Unable to open USB device: LIBUSB_ERROR_ACCESS
Unable to find any ICDI devices

It seems that naturally, the device is registered when the container starts, and then accessible tru the container. In hardware development, there is a lot of plugging and unplugging and swapping boards, etc, so I kind of need it.

Is there any way I can go around this issue?

Also, when we define permissions of a device in the host computer’s udev/rules.d - and lxc accesses this device, which uid does it access as? Usually this device has 660 permissions, and the user has to be a member of dialout and plugdev. But I understand lxd will be accessing this device, so it is lxd’s uid?

would it help to list the rules file in the containers /etc/udev/rules.d ?

Best regards,

You can directly set mode on the usb device in LXD so that those permissions are applied inside the container.

LXD listens for USB events and should remove and add back the device as it’s plugged in and out.

Hello @stgraber:

" You can directly set mode on the usb device in LXD so that those permissions are applied inside the container." I did not entirely this one. Do you mean set uid,gid,mode while doing the lxc config device add …?

If I remove and add back the device config, it does work. But here: - it claims as if it will automatically hotplug.

Best Regards,

Yes, you can set uid, gid, mode, … during lxc config device add or after the fact by editing the config with lxc config edit.

yes, I have deleted the files under /etc/udev/rules.d, and instead I added the device with uid=1000 gid=100 mode=0666 and now it works as hotplug. thank you.

1 Like