Configuring docker cgroup rules or --privileged in VS Code Torizon extension

Hi,

I am writing a C++ application using libusb in VS Code with TorizonCore Early Access Extension, starting from the C/C++ Makefile template (without Qt).

Libusb is able to access the hardware if I manually run the application the container as root, or with --privileged within the container, via SSH, outside of VSCode. But I am not able to set --privileged or cgroup rules in VS Code debug mode. I think some group rules or other permission are needed by libusb.

How can I add --privileged or other options to the execution of the docker for step-by-step debugging in VS Code TorizonCore extension?

Thank you all for the help and best regards,

ldvp

Greetings @ldvp,

You can add any arbitrary docker run parameter via the extraparms setting in the configuration window. However the syntax for this isn’t well documented yet but we’re working on that.

In short extraparms takes a key/value pair and the syntax needs to match the python API as specified here: Containers — Docker SDK for Python 6.0.1 documentation

For example to add --privileged you want the following syntax according to the above link:
key: privileged
value: True

Then for cgroups something like this: (these values aren’t for USB)
key: device_cgroup_rules
value: [ "c 199:* rmw" , "c 226:* rmw" ]

We’re working on better documenting and simplifying this but for the time being this is how it works.

Best Regards,
Jeremias

Dear @jeremias.tx,
thank you for the answer, I have just tried following your instructions and privileged option worked.
All the best,
ldvp

Glad to help!