Problem
A raspberry pi 3 running a Balena OS variant balenalib/rpi-raspbian
generates two i2c adapters. When you use the i2c-tools
package to analyze the bus via i2cdetect -y 1
, you can find devices on port 1. If you then perform i2cdetect -y 3
on the 3rd port, the same devices appeared. Then running i2cdetect -y 1
on the 1st port again is slow and yields 0 devices. I am super confused, this does not occur on the official raspberry pi OS since there is only one i2c adapter on port 1 which is thebcm2835
interface.
Steps
FROM balenalib/rpi-raspbian
RUN apt-get update && apt-get install -y i2c-tools
RUN modprobe i2c-dev
# ...
Start the container.
ssh into the running container
i2cdetect -l
i2c-3 i2c ffffffff.i2c I2C adapter
i2c-1 i2c bcm2835 I2C adapter I2C adapter
When you specify port 1 first:
root@41e310d:/usr/src/app# i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: 10 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: 20 21 22 23 -- -- -- -- -- -- -- -- -- -- -- --
30: 30 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- 44 -- -- -- 48 -- -- -- -- -- -- --
50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- 63 64 -- -- -- 68 -- 6a -- -- -- 6e --
70: -- -- -- -- -- -- -- --
Then port 3:
root@41e310d:/usr/src/app# i2cdetect -y 3
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: 10 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: 20 21 22 23 -- -- -- -- -- -- -- -- -- -- -- --
30: 30 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- 44 -- -- -- 48 -- -- -- -- -- -- --
50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- 63 64 -- -- -- 68 -- 6a -- -- -- 6e --
70: -- -- -- -- -- -- -- --
Then go back to port 1, i2cdetect is slow and every device has disappeared
root@41e310d:/usr/src/app# i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
Note I tried this on a Pi 4 as well:
root@e8d3c87:/usr/src/app# i2cdetect -l
i2c-1 i2c bcm2835 (i2c@7e804000) I2C adapter
i2c-11 i2c ffffffff00000002.i2c I2C adapter
And i2c-detect -y 1
resulted in 0 devices from the get go but the expected devices appeared on port 11. This again is very different behavior than the original Raspberry pi OS