I2C nightmares with imx8x, I2C detect can't find the bus

Hi there,

We are still setting this up for the first time. The Torizon loaded up quickly and easily, docker and portainer are working well, we even have migrated to Microsoft from Eclipse which is something I didn’t ever think I would do.

However, we have something really fundamental to sort out and its been a day of struggle so far.

We have the imx8x 2gb and the evaluation board.

There are a pair of I2C busses to use on the evaluation board: bus 16 and 17 according to I2C (Linux) | Toradex Developer Center.

So we want to bring up my devices (one is an SMBUS battery, one is a slave i2c device) and in the process, I wanted to see if we can see the device addresses on each bus.

The imx8x and colibri board has other ideas…

I wanted to use i2cdetect but torizoncore does not have this command, or even apt so it can be installed, so I need Debian via docker.

So I log in via ssh to the terminal, and run: “docker run --rm -it -v /var/run/dbus:/var/run/dbus -v /dev:/dev torizon/debian:$CT_TAG_DEBIAN bash”

Then I update with

apt updateroot@d152fd90ba33:/# “apt update”

Then I get the i2cdetect tool with “apt install libi2c-dev i2c-tools”.

Once all that is installed we can do the i2cdetect command: “i2cdetect -l”

The result is

i2c-17 unknown 5a810000.i2c N/A
i2c-16 unknown 5a800000.i2c N/A

unknown device and N/A bus…

It’s clear that the i2c just hasn’t been brought up, I had a look at /proc/modules and sure enough, there is no mention of the i2c module.

“i2cdetect -y -r 17” (its bus 17)

Error: Could not open file `/dev/i2c-17’: Operation not permitted

Now there is no modprobe command to manually load the i2c module up, lsmod also missing (but it’s fine as this is just formatting the /proc/modules file)

root@d152fd90ba33:/# modprobe bash: modprobe: command not found root@d152fd90ba33:/#

So how do I set this up so the i2c modules are loaded up, and the I2C into user space so I can just check to make sure my device addresses register on the busses?

i would expect a result from i2cdetect like:

i2c-17 i2c 5a810000.i2c i2c-17
i2c-16 i2c 5a800000.i2c i2c-16

How do i fix?

I think this can’t be done in the userspace, so I guess it’s down to working with the TorizonCore Builder?
But I looked around and there are no examples where the I2C’s are enabled for this system

Where should I go next to try?

Greetings @FatLinux,

The issue here is that the permissions to access i2c aren’t being properly given to the container. Remember containers are mostly isolated from the underlying OS. For things like hardware peripherals, explicit access needs to be given on a per-container basis. Luckily it’s fairly easy to give access and just involves adding some flags to the docker run command.

See this section of i2c on torizon article about how to do this:How to use I2C on Torizon | Toradex Developer Center

Just to confirm I tried the above article and got the following results in the container:

root@6d6d8829c524:/# i2cdetect -l
i2c-17  i2c             5a810000.i2c                            I2C adapter
i2c-16  i2c             5a800000.i2c                            I2C adapter
root@6d6d8829c524:/# i2cdetect -y -r 17
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- 4a -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

Best Regards,
Jeremias

Thank you for your help.

I didn’t see that flag --privileged on the run docker did the trick.

You are welcome.