alecunsolo Posted February 5, 2021 Posted February 5, 2021 Armbianmonitor: http://ix.io/2OrM Hi all How can I enable the rtc clock in the Odroid HC4? I know nothing about device tree and overlays, but the Hardkernel Ubuntu image has an overlay to enable: wiki. I didn't find anything similar in the armbian image. Could be related to this this PR for the N2 model? Thanks
tparys Posted February 6, 2021 Posted February 6, 2021 Based on that wiki, it looks like it's probably the same RTC chip (pcf8563), and similar config between the C4 and N2, at least for the HardKernel kernel, which Armbian would probably mark as "legacy". You might be able to enable it in armbian-config, but long term it'd probably serve you better to keep the mainline kernel. I'd probably start seeing if you can enable it manually with sudo or a root shell. Take a look HERE, which shows how to enable it manually. i2cdetect can verify if your RTC is visible on a given I2C bus (may need to test a bus other than 0). Based on the wiki, it should probably be at address 0x51, and probably end up with a command like this: # echo pcf8563 0x51 > /sys/class/i2c-adapter/i2c-0/new_device Or on i2c-1, or whatever bus it's on. And then see if you can read your RTC via "hwclock". If you can, then you know what the tell the Linux kernel. You can do this through a Device Tree Overlay, or via a SystemD script which will run on startup. If you go the overlay route, you'll need to see that the below block ends up inside the the DTB inside the appropriate I2C bus. The extra stuff in each overlay file just sorta specifies where your changes are going. Decompile your DTB with "dtc -o meson-sm1-odroid-hc4.dts meson-sm1-odroid-hc4.dtb", and take a look at the resulting DTS file to see what I mean. rtc@51 { compatible = "nxp,pcf8563"; reg = <0x51>; }; Another way which may be more approachable is the SystemD route (see HERE). Basically you'd be writing a short script, and telling SystemD to start it on boot.
alecunsolo Posted February 8, 2021 Author Posted February 8, 2021 Thank for the reply. I can enable the rtc manually: # i2cdetect -y 0 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- 3c -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- 51 -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- -- # echo pcf8563 0x51 > /sys/class/i2c-adapter/i2c-0/new_device # i2cdetect -y 0 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- 3c -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- UU -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- -- # ls /dev/rt* /dev/rtc /dev/rtc0 /dev/rtc1 # hwclock --rtc /dev/rtc1 2021-02-08 08:54:57.164679+00:00 I think the overlay is a cleaner solution, so I decompiled the "/boot/dtb/amlogic/meson-sm1-odroid-hc4.dtb" (https://pastebin.com/FHJW3WN9) and try to make an overlay based on this post: /dts-v1/; /plugin/; / { fragment@0 { target-path = "/soc/bus@ffd00000/i2c@1d000"; __overlay__ { pcf8563: rtc@51 { compatible = "nxp,pcf8563"; reg = <0x51>; }; }; }; }; but when I tried to use the armbian-add-overlay script I got sudo armbian-add-overlay pcf8563.dts Overlays are not supported on Meson64 based boards. So meson boards don't support overlays? Or is the script not up-to-date?
tparys Posted February 9, 2021 Posted February 9, 2021 Hrm. The C4 image I have has a /boot/dtb/amlogic/overlay directory, and that's definitely a Meson64. Maybe try armbian-config to enable your overlay? In the meantime, perhaps someone else can shed some light on what's going on?
Solution Genna Posted February 9, 2021 Solution Posted February 9, 2021 Have you tried adding it as a user overlay? Basically create a folder '/boot/overlay-user'. Compile your plugin with the usual 'dtc -I dts -O dtb [your file] -o [output name].dtbo' and put it into the created directory. Then edit '/boot/armbianEnv.txt' and add the line 'user_overlays=[output name]'. That is what worked for me every time so far.
tparys Posted February 10, 2021 Posted February 10, 2021 I've never really spent too much time using overlays myself, but I did some digging, and this is what I found: In armbian-add-overlay, you have this chunk of code, which is generating the error. case "${LINUXFAMILY}" in sunxi|sunxi64|rk3399|rockchip64|rockpis) :;; *) echo >&2 "Overlays are not supported on ${LINUXFAMILY^} based boards." exit -1 ;; esac But what the script seems to do: Compiles the given dts file into a dtbo Copies the dtbo to /boot/overlay-user Adds "user_overlays=" to /boot/armbianEnv.txt and includes the given overlay file Given that the following is in the ODroid C4 (Amlogic / meson64) image (/boot/boot.cmd), I'm tempted to say it's an oversight. for overlay_file in ${user_overlays}; do if load ${devtype} ${devnum} ${load_addr} ${prefix}overlay-user/${overlay_file}.dtbo; then echo "Applying user provided DT overlay ${overlay_file}.dtbo" fdt apply ${load_addr} || setenv overlay_error "true" fi done So yeah, I'd suggest doing Genna suggests, or fix the script so it doesn't fail. Also, file a bug on the armbian-add-overlay script, or even better, a PR that fixes it
alecunsolo Posted February 18, 2021 Author Posted February 18, 2021 (edited) Sorry for the delay. Yes, manually using the user-overlay worked, so it is an oversight in the armbian-add-script. I was going to do a simple PR, but I think the issue was already addressed (and in a more elegant way) with this PR Thank you (I just noticed that the author of the PR is you @tparys ) Edited February 18, 2021 by alecunsolo Missing information
Recommended Posts