LeFish
March 21, 2024, 8:43pm
1
Hi all,
after years of very successfully using DietPi on RaspberryPi (RPi) I would like to switch to the NanoPi R4S for my next project.
I need to use the I2C Bus for this project.
My I2C-Device (LM75 Temperature Sensor - 0x48h expected) is working on a DietPi-image for RPi:
dietpi@dietpi:~$ sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
But on the NanoPiR4S-image I do not get any feasible results:
dietpi@DietPiTBK:~$ ls /dev/ | grep i2c
i2c-0
i2c-1
i2c-2
i2c-7
dietpi@DietPiTBK:~$ sudo 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: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
dietpi@DietPiTBK:~$ sudo 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: -- -- -- -- -- -- -- --
dietpi@DietPiTBK:~$ sudo i2cdetect -y 2
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
dietpi@DietPiTBK:~$ sudo i2cdetect -y 7
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: 08 09 0a 0b 0c 0d 0e 0f
10: 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f
20: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f
30: -- -- -- -- -- -- -- -- 38 39 3a 3b 3c 3d 3e 3f
40: 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f
70: 70 71 72 73 74 75 76 77
As from schematics and hardware-docs I expect to be I2C Bus: 3 to be the correct one:
HardwareSpecs
Schematics - Full Schematic
After searching these forums I added i2c3
to the overlays=
line in /boot/dietpiEnv.txt
(https://dietpi.com/forum/t/nanopi-neo-i2c-enable-how-to/15700 without any success.
Do you see any possibilities in supporting I2C on Rockchip NanoPi devices in near future?
I will test I2C support on official FriendlyElec-Images and will report back.
Thanks!
Best regards
LeFish
maybe @MichaIng has an idea
There are overlays to enabled I2C 7 and I2C 8, but indeed they have been prefixed to be more SoC-specific (which is generally a good thing). Please try to use rk3399-i2c7
and or rk3399-i2c8
in the overlays
line. Through I2C 7 seems to be enabled already.
From the /boot/dtb/rockchip/overlays/README.rockchip-overlays
:
### i2c7
Activates TWI/I2C bus 7
I2C7 pins (SCL, SDA): GPIO2-B0, GPIO2-A7 GPIO1-C5, GPIO1-C4
### i2c8
Activates TWI/I2C bus 8
I2C8 pins (SCL, SDA): GPIO1-C5, GPIO1-C4
The prefixes are missing there.
Not sure about bus 3, there is not and never has been an overlay to enable it. I see it in the board schematics, though. I am currently on a conference at Orange Pi, so do not have much time. We can try to find some information and see whether we can derive from the other overlays how to enable I2C 3 (and maybe even I2C 4) on the intended pins/GPIOs from the board schematics with a custom overlay.
LeFish
March 23, 2024, 8:56pm
4
Hi @MichaIng ,
thank you for your reply.
I downloaded FriendlyElec images from
FriendlyElec-R4S_GDrive_SDImages
On rk3399-sd-debian-bullseye-core-6.1-arm64-20230928.img.gz
the very same i2c buses as on the current DietPi image are enabled:
pi@NanoPi-R4S:~$ ls /dev/ | grep i2c
i2c-0
i2c-1
i2c-2
i2c-7
The same applies for the “original” FriendlyElec FriendlyWRT-Image (based on OpenWRT):
Using username "root".
___ _ _ _ __ __ _
| __| _(_)___ _ _ __| | |_ \ \ / / _| |_
| _| '_| / -_) ' \/ _` | | || \ \/\/ / '_| _|
|_||_| |_\___|_||_\__,_|_|\_, |\_/\_/|_| \__|
|__/
-----------------------------------------------------
FriendlyWrt 23.05.2, r23630-842932a63d
-----------------------------------------------------
root@FriendlyWrt:~# ls /dev | grep i2c
i2c-0
i2c-1
i2c-2
i2c-7
root@FriendlyWrt:~#
To be honest, I doubt to try any further image makes sense…
Regarding I2C:7 and I2C:8
I2C Bus 8 is not routed anywhere:
I2C-Bus:8(Schematic)
Therefore, I honestly doubt there is any sense in trying to activate this overlay.
Also, I2C-Bus:7’s readout is returning rubbish imho. It does not seem to be routed anywhere:
I2C-Bus:7(Schematic)
Best regards
LeFish
LeFish
March 24, 2024, 7:05pm
5
Hi @MichaIng ,
hurrah, I solved it:
root@DietPi:~# ls /dev/ | grep i2c
i2c-0
i2c-1
i2c-2
i2c-3
i2c-7
root@DietPi:~# i2cdetect -y 3
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
root@DietPi:~#
This is how I went about it:
Prerequisite is to install device-tree-compiler
root@DietPi:/boot/dtb# cd /boot/dtb/rockchip/overlay/
root@DietPi:/boot/dtb/rockchip/overlay# cat rockchip-rk3399-i2c3.dts
/dts-v1/;
/plugin/;
/ {
metadata {
title = "Enable i2c3 on NanoPiR4s";
compatible = "rockchip,rk3399";
category = "misc";
description = "Enable NanoPiR4s i2c3";
};
fragment@0 {
target = <&i2c3>;
__overlay__ {
status = "okay";
};
};
};
root@DietPi:/boot/dtb/rockchip/overlay# sudo dtc -O dtb -o rockchip-rk3399-i2c3.dtbo rockchip-rk3399-i2c3.dts
root@DietPi:/boot/dtb/rockchip/overlay# sudo chmod +x rockchip-rk3399-i2c3.dtbo
Finally add rk3399-i2c3
to the file /boot/dietpiEnv.txt
in the overlays=
line.
Relevant ressources:
(1) https://wiki.radxa.com/Rockpi4/dev/use-rsetup-to-enable-common-interface-with-kernel-5.10#i2c2
(2) https://github.com/MichaIng/DietPi/discussions/6229
(3) cross compiling - How to compile dts Linux device tree source files to dtb? - Stack Overflow
Would you kindly add the overlay permanent to DietPi:NanoPiR4s? I uploaded it to WeTransfer
Thank you!
Best regards
LeFish
2 Likes
I’ll open a PR at Armbian in the hope it gets accepted for their kernel builds.
system
Closed
June 25, 2024, 10:10am
7
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.