Finally I found a solution!!!!
No building custom modules is needed, only stock kernel configuration.
Here the trick is that the I2c used bus IS NOT THE STANDARD ONE (i.e. usually con Raspberry the I2c bus is on GPIO 2 and GPIO 3, which on Kunbus are used for other pourpose).
The GPIO where the RTC is attached are the GPIO 44 and GPIO 45, you could check on the provided schematic and you could even see that there are the two pull up resistors needed by the bus to properly work.
That was the difficult thing to spot, as soon as I have understood that I have decided to configure a second I2c bus and let the RTC driver use that.
- Configure the Tree Overlay
I have added these two lines to
:
Code: Select all
dtoverlay=i2c-gpio,i2c_gpio_sda=44,i2c_gpio_scl=45,bus=2
dtoverlay=i2c-rtc,pcf2129
The first one configure the second I2c bus and assign the correct 2 GPIO, the second one ask to the kernel to use the driver for the pcf2129 for RTC.
- Create a Service for Systemd
In the service you have to create a new device when the system start up:
Code: Select all
[Unit]
Description=RTC configuration for pcf2129
[Service]
ExecStart=/usr/local/bin/configrtc.sh
[Install]
WantedBy=multi-user.target
This is the script used in the service:
Code: Select all
#!/bin/bash
echo pca2129 0x51 > /sys/class/i2c-dev/i2c-2/device/new_device
sleep 0.5
hwclock -s || hwclock -w
In this way I have the RTC device working at startup every time with my Ubuntu Server 22.04.
Code: Select all
root@kunbus02:~# 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: -- 51 -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: 60 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
Hope that this little tutorial could be of some help to some other users.
Regards,
S.