radxa / meta-radxa

OpenEmbedded BSP Layer for the Radxa boards
GNU Lesser General Public License v3.0
9 stars 18 forks source link

I2C problems #21

Open WalterPrech opened 2 years ago

WalterPrech commented 2 years ago

I followed the instructions to build a yocto dunfell image for a Rockchip Pi 4b.

I build a console image ~/yocto/poky/build $ bitbake -k radxa-console-image

Testing i2c without connecting any i2c slaves get the following results:

i2cdetect -l  
i2c-0   i2c         rk3x-i2c                            I2C adapter
i2c-1   i2c         rk3x-i2c                            I2C adapter
i2c-9   i2c         DesignWare HDMI                     I2C adapter

i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: UU UU -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: 50 51 52 53 54 55 56 57 -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --  

i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- UU -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --

i2cdetect -y 9
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: 30 -- -- -- -- -- -- 37 -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --

If I connect some i2c-slaves, the result is exactly the same.

The i2c-address 0x18 should be shown for the connected sensor.

What's going wrong? Do I have to activate some settings and if yes where?

jack-ma commented 2 years ago

What sensor are you connecting and which pins on ROCK Pi do you connect? I suspect it's the voltage level issue.

WalterPrech commented 2 years ago

I use the "blue" pins (pin 27 and 28).

In the meanwhile I figured out, that there were no overlays and no hw_intfc.conf file created in the build. And so no i2c was enabled.

I make a patch to rk3399-rock-pi-4.dtsi and added:

+&i2c2 {
+        clock-frequency = <400000>;
+        i2c-scl-rising-time-ns = <168>;
+        i2c-scl-falling-time-ns = <4>;
+        status = "okay";
+};

Now I can attach i2c-2 and get the sensors data.

Also it's a problem, that LINUX_VERSION = "4.4.154" is used. This should be 5.10 or higher.