Missing Kernal I2C bits needed for Odroid C2 RTC PCF8563 RTC Shield REV 0.1

Creating a bug report/issue

Required Information

  • DietPi version | cat /boot/dietpi/.version
    G_DIETPI_VERSION_CORE=8
    G_DIETPI_VERSION_SUB=13
    G_DIETPI_VERSION_RC=2
    G_GITBRANCH=‘master’
    G_GITOWNER=‘MichaIng’
    G_LIVE_PATCH_STATUS[0]=‘applied’
    G_LIVE_PATCH_STATUS[1]=‘not applicable’

  • Distro version | echo $G_DISTRO_NAME $G_RASPBIAN
    bullseye

  • Kernel version | uname -a
    Linux DietPi 6.0.13-meson64 #22.11.2 SMP PREEMPT Sun Dec 18 16:52:19 CET 2022 aarch64 GNU/Linux

  • SBC model | echo $G_HW_MODEL_NAME or (EG: RPi3)
    Odroid C2 (aarch64)

  • Power supply used | (EG: 5V 1A RAVpower)
    5V 2A

  • SD card used | (EG: SanDisk ultra)
    eMMC

Additional Information (if applicable)

https://wiki.odroid.com/accessory/add-on_boards/rtc_shield

Steps to reproduce

rtc_pcf8563 and aml_i2c both installed and running

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

i2cdetect returns module rtc_pcf8563 24576 0
but aml_i2c module is not listed so I have no way to update the time on the RTC module

Extra details

It looks like the aml_i2c module is not loaded in the kernel on my system. It’s possible that it’s not built into the kernel image or that it’s not being loaded automatically at boot? I tried “modprobe aml_i2c” to see if it’s available on the system, it returns:

modprobe: FATAL: Module aml_i2c not found in directory /lib/modules/6.0.13-meson64

just to avoid a misunderstanding. We as DietPi project don’t compile own kernel version.

Maybe @MichaIng has an idea what could be missing.

That is disheartening news, Joulinar; I haven’t had any luck getting issues addressed with Armbian. Unless you are willing to pay them $3k and become a ‘gold member.’

yes we know that behaviour, but we are simply not able to maintain own kernel builds as the DietPi project has a single main developer and some volunteer assisting on the forum or maintaining other stuf like web side or blog.

1 Like

aml_i2c is a vendor module, not a standard Linux module, so it does not exist in mainline kernel. There you usually enable device tree overlays to have optional hardware features enabled the related kernel modules loaded automatically (/etc/modules is basically deprecated).

But I think the related I2C bus is enabled already. Can you check:

ls -l /dev/i2c*
find /proc/device-tree/ -type d -name '*i2c*' -exec ls -l {}/status \; -exec cat {}/status \; -exec echo \; 2> /dev/null

Here is what I get Michael:

root@DietPi:~# ls -l /dev/i2c*
find /proc/device-tree/ -type d -name '*i2c*' -exec ls -l {}/status \; -exec cat {}/status \; -exec echo \; 2> /dev/null
crw-rw---- 1 root i2c 89, 0 Feb  1 06:21 /dev/i2c-0
crw-rw---- 1 root i2c 89, 1 Feb  1 06:21 /dev/i2c-1
-r--r--r-- 1 root root 9 Feb  1 07:26 /proc/device-tree/soc/bus@c8100000/i2c@500/status
disabled
-r--r--r-- 1 root root 5 Feb  1 07:26 /proc/device-tree/soc/bus@c1100000/i2c@8500/status
okay
-r--r--r-- 1 root root 9 Feb  1 07:26 /proc/device-tree/soc/bus@c1100000/i2c@87e0/status
disabled
-r--r--r-- 1 root root 9 Feb  1 07:26 /proc/device-tree/soc/bus@c1100000/i2c@87c0/status
disabled
root@DietPi:~# find / -name "*i2c*dts"
find: ‘/proc/6070’: No such file or directory
find: ‘/proc/6071’: No such file or directory
find: ‘/proc/6072’: No such file or directory
find: ‘/proc/6073’: No such file or directory
find: ‘/proc/6074’: No such file or directory
find: ‘/proc/6076’: No such file or directory
find: ‘/mnt/USB’: No such device
root@DietPi:~# 

Makes me wonder if you should pull down the WiringPi GPIO interface library (C) if it will not work on this kernel @MichaIng and @Joulinar?

Okay, so one of the buses is enabled, three more are available but disabled.

Can you try to add i2cA i2cB to the overlays= line in /boot/dietpiEnv.txt, so that it looks like:

overlays=i2cA i2cB

and repeat

find /proc/device-tree/ -type d -name '*i2c*' -exec ls -l {}/status \; -exec cat {}/status \; -exec echo \; 2> /dev/null

and in case i2cdetect to see whether one of the two overlays enabled the required bits already?

Actually the one that is enabled already looks closest to the /i2c@c1108500/pcf8563@51 one from the Odroid wiki, but lets see.

@MichaIng After updating /boot/dietpiEnv.txt to:

rootfstype=ext4
# The init system logs to the console defined last.
consoleargs=console=tty1 console=ttyAML0,115200 console=ttyS1,115200 console=ttyS2,115200 console=ttyS3,115200 console=ttyS4,115200 console=ttyS5,115200 console=ttyS6,115200 console=ttyS7,115200 console=ttyS0,115200
verbosity=4
usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u
extraargs=net.ifnames=0 video=HDMI-A-1:1280x390
docker_optimizations=off
overlays=i2cA i2cB

Here are the results:

root@DietPi:~# i2cdetect -l
i2c-1   i2c             Meson I2C adapter                       I2C adapter
i2c-2   i2c             DesignWare HDMI                         I2C adapter
i2c-0   i2c             Meson I2C adapter                       I2C adapter
root@DietPi:~# find /proc/device-tree/ -type d -name '*i2c*' -exec ls -l {}/status \; -exec cat {}/status \; -exec echo \; 2> /dev/null
-r--r--r-- 1 root root 9 Feb  6 13:13 /proc/device-tree/soc/bus@c8100000/i2c@500/status
disabled
-r--r--r-- 1 root root 5 Feb  6 13:13 /proc/device-tree/soc/bus@c1100000/i2c@8500/status
okay
-r--r--r-- 1 root root 9 Feb  6 13:13 /proc/device-tree/soc/bus@c1100000/i2c@87e0/status
disabled
-r--r--r-- 1 root root 5 Feb  6 13:13 /proc/device-tree/soc/bus@c1100000/i2c@87c0/status
okay
root@DietPi:~# i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: 20 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
root@DietPi:~# 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: -- -- -- -- -- -- -- --                         
root@DietPi:~# i2cdetect -y 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: 30 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
root@DietPi:~# 

Where are the device tree files located in DietPi? Maybe we can fdtput -t s /path/to/device-tree-file.dtb /path/to/i2c/node status "okay"

Also, I am using the RTC and UPS3 at the same time but they appear to use different pins: ODROID-C2, RTC shield & UPS3 - ODROID

@MichaIng I seem to have cleared up the duplicate I2C but still no joy

root@DietPi:~# i2cdetect -l
i2c-1   i2c             DesignWare HDMI                         I2C adapter
i2c-0   i2c             Meson I2C adapter                       I2C adapter
root@DietPi:~# find /proc/device-tree/ -type d -name '*i2c*' -exec ls -l {}/status \; -exec cat {}/status \; -exec echo \; 2> /dev/null
-r--r--r-- 1 root root 9 Feb  8 16:45 /proc/device-tree/soc/bus@c8100000/i2c@500/status
disabled
-r--r--r-- 1 root root 5 Feb  8 16:45 /proc/device-tree/soc/bus@c1100000/i2c@8500/status
okay
-r--r--r-- 1 root root 9 Feb  8 16:45 /proc/device-tree/soc/bus@c1100000/i2c@87e0/status
disabled
-r--r--r-- 1 root root 9 Feb  8 16:45 /proc/device-tree/soc/bus@c1100000/i2c@87c0/status
disabled
root@DietPi:~# i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- 4d -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
root@DietPi:~# i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: 30 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
root@DietPi:~# 

Although I may have found the problem, see this:

root@DietPi:~# sudo apt install device-tree-compiler
sudo fdtput -t s /media/boot/meson64_odroidc2.dtb /i2c@c1108500/pcf8563@51 status "okay"
echo "aml_i2c"|sudo tee -a /etc/modules
echo "rtc_pcf8563"|sudo tee -a /etc/modules
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
device-tree-compiler is already the newest version (1.6.0-1).
0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.
Couldn't open blob from '/media/boot/meson64_odroidc2.dtb': No such file or directory
aml_i2c
rtc_pcf8563
root@DietPi:~# sudo apt install device-tree-compiler
sudo fdtput -t s /media/boot/meson64_odroidc2.dtb /i2c@c1108500/pcf8563@51 status "okay"
echo "aml_i2c"|sudo tee -a /etc/modules
echo "rtc_pcf8563"|sudo tee -a /etc/modules
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
device-tree-compiler is already the newest version (1.6.0-1).
0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.
Couldn't open blob from '/media/boot/meson64_odroidc2.dtb': No such file or directory
aml_i2c
rtc_pcf8563
root@DietPi:~# echo "aml_i2c"|sudo tee -a /etc/modules
echo "rtc_pcf8563"|sudo tee -a /etc/modules
aml_i2c
rtc_pcf8563
root@DietPi:~# 

/media/boot/meson64_odroidc2.dtb does not exist in your file structure, is that the problem?

Where do you get the info from that the dtbs would be stored at /media/boot? Note that you cannot follow any Hardkernel wiki steps, these are all related to their legacy vendor kernel and their specific images.

As I said, the aml_i2c does not exist on our mainline kernel image and loading the rtc_pcf8563 module manually shouldn’t be required as such is done automatically on device detection on modern kernels.

The device trees are stored in /boot/dtb/meson and the overlays in /boot/dtb/meson/overlay.

If enabling the additional I2C buses with those overlays does no enable the RTC, then we need to check what how the device tree looks like on the vendor image. Probably the node needs to be adjusted to e.g. use different pins or states, if possible.

@MichaIng

I have 2 dtb folders and neither of them are /boot/dtb/meson

, /boot/dtb

root@DietPi:~# cd /boot/dtb
root@DietPi:/boot/dtb# ls
amlogic  nuvoton
root@DietPi:/boot/dtb# 

and /boot/dtb-6.0.13-meson64

root@DietPi:~# cd /boot/dtb-6.0.13-meson64
root@DietPi:/boot/dtb-6.0.13-meson64# ls
amlogic  nuvoton
root@DietPi:/boot/dtb-6.0.13-meson64# 

No folder reflects your /boot/dtb/meson/overlay file structure, but both folders have the overlays in this folder path

/boot/dtb-6.0.13-meson64/amlogic/overlay

Which contain the overlays

root@DietPi:~# cd /boot/dtb-6.0.13-meson64/amlogic/overlay root@DietPi:/boot/dtb-6.0.13-meson64/amlogic/overlay# ls meson-fixup.scr meson-i2cA.dtbo meson-uartA.dtbo meson-w1AB-gpio.dtbo README.meson-overlays meson-g12-gxl-cma-pool-896MB.dtbo meson-i2cB.dtbo meson-uartC.dtbo meson-w1-gpio.dtbo root@DietPi:/boot/dtb-6.0.13-meson64/amlogic/overlay#

Since the C2 has an Amlogic S905, Quad Core Cortex™-A53 (ARMv8 64-bit) I’m imagining the correct DTB to use is the amlogic overlays which are respectively

/boot/dtb/amlogic/meson-gxbb-odroidc2.dtb
/boot/dtb-6.0.13-meson64/amlogic/meson-gxbb-odroidc2.dtb

My question to you is do we need the missing overlay folders, do the folder structures have to reflect your example and how do I need to alter

/boot/dietpiEnv.txt

to correctly enable these overlays? my current file looks like this:

rootdev=UUID=eefd4803-778c-4c63-8a32-646fb9cf0cc3
rootfstype=ext4

# The init system logs to the console defined last.
consoleargs=console=tty1 console=ttyAML0,115200 console=ttyS1,115200 console=ttyS2,115200 console=ttyS3,115200 console=ttyS4,115200 console=ttyS5,115200 console=ttyS6,115200 console=ttyS7,115200 console=ttyS0,115200
verbosity=4

usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u

extraargs=net.ifnames=0 video=HDMI-A-1:1280x390

docker_optimizations=off


overlay_path=amlogic
overlay_prefix=meson
overlays=i2cA i2cB i2c0 i2c1 i2c2

Ah right sorry, amlogic is the path element and meson the device tree and overlay prefix, so the overlays are in /boot/dtb/amlogic/overlay.

You see the meson-i2cA.dtbo etc. With overlay_prefix=meson, having an entry i2cA in the overlays= line makes U-Boot look for a file in /boot/dtb/amlogic/overlay with that name, pretended with meson- and .dtbo ending, which is there. So generally it is able to apply this overlay. But it seems to not enable/set the correct pins with I2C for working with the RTC, so something is still wrong/missing.