Peripheral permission via VSCODE

My Setup-
OS - Torizon OS BSP 6
SoM - Verdin IMX8P
Torizon IDE Ext - version 2.4.2

I have to gain access to the i2c device, can someone point me to some documentation on this. I think it’s in the docker-compose.yml, but not sure if I have to edit another file besides the docker compose

Hi, I’m the Toradex AI Assistant. I’m in early beta, and I would appreciate your feedback.
The Toradex Support team will follow up with you shortly!


I see you’re looking to access an I2C device from a container in Torizon OS using VS Code with the Torizon IDE Extension.

To access I2C devices within a Docker container on Torizon, you indeed need to modify the docker-compose.yml file to grant the container access to the I2C device. Here’s a general approach to achieve this:

  1. Identify the I2C Device: First, you need to identify the I2C device file you want to access. This can typically be found under /dev/i2c-X, where X is the number of the I2C bus. You can list all I2C devices available on your system by running i2cdetect -l in the terminal on your Torizon device.

  2. Modify docker-compose.yml: In your docker-compose.yml file, you will need to add a devices section under the service that requires access to the I2C device. For example, if your I2C device is /dev/i2c-1, you would add something like this to your service configuration:

      - "/dev/i2c-1:/dev/i2c-1"

This configuration maps the I2C device from the host (left side of the colon) to the container (right side of the colon), allowing your application inside the container to access it as if it were running directly on the host.

  1. Set Appropriate Permissions: Depending on your container’s user configuration, you might also need to ensure that the user inside the container has the necessary permissions to access the I2C device. This can involve setting the user to root or adjusting the device’s permissions on the host to allow access by non-root users.

  2. Re-deploy Your Container: After making these changes, you’ll need to redeploy your container. This can typically be done from VS Code with the Torizon IDE Extension by rebuilding and redeploying your application.

Remember, the exact steps might vary based on your specific setup and the device you are trying to access. This approach should guide you in the right direction for accessing I2C devices from within a Docker container on Torizon OS.

Best regards,
Toradex AI Assistant

Please, also check if these links can help you solve your problem:

How to Use GPIO on Torizon OS | Toradex Developer Center.

How did you like my response?

:+1: :-1:

Greetings @jeffbelz,

In addition to what the ToradexAI bot has stated, we have an article on i2c access: How to use I²C on Torizon OS | Toradex Developer Center

We also have a more practical example of using an i2c device here: torizon-samples/sht31 at bookworm · toradex/torizon-samples · GitHub

You can see the provided docker-compose.yml files in this sample for a reference.

Best Regards,