/dev/i2c interface not accessible


I am using a Verdin imx8mplus with Dahlia with Torizon vscode extension.

I am trying to write and read to onboard EEPROM via I2C interface as per the following instructions.


Setup the container as per the instructions here for user-space container access :

Tried the following as per the output from the command: ls -l /dev/i2c-*


However with all these options, I am not either getting errno 1: Operation not permitted or errno 2: No such file or operation.

Sample code:
snprintf(filename, 19, “/dev/i2c-%d”, adapter_nr);
file = open(filename, O_RDWR);
if (file < 0) {
/* ERROR HANDLING; you can check errno to see what went wrong */

Greetings @SJ_BHD,

As per the error message it appears either the device file doesn’t exist in the container or you’re running into a permission error.

If it’s the first case, then can you confirm whether you’re adding relevant /dev/i2c* device file to the container so that the container can access it.

If it’s the second case then can you confirm that you’re adding the torizon user inside the container to the i2cdev user group for permission access.

Best Regards,

Hello @jeremias.tx ,

Apologies, I was using the volume option instead of the device option.

I have added the following devices.

For the buildcommands property:
RUN usermod -a -G i2cdev torizon

See attached screenshot for configuration page.

However, I am still an IOCTL issue when trying to access the EEPROM at the address 0x57 as noted in the Dahlia datasheet.

The error is noted in the terminal tab for VSCode as follows:
Errno: 16
Error Message for IOCTL operation: Device or resource busy
Child exited with status 1
IOCTL error

See code snippet:
int addr = 0x57; /* The I2C address for the EEPROM from datasheet of the Dahlia */

if (ioctl(file, I2C_SLAVE, addr) < 0) {
printf(“Errno: %d \n”,errno);
printf(“Error Message for IOCTL operation: %s\n”,strerror(errno));
printf(“IOCTL error”);

How can we get rid of the IOCTL error?

Hi @SJ_BHD ,

We would like to ask a couple of questions.

  • What is the version of the Verdin module you’re using?
  • What is the version of the Dahlia board?
  • How is the EEPROM hooked up? Did you change anything on the Dahlia board?
  • Which I2C interface are you using for your tests?
  • If possible please share the output of i2cdetect -y -r <index>. So for example i2cdetect -y -r 0 to read from i2c 0.

Have a great day!

Best Regards

Hello @SJ_BHD ,
We haven’t received any feedback from you. Were you able to solve your issue?

Best regards,

Tried using I2C_SLAVE_FORCE and it seems to work, although it may not be recommended.


Could you please share more information/context about your solution?

Some reference to the I2C_SLAVE_FORCE would be nice, as well as how you applied it :slight_smile:

Best regards,

In the same code as above in ioctl, substituted I2C_SLAVE for I2C_SLAVE_FORCE.

Hi @SJ_BHD !

Thanks for the reply.

If your initial issue is solved, please mark the most suitable message as the solution :slight_smile:

Best regards,


Dont think it is a solution, but a temporary workaround.
See link below:

I2C_SLAVE_FORCE is used when device is being managed by kernel driver.

How can I disable this kernel drive so that I can just use I2C_SLAVE in ioctl, or what are the methods for this driver that I can call instead of ioctl?

Hi @SJ_BHD !

Have you configured your device tree accordingly to use your I2C device?

Also, if you explain what you are trying to accomplish, we can better help you. I understand you want to read from an EEPROM. But are you using some kind of Linux driver for this device (configured in the device tree) or do you want to read it “manually” from your application?

You can add some I2C tools to your container to check the I2C bus. Some tools are referenced in the following article:

Best regards,

Hi @SJ_BHD !

Did you have time to go through my previous questions?

Do you have any updates regarding this topic?

Let us know :slight_smile:

Best regards,