Jump to content

ODroid-N2 RTC not work in linux-image-current-meson64=20.02.8 5.4.28-meson64


iav
Go to solution Solved by iav,

Recommended Posts

I use image linux-image-current-meson64=20.02.8 5.4.28-meson64, kernel set by apt upgrade

RTC battery connected. Try to perform setup by instruction

seems nwclock can't work:


 

lsmod|grep rtc
rtc_meson_vrtc         20480  1


ls -l /dev/rt*
lrwxrwxrwx 1 root root      4 Mar 30 18:28 /dev/rtc -> rtc0
crw------- 1 root root 252, 0 Mar 30 18:28 /dev/rtc0


 hwclock
hwclock: select() to /dev/rtc0 to wait for clock tick timed out
root@droid:~# hwclock -w
hwclock: ioctl(RTC_SET_TIME) to /dev/rtc0 to set the time failed: Invalid argument

How to set hardware clock correctly?

 

 

Previously I use earlier ubuntu-based armbian kernel 4.* on same device, and hardware clock woks. It brokes after swtching to a new image with new kernel.

 

Link to comment
Share on other sites

On 3/30/2020 at 12:19 PM, iav said:

How to set hardware clock correctly?

Odroid-N2 external RTC is attached on I2C3 which isn't enabled by default.

To enable it, use this overlay source and compile it and load it.

/dts-v1/;
/plugin/;

/ {
    compatible = "amlogic,meson-g12b";
    fragment@0 {
        target-path = "/aliases";
        __overlay__ {
            i2c3a = "/soc/bus@ffd00000/i2c@1c000";
        };
    };
    fragment@1 {
        target-path = "/soc/bus@ffd00000/i2c@1c000";
        __overlay__ {
            status = "okay";
            pinctrl-0 = <&i2c3_sda_a_pins>, <&i2c3_sck_a_pins>;
            pinctrl-names = "default";
            pcf8563: rtc@51 { /*I2C-bus slave address: read A3h and write A2h*/
		compatible = "nxp,pcf8563";
		reg = <0x51>;
            };
        };
    };
};

Then, the i2c will appear as well as module for PCF8563 will be loaded, it will be hookup as /dev/rtc1, you can then set the clock and re-read it using :

hwclock -w -f /dev/rtc1
hwclock -f /dev/rtc1

 

Link to comment
Share on other sites

1 hour ago, martinayotte said:

Odroid-N2 external RTC is attached on I2C3 which isn't enabled by default.

To enable it, use this overlay source and compile it and load it.


/dts-v1/;
/plugin/;

/ {
    compatible = "amlogic,meson-g12b";
    fragment@0 {
        target-path = "/aliases";
        __overlay__ {
            i2c3a = "/soc/bus@ffd00000/i2c@1c000";
        };
    };
    fragment@1 {
        target-path = "/soc/bus@ffd00000/i2c@1c000";
        __overlay__ {
            status = "okay";
            pinctrl-0 = <&i2c3_sda_a_pins>, <&i2c3_sck_a_pins>;
            pinctrl-names = "default";
            pcf8563: rtc@51 { /*I2C-bus slave address: read A3h and write A2h*/
		compatible = "nxp,pcf8563";
		reg = <0x51>;
            };
        };
    };
};

en, the i2c will appear as well as module for PCF8563 will be loaded, it will be hookup as /dev/rtc1, you can then set the clock and re-read it using :


hwclock -w -f /dev/rtc1
hwclock -f /dev/rtc1

 

Thank you for help.

Could you please point to faq, howto or something like it to read how to "use this overlay source and compile it and load it"? Sorry, I am not "in context" for a while. But I will :)

Link to comment
Share on other sites

8 minutes ago, iav said:

read how to "use this overlay source and compile it and load it"?

Install DT compiler from http://ftp.debian.org/debian/pool/main/d/device-tree-compiler/device-tree-compiler_1.4.7-3_arm64.deb

Then, compile the DTS I've provided and then load it dynamically :

dtc -@ -I dts -O dtb -o odroid-n2-ic2@1c000.dtbo odroid-n2-ic2@1c000.dts
mkdir /sys/kernel/config/device-tree/overlays/i2c3a
cat odroid-n2-ic2@1c000.dtbo > /sys/kernel/config/device-tree/overlays/i2c3a/dtbo

 

Link to comment
Share on other sites

31 minutes ago, martinayotte said:

Install DT compiler from http://ftp.debian.org/debian/pool/main/d/device-tree-compiler/device-tree-compiler_1.4.7-3_arm64.deb

Then, compile the DTS I've provided and then load it dynamically :


dtc -@ -I dts -O dtb -o odroid-n2-ic2@1c000.dtbo odroid-n2-ic2@1c000.dts
mkdir /sys/kernel/config/device-tree/overlays/i2c3a
cat odroid-n2-ic2@1c000.dtbo > /sys/kernel/config/device-tree/overlays/i2c3a/dtbo

 

It works!

Thank you!

 

Do you think I have to ask armbian kernel builders to include your code into kernel image?

Link to comment
Share on other sites

On 4/12/2020 at 2:59 AM, martinayotte said:

I'm one of the main Armbian devs, so, yes, I will add the DT overlay in builds in the near future ...

What kernel  I have to install to got it work?

linux-image-current, -dev, -legacy, other sources?

Link to comment
Share on other sites

30 minutes ago, martinayotte said:

I've not done the commit yet, "time is the missing ingredient" ...

But feel free to compile above DT overlay !

yes, I did it already... but I not understand how to avoid manual path creation and dt copying with manual hwclock run. To let it work as it should — set system clock at a boot time.

Link to comment
Share on other sites

On 4/12/2020 at 1:59 AM, martinayotte said:

I'm one of the main Armbian devs, so, yes, I will add the DT overlay in builds in the near future ...

  

On 4/12/2020 at 1:59 AM, martinayotte said:

I'm one of the main Armbian devs, so, yes, I will add the DT overlay in builds in the near future ...

Hi martinayotte,

 

thanks for providing quick fix via device tree overlay. Also i am very happy to see we got Armbian and a much more recent kernel running on HK Odroid N2! Thx for all your hard work!

 

Do we lack full support for overlays atm? Even if we do as described for allwiner based boards?

'Cause i tried to use "user_overlays" and "overlay" options in "ArmbianEnv.txt" as described here:

https://docs.armbian.com/Hardware_Allwinner_overlays/

but couldn't get it to work.

Just wanna know if i am missing something/ doing it wrong or It's known/intended

 

/boot/armbianEnv.txt

verbosity=1
user_overlays=odroid-n2-ic2@1c000
usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u <= AutoAdded so file seems to be found

adding the entries and copying the files myself didn't change anything.

adding useroverlay via armbian-add-overlay  => Overlays are supported only on A10... => Removing the allwiner sanity check from

/usr/sbin/armbian-add-overlay line 38-41

edits armbianEnv.txt correctly by adding "user_overlays" option and copying the files to "/boot/overlay-user/" which seems be the desired location. But no pcf8563 modules are loaded after boot. 

I also tried adding the dtbo to /boot/dtb/overlay /boot/dtb/amlogic/overlays and so on.

 

Your mentioned example rc.local works fine instead.

mkdir /sys/kernel/config/device-tree/overlays/i2c3a
cat /root/odroid-n2-ic2@1c000.dtbo > /sys/kernel/config/device-tree/overlays/i2c3a/dtbo

systemctl stop ntp
ntpd -qg
systemctl start ntp
hwclock --systohc -f /dev/rtc1

 

TIA

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines