Jump to content

Recommended Posts

Posted

Hi, after upgrade to next kernel:

 

 

my rtc-i2c stopped working.

 

Here is the result for "Linux ... 3.4.113-sun8i #18 SMP PREEMPT Wed Jan 24 22:10:49 CET 2018 armv7l GNU/Linux"

 

[    6.008219] rtc-ds1307 0-0068: rtc core: registered ds1307 as rtc1
[    6.008241] rtc-ds1307 0-0068: 56 bytes nvram
[    6.008277] i2c i2c-0: new_device: Instantiated device ds1307 at 0x68

 

Here is for "Linux ... 4.14.18-sunxi #24 SMP Fri Feb 9 16:24:32 CET 2018 armv7l GNU/Linux"

 

[ 6376.740796] i2c i2c-0: new_device: Instantiated device ds3232 at 0x68

 

and nothing else (btw the same is for ds1307). Device rtc1 is not registered.

 

Can anybody suggest how to force device /dev/rtc1 to be registered?

 

Posted

rtc module is standard 1307/3231. Registered with command:

 

/bin/echo ds1307 0x68 1>/sys/class/i2c-adapter/i2c-0/new_device

Posted

Unfortunately device is no longer detected on i2c bus:

 

root@PKHELPER:~# 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: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- UU -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

Posted

Thanks! As following:

 

root@PKHELPER:/boot/overlay-user# ll
total 8
-rw-r--r-- 1 root root 473 May 13 16:45 ds1307.dts
-rw-r--r-- 1 root root 401 May 13 16:46 ds1307.dtbo
root@PKHELPER:/boot/overlay-user# cat ds1307.dts
/dts-v1/;
/plugin/;

/ {
    compatible = "brcm,bcm2708";

    fragment@0 {
            target = <&i2c0>;

            __overlay__ {
                    #address-cells = <1>;
                    #size-cells = <0>;
                    status = "okay";

                    ds1307@68 {
                            compatible = "ds1307";
                            reg = <0x68>;
                            status = "okay";
                    };
            };
      };
};

root@PKHELPER:/boot/overlay-user# dmesg | grep ds1307
[    8.348114] rtc-ds1307 0-0068: registered as rtc1
root@PKHELPER:/boot/overlay-user# hwclock -r -f /dev/rtc1
Sun 13 May 2018 04:49:25 PM CEST  -0.422132 seconds
root@PKHELPER:/boot/overlay-user#

 

Posted

Hi, as written above everything is working correctly with "next" (4.14.70) and "default" (3.4.113) kernels.

 

For some of my boards I have upgraded to dev. And unfortunately module stopped working.

 

It seems that overlay method is mot causing that rtc device is registered. Here is my ds1307.dts file:

 

[root@PKTEST /boot/overlay-user]# ll
total 8
-rw-r--r-- 1 root root 271 May 13 18:11 ds1307.dts
-rw-r--r-- 1 root root 401 May 13 18:11 ds1307.dtbo
[root@PKTEST /boot/overlay-user]# cat ds1307.dts
/dts-v1/;
/plugin/;

/ {
        compatible = "brcm,bcm2708";
        fragment@0 {
                target = <&i2c0>;
                __overlay__ {
                        #address-cells = <1>;
                        #size-cells = <0>;
                        status = "okay";
                        ds1307@68 {
                                compatible = "ds1307";
                                reg = <0x68>;
                                status = "okay";
                        };
                };
        };
};
[root@PKTEST /boot/overlay-user]#

 

After boot it is as folllowing:

 

[root@PKTEST ~]# cd /sys/class/i2c-adapter/
[root@PKTEST /sys/class/i2c-adapter]# ll
total 0
lrwxrwxrwx 1 root root 0 Jan  1  1970 i2c-2 -> ../../devices/platform/soc/1f02400.i2c/i2c-2
lrwxrwxrwx 1 root root 0 Jan  1  1970 i2c-1 -> ../../devices/platform/soc/1c2ac00.i2c/i2c-1
lrwxrwxrwx 1 root root 0 Jan  1  1970 i2c-0 -> ../../devices/platform/soc/1ee0000.hdmi/i2c-0
[root@PKTEST /sys/class/i2c-adapter]# cd i2c-2
[root@PKTEST /sys/class/i2c-adapter/i2c-2]# ll
total 0
-rw-r--r-- 1 root root 4096 Jan  1  1970 uevent
lrwxrwxrwx 1 root root    0 Jan  1  1970 subsystem -> ../../../../../bus/i2c
drwxr-xr-x 4 root root    0 Jan  1  1970 2-0065
drwxr-xr-x 3 root root    0 Jan  1  1970 i2c-dev
drwxr-xr-x 2 root root    0 Oct  4 11:47 power
lrwxrwxrwx 1 root root    0 Oct  4 11:47 of_node -> ../../../../../firmware/devicetree/base/soc/i2c@1f02400
--w------- 1 root root 4096 Oct  4 11:47 new_device
-r--r--r-- 1 root root 4096 Oct  4 11:47 name
lrwxrwxrwx 1 root root    0 Oct  4 11:47 device -> ../../1f02400.i2c
--w------- 1 root root 4096 Oct  4 11:47 delete_device
[root@PKTEST /sys/class/i2c-adapter/i2c-2]# cd ../i2c-1
[root@PKTEST /sys/class/i2c-adapter/i2c-1]# ll
total 0
-rw-r--r-- 1 root root 4096 Jan  1  1970 uevent
lrwxrwxrwx 1 root root    0 Jan  1  1970 subsystem -> ../../../../../bus/i2c
drwxr-xr-x 3 root root    0 Jan  1  1970 1-0068
drwxr-xr-x 3 root root    0 Jan  1  1970 i2c-dev
lrwxrwxrwx 1 root root    0 Oct  4 11:48 device -> ../../1c2ac00.i2c
drwxr-xr-x 2 root root    0 Oct  4 11:48 power
lrwxrwxrwx 1 root root    0 Oct  4 11:48 of_node -> ../../../../../firmware/devicetree/base/soc/i2c@1c2ac00
--w------- 1 root root 4096 Oct  4 11:48 new_device
-r--r--r-- 1 root root 4096 Oct  4 11:48 name
--w------- 1 root root 4096 Oct  4 11:48 delete_device
[root@PKTEST /sys/class/i2c-adapter/i2c-1]# cd 1-0068
[root@PKTEST /sys/class/i2c-adapter/i2c-1/1-0068]# ll
total 0
-rw-r--r-- 1 root root 4096 Jan  1  1970 uevent
lrwxrwxrwx 1 root root    0 Jan  1  1970 subsystem -> ../../../../../../bus/i2c
drwxr-xr-x 2 root root    0 Oct  4 11:48 power
lrwxrwxrwx 1 root root    0 Oct  4 11:48 of_node -> ../../../../../../firmware/devicetree/base/soc/i2c@1c2ac00/ds1307@68
-r--r--r-- 1 root root 4096 Oct  4 11:48 name
-r--r--r-- 1 root root 4096 Oct  4 11:48 modalias
[root@PKTEST /sys/class/i2c-adapter/i2c-1/1-0068]# cd ../../i2c-0
[root@PKTEST /sys/class/i2c-adapter/i2c-0]# ll
total 0
-rw-r--r-- 1 root root 4096 Jan  1  1970 uevent
lrwxrwxrwx 1 root root    0 Jan  1  1970 subsystem -> ../../../../../bus/i2c
drwxr-xr-x 3 root root    0 Jan  1  1970 i2c-dev
drwxr-xr-x 2 root root    0 Oct  4 11:48 power
--w------- 1 root root 4096 Oct  4 11:48 new_device
-r--r--r-- 1 root root 4096 Oct  4 11:48 name
lrwxrwxrwx 1 root root    0 Oct  4 11:48 device -> ../../1ee0000.hdmi
--w------- 1 root root 4096 Oct  4 11:48 delete_device
[root@PKTEST /sys/class/i2c-adapter/i2c-0]#

 

 

 

Additionally I have verified and swtched off overlay method in armbianEnv.txt file. The used method used for "Default" (echo to new_device). rtc1 is registered but cannot be effectively used:

 

[root@PKTEST ~]# cd /sys/class/i2c-adapter/
[root@PKTEST /sys/class/i2c-adapter]# ll
total 0
lrwxrwxrwx 1 root root 0 Jan  1  1970 i2c-1 -> ../../devices/platform/soc/1f02400.i2c/i2c-1
lrwxrwxrwx 1 root root 0 Jan  1  1970 i2c-0 -> ../../devices/platform/soc/1ee0000.hdmi/i2c-0
[root@PKTEST /sys/class/i2c-adapter]# cd
[root@PKTEST ~]# cat /boot/armbianEnv.txt
verbosity=0
rootdev=UUID=f8301761-6756-4f97-aa80-12c05ea037cf
extraargs=pty.legacy_count=2
usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u,0x1058:0x10b8:u
[root@PKTEST ~]# cd /sys/class/i2c-adapter/
[root@PKTEST /sys/class/i2c-adapter]# ll
total 0
lrwxrwxrwx 1 root root 0 Oct  4 11:40 i2c-1 -> ../../devices/platform/soc/1f02400.i2c/i2c-1
lrwxrwxrwx 1 root root 0 Oct  4 11:40 i2c-0 -> ../../devices/platform/soc/1ee0000.hdmi/i2c-0
[root@PKTEST /sys/class/i2c-adapter]# cd i2c-0
[root@PKTEST /sys/class/i2c-adapter/i2c-0]# ll
total 0
-rw-r--r-- 1 root root 4096 Jan  1  1970 uevent
lrwxrwxrwx 1 root root    0 Jan  1  1970 subsystem -> ../../../../../bus/i2c
drwxr-xr-x 3 root root    0 Jan  1  1970 i2c-dev
lrwxrwxrwx 1 root root    0 Oct  4 11:40 device -> ../../1ee0000.hdmi
drwxr-xr-x 2 root root    0 Oct  4 11:40 power
--w------- 1 root root 4096 Oct  4 11:40 new_device
-r--r--r-- 1 root root 4096 Oct  4 11:40 name
--w------- 1 root root 4096 Oct  4 11:40 delete_device
[root@PKTEST /sys/class/i2c-adapter/i2c-0]# cd ..
[root@PKTEST /sys/class/i2c-adapter]# cd i2c-1
[root@PKTEST /sys/class/i2c-adapter/i2c-1]# ll
total 0
-rw-r--r-- 1 root root 4096 Jan  1  1970 uevent
lrwxrwxrwx 1 root root    0 Jan  1  1970 subsystem -> ../../../../../bus/i2c
drwxr-xr-x 4 root root    0 Jan  1  1970 1-0065
drwxr-xr-x 3 root root    0 Jan  1  1970 i2c-dev
drwxr-xr-x 2 root root    0 Oct  4 11:41 power
lrwxrwxrwx 1 root root    0 Oct  4 11:41 of_node -> ../../../../../firmware/devicetree/base/soc/i2c@1f02400
--w------- 1 root root 4096 Oct  4 11:41 new_device
-r--r--r-- 1 root root 4096 Oct  4 11:41 name
lrwxrwxrwx 1 root root    0 Oct  4 11:41 device -> ../../1f02400.i2c
--w------- 1 root root 4096 Oct  4 11:41 delete_device
[root@PKTEST /sys/class/i2c-adapter/i2c-1]# cd ..
[root@PKTEST /sys/class/i2c-adapter]# i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: 30 31 32 33 34 35 36 37 -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
[root@PKTEST /sys/class/i2c-adapter]# 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: -- -- -- -- -- UU -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
[root@PKTEST /sys/class/i2c-adapter]# cd i2c-0
[root@PKTEST /sys/class/i2c-adapter/i2c-0]# echo ds1307 0x68 >new_device
[root@PKTEST /sys/class/i2c-adapter/i2c-0]# dmesg | tail -10
[   10.207986] zram0: detected capacity change from 0 to 52428800
[   10.464198] EXT4-fs (zram0): mounted filesystem without journal. Opts: discard
[   10.560357] thermal thermal_zone0: failed to read out thermal zone (-110)
[   11.600361] thermal thermal_zone0: failed to read out thermal zone (-110)
[   13.280939] dwmac-sun8i 1c30000.ethernet eth0: Link is Up - 100Mbps/Full - flow control rx/tx
[   13.280991] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[   15.604092] random: crng init done
[   15.604102] random: 7 urandom warning(s) missed due to ratelimiting
[  109.520532] i2c i2c-0: new_device: Instantiated device ds1307 at 0x68
[  109.544732] rtc-ds1307 0-0068: registered as rtc1
[root@PKTEST /sys/class/i2c-adapter/i2c-0]# ll
total 0
lrwxrwxrwx 1 root root    0 Oct  4 11:40 device -> ../../1ee0000.hdmi
lrwxrwxrwx 1 root root    0 Oct  4 11:40 subsystem -> ../../../../../bus/i2c
drwxr-xr-x 2 root root    0 Oct  4 11:40 power
--w------- 1 root root 4096 Oct  4 11:40 delete_device
drwxr-xr-x 3 root root    0 Oct  4 11:40 i2c-dev
-rw-r--r-- 1 root root 4096 Oct  4 11:40 uevent
-r--r--r-- 1 root root 4096 Oct  4 11:40 name
--w------- 1 root root 4096 Oct  4 11:41 new_device
drwxr-xr-x 5 root root    0 Oct  4 11:41 0-0068
[root@PKTEST /sys/class/i2c-adapter/i2c-0]# ll /dev/rtc*
crw------- 1 root root 253, 0 May 22  2016 /dev/rtc0
lrwxrwxrwx 1 root root      4 May 22  2016 /dev/rtc -> rtc0
crw------- 1 root root 253, 1 Oct  4 11:41 /dev/rtc1
[root@PKTEST /sys/class/i2c-adapter/i2c-0]# hwclock -r -f /dev/rtc1
hwclock: ioctl(RTC_RD_TIME) to /dev/rtc1 to read the time failed: Invalid argument
[root@PKTEST /sys/class/i2c-adapter/i2c-0]# cd ../i2c-1
[root@PKTEST /sys/class/i2c-adapter/i2c-1]# echo ds1307 0x68 >new_device
[root@PKTEST /sys/class/i2c-adapter/i2c-1]# dmesg | tail -10
[   10.560357] thermal thermal_zone0: failed to read out thermal zone (-110)
[   11.600361] thermal thermal_zone0: failed to read out thermal zone (-110)
[   13.280939] dwmac-sun8i 1c30000.ethernet eth0: Link is Up - 100Mbps/Full - flow control rx/tx
[   13.280991] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[   15.604092] random: crng init done
[   15.604102] random: 7 urandom warning(s) missed due to ratelimiting
[  109.520532] i2c i2c-0: new_device: Instantiated device ds1307 at 0x68
[  109.544732] rtc-ds1307 0-0068: registered as rtc1
[  154.367483] rtc-ds1307 0-0068: read error -5
[  166.008663] i2c i2c-1: new_device: Instantiated device ds1307 at 0x68
[root@PKTEST /sys/class/i2c-adapter/i2c-1]# ll /dev/rtc*
crw------- 1 root root 253, 0 May 22  2016 /dev/rtc0
lrwxrwxrwx 1 root root      4 May 22  2016 /dev/rtc -> rtc0
crw------- 1 root root 253, 1 Oct  4 11:41 /dev/rtc1
[root@PKTEST /sys/class/i2c-adapter/i2c-1]# hwclock -r -f /dev/rtc1
hwclock: ioctl(RTC_RD_TIME) to /dev/rtc1 to read the time failed: Invalid argument
[root@PKTEST /sys/class/i2c-adapter/i2c-1]# cd ../i2c-0
[root@PKTEST /sys/class/i2c-adapter/i2c-0]# echo 0x68 >delete_device
[root@PKTEST /sys/class/i2c-adapter/i2c-0]# dmesg | tail -10
[   13.280939] dwmac-sun8i 1c30000.ethernet eth0: Link is Up - 100Mbps/Full - flow control rx/tx
[   13.280991] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[   15.604092] random: crng init done
[   15.604102] random: 7 urandom warning(s) missed due to ratelimiting
[  109.520532] i2c i2c-0: new_device: Instantiated device ds1307 at 0x68
[  109.544732] rtc-ds1307 0-0068: registered as rtc1
[  154.367483] rtc-ds1307 0-0068: read error -5
[  166.008663] i2c i2c-1: new_device: Instantiated device ds1307 at 0x68
[  195.468248] rtc-ds1307 0-0068: read error -5
[  209.625152] i2c i2c-0: delete_device: Deleting device ds1307 at 0x68
[root@PKTEST /sys/class/i2c-adapter/i2c-0]# cd ../i2c-1
[root@PKTEST /sys/class/i2c-adapter/i2c-1]# echo ds1307 0x68 >new_device
-bash: echo: write error: Invalid argument
[root@PKTEST /sys/class/i2c-adapter/i2c-1]# ll
total 0
lrwxrwxrwx 1 root root    0 Oct  4 11:41 device -> ../../1f02400.i2c
lrwxrwxrwx 1 root root    0 Oct  4 11:41 subsystem -> ../../../../../bus/i2c
drwxr-xr-x 2 root root    0 Oct  4 11:41 power
drwxr-xr-x 4 root root    0 Oct  4 11:41 1-0065
--w------- 1 root root 4096 Oct  4 11:41 delete_device
drwxr-xr-x 3 root root    0 Oct  4 11:41 i2c-dev
-rw-r--r-- 1 root root 4096 Oct  4 11:41 uevent
-r--r--r-- 1 root root 4096 Oct  4 11:41 name
lrwxrwxrwx 1 root root    0 Oct  4 11:41 of_node -> ../../../../../firmware/devicetree/base/soc/i2c@1f02400
drwxr-xr-x 3 root root    0 Oct  4 11:42 1-0068
--w------- 1 root root 4096 Oct  4 11:43 new_device
[root@PKTEST /sys/class/i2c-adapter/i2c-1]# echo 0x68 >delete_device
[root@PKTEST /sys/class/i2c-adapter/i2c-1]# dmesg | tail -10
[   15.604092] random: crng init done
[   15.604102] random: 7 urandom warning(s) missed due to ratelimiting
[  109.520532] i2c i2c-0: new_device: Instantiated device ds1307 at 0x68
[  109.544732] rtc-ds1307 0-0068: registered as rtc1
[  154.367483] rtc-ds1307 0-0068: read error -5
[  166.008663] i2c i2c-1: new_device: Instantiated device ds1307 at 0x68
[  195.468248] rtc-ds1307 0-0068: read error -5
[  209.625152] i2c i2c-0: delete_device: Deleting device ds1307 at 0x68
[  226.135079] i2c i2c-1: Failed to register i2c client ds1307 at 0x68 (-16)
[  237.022019] i2c i2c-1: delete_device: Deleting device ds1307 at 0x68
[root@PKTEST /sys/class/i2c-adapter/i2c-1]# echo ds1307 0x68 >new_device
[root@PKTEST /sys/class/i2c-adapter/i2c-1]# dmesg | tail -10
[   15.604102] random: 7 urandom warning(s) missed due to ratelimiting
[  109.520532] i2c i2c-0: new_device: Instantiated device ds1307 at 0x68
[  109.544732] rtc-ds1307 0-0068: registered as rtc1
[  154.367483] rtc-ds1307 0-0068: read error -5
[  166.008663] i2c i2c-1: new_device: Instantiated device ds1307 at 0x68
[  195.468248] rtc-ds1307 0-0068: read error -5
[  209.625152] i2c i2c-0: delete_device: Deleting device ds1307 at 0x68
[  226.135079] i2c i2c-1: Failed to register i2c client ds1307 at 0x68 (-16)
[  237.022019] i2c i2c-1: delete_device: Deleting device ds1307 at 0x68
[  247.317683] i2c i2c-1: new_device: Instantiated device ds1307 at 0x68
[root@PKTEST /sys/class/i2c-adapter/i2c-1]# ll /dev/rtc*
crw------- 1 root root 253, 0 May 22  2016 /dev/rtc0
lrwxrwxrwx 1 root root      4 May 22  2016 /dev/rtc -> rtc0
[root@PKTEST /sys/class/i2c-adapter/i2c-1]#

 

 

Posted

Additionally I have noticed that example file is different slightly than mine:

 

https://github.com/armbian/sunxi-DT-overlays/blob/master/examples/i2c-ds1307.dts

 

Unfortunately I cannot compile new dts file:

 

[root@PKTEST ~]# uname -r
4.18.8-sunxi
[root@PKTEST ~]# cd /lib/modules/4.18.8-sunxi/build/scripts/dtc
[root@PKTEST /lib/modules/4.18.8-sunxi/build/scripts/dtc]# ll
total 304
drwxr-xr-x 2 root root  4096 Oct  2 20:32 libfdt
drwxr-xr-x 2 root root  4096 Oct  2 20:32 include-prefixes
-rw-r--r-- 1 root root    42 Oct  2 20:32 version_gen.h
-rw-r--r-- 1 root root  7888 Oct  2 20:32 util.h
-rw-r--r-- 1 root root  9622 Oct  2 20:32 util.c
-rwxr-xr-x 1 root root  2552 Oct  2 20:32 update-dtc-source.sh
-rw-r--r-- 1 root root  6158 Oct  2 20:32 treesource.c
-rw-r--r-- 1 root root  3624 Oct  2 20:32 srcpos.h
-rw-r--r-- 1 root root  6859 Oct  2 20:32 srcpos.c
-rw-r--r-- 1 root root   372 Oct  2 20:32 Makefile.dtc
-rw-r--r-- 1 root root   956 Oct  2 20:32 Makefile
-rw-r--r-- 1 root root 21011 Oct  2 20:32 livetree.c
-rw-r--r-- 1 root root     4 Oct  2 20:32 .gitignore
-rw-r--r-- 1 root root  2283 Oct  2 20:32 fstree.c
-rw-r--r-- 1 root root 22682 Oct  2 20:32 flattree.c
-rw-r--r-- 1 root root  8546 Oct  2 20:32 fdtput.c
-rw-r--r-- 1 root root  8781 Oct  2 20:32 fdtget.c
-rw-r--r-- 1 root root  3756 Oct  2 20:32 fdtdump.c
-rwxr-xr-x 1 root root  8755 Oct  2 20:32 dtx_diff
-rwxr-xr-x 1 root root 41838 Oct  2 20:32 dt_to_config
-rw-r--r-- 1 root root 10590 Oct  2 20:32 dtc-parser.y
-rw-r--r-- 1 root root  7043 Oct  2 20:32 dtc-lexer.l
-rw-r--r-- 1 root root  8736 Oct  2 20:32 dtc.h
-rw-r--r-- 1 root root  9477 Oct  2 20:32 dtc.c
-rw-r--r-- 1 root root  5253 Oct  2 20:32 data.c
-rw-r--r-- 1 root root 45534 Oct  2 20:32 checks.c
[root@PKTEST /lib/modules/4.18.8-sunxi/build/scripts/dtc]# cd /boot/overlay-user/
[root@PKTEST /boot/overlay-user]# ll
total 8
-rw-r--r-- 1 root root 401 May 13 18:11 ds1307.dtbo
-rw-r--r-- 1 root root 770 Oct  4 12:29 ds1307.dts
[root@PKTEST /boot/overlay-user]# rm ds1307.dtbo
[root@PKTEST /boot/overlay-user]# cat ds1307.dts
/dts-v1/;
/plugin/;

/ {
        compatible = "allwinner,sun4i-a10", "allwinner,sun7i-a20", "allwinner,sun8i-h3", "allwinner,sun50i-a64", "allwinner,sun50i-h5";

        /*
         * Aliases can be used to set the external RTC as rtc0
         * Needs supplying the correct path to the I2C controller RTC is connected to,
         * this example is for I2C1 on H3
         * NOTE: setting time at boot by the kernel
         * may not work in some cases if the external RTC module is loaded too late
         */
        fragment@0 {
                target-path = "/aliases";
                __overlay__ {
                        rtc0 = "/soc/i2c@01c2b000/ds1307@68";
                };
        };

        fragment@1 {
                target = <&i2c1>;
                __overlay__ {
                        #address-cells = <1>;
                        #size-cells = <0>;
                        ds1307@68 {
                                compatible = "dallas,ds1307";
                                reg = <0x68>;
                                status = "okay";
                        };
                };
        };
};
[root@PKTEST /boot/overlay-user]# armbian-add-overlay ds1307.dts
Error: kernel headers are not installed properly
Can't find dtc that supports compiling overlays
Please install the headers package for kernel 4.18.8-sunxi
[root@PKTEST /boot/overlay-user]#

 

Posted

Thanks, I have updated device-tree-compiler to "buster" version and I have created symbolic link from modules/... to dtc binary. Script armbian-add-overlay is working. But after compiling new dts - rtc is still not working (not registered as rtc device).

Posted
1 hour ago, martinayotte said:

Is it at least appearing with "i2cdetect" ?

Is RTC DT node appears under the proper I2C node in /proc/device-tree/soc ?

 

 

I am not sure if the path is correct - I used the one from dts file (in post above). It seems that "something" is there. However, I2C detect does not see any device under address 0x68. I am also not sure if aliases section of dts file will somehow override visibility of standard rtc0 device from SOC?

 

Below are a few commands.

[root@PKTEST /proc/device-tree/soc/i2c@1c2b000]# ll
total 0
-r--r--r-- 1 root root 24 Oct  4 17:32 compatible
-r--r--r-- 1 root root  8 Oct  4 17:32 clocks
-r--r--r-- 1 root root  8 Oct  4 17:32 resets
-r--r--r-- 1 root root  9 Oct  4 17:32 status
-r--r--r-- 1 root root  4 Oct  4 17:32 #address-cells
-r--r--r-- 1 root root 12 Oct  4 17:32 interrupts
-r--r--r-- 1 root root  4 Oct  4 17:32 #size-cells
drwxr-xr-x 2 root root  0 Oct  4 17:32 ds1307@68
-r--r--r-- 1 root root  4 Oct  4 17:32 phandle
-r--r--r-- 1 root root  8 Oct  4 17:32 reg
-r--r--r-- 1 root root  4 Oct  4 17:32 pinctrl-0
-r--r--r-- 1 root root  4 Oct  4 17:32 name
-r--r--r-- 1 root root  8 Oct  4 17:32 pinctrl-names
[root@PKTEST /proc/device-tree/soc/i2c@1c2b000]# cd ds1307@68/
[root@PKTEST /proc/device-tree/soc/i2c@1c2b000/ds1307@68]# ll
total 0
-r--r--r-- 1 root root 14 Oct  4 17:32 compatible
-r--r--r-- 1 root root  5 Oct  4 17:32 status
-r--r--r-- 1 root root  4 Oct  4 17:32 reg
-r--r--r-- 1 root root  7 Oct  4 17:32 name
[root@PKTEST /proc/device-tree/soc/i2c@1c2b000/ds1307@68]# ll /dev/rtc*
crw------- 1 root root 253, 0 May 22  2016 /dev/rtc0
lrwxrwxrwx 1 root root      4 May 22  2016 /dev/rtc -> rtc0
[root@PKTEST /proc/device-tree/soc/i2c@1c2b000/ds1307@68]# dmesg | grep -i ds1307
[root@PKTEST /proc/device-tree/soc/i2c@1c2b000/ds1307@68]# dmesg | grep -i rtc
[    3.625735] [drm] Cannot find any crtc or sizes
[    3.746859] sun6i-rtc 1f00000.rtc: rtc core: registered rtc-sun6i as rtc0
[    3.746865] sun6i-rtc 1f00000.rtc: RTC enabled
[    4.640512] [drm] Cannot find any crtc or sizes
[root@PKTEST /proc/device-tree/soc/i2c@1c2b000/ds1307@68]# i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: 30 -- 32 33 34 35 36 37 -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
[root@PKTEST /proc/device-tree/soc/i2c@1c2b000/ds1307@68]# 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: -- -- -- -- -- UU -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
[root@PKTEST /proc/device-tree/soc/i2c@1c2b000/ds1307@68]#

 

Posted
10 minutes ago, piknew said:

However, I2C detect does not see any device under address 0x68.

Maybe you mixed SDA and SCK lines ?

Or the DS1307 is itself defective ...

 

Posted

Definitely not (PKTEST is Orange Pi PC) - I also checked on OPI+2 with the same results (FAILED on "dev"). But I will try to downgrade to "next" on OPiPC (PKTEST). I will give an update in matter of minutes.

 

 

Update: "next" is the same. But then I have downgraded to "Default" and:

 

[root@PKTEST ~]# i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
[root@PKTEST ~]# cd /sys/class/i2c-adapter/i2c-0
[root@PKTEST /sys/class/i2c-adapter/i2c-0]# echo ds1307 0x68 >new_device
[root@PKTEST /sys/class/i2c-adapter/i2c-0]# ll /dev/rtc*
crw------- 1 root root 254, 0 May 22  2016 /dev/rtc0
lrwxrwxrwx 1 root root      4 May 22  2016 /dev/rtc -> rtc0
crw------- 1 root root 254, 1 Oct  4 18:36 /dev/rtc1
[root@PKTEST /sys/class/i2c-adapter/i2c-0]# hwclock -r -f /dev/rtc1
Thu 04 Oct 2018 06:36:46 PM CEST  -0.853544 seconds
[root@PKTEST /sys/class/i2c-adapter/i2c-0]#

 

Posted

SUCCESS :)

 

Story: I have used armbian-config to check Hardware (if my I2C bus is enabled). I have noticed very strange behavior of function: grep was outputted in "usage" mode. I revieved all the scripts and it appeared that line which is searching for "overlays=" is throwing this error. My /boot/armbianEnv.txt didn't have any overlay, especially for I2C, enabled. So, I have added as following (+ overlay prefix):

 

[root@PKTEST ~]# cat /boot/armbianEnv.txt
rootdev=UUID=f8301761-6756-4f97-aa80-12c05ea037cf
extraargs=pty.legacy_count=2
overlays=i2c0 i2c1 i2c2
user_overlays=ds1307
overlay_prefix=sun8i-h3
usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u,0x1058:0x10b8:u
[root@PKTEST ~]#

 

Then I have modified my user overlay file to be as following:

 

[root@PKTEST ~]# cat /boot/overlay-user/ds1307.dts
/dts-v1/;
/plugin/;

/ {
        compatible = "allwinner,sun4i-a10", "allwinner,sun7i-a20", "allwinner,sun8i-h3", "allwinner,sun50i-a64", "allwinner,sun50i-h5";

        /*
         * Aliases can be used to set the external RTC as rtc0
         * Needs supplying the correct path to the I2C controller RTC is connected to,
         * this example is for I2C1 on H3
         * NOTE: setting time at boot by the kernel
         * may not work in some cases if the external RTC module is loaded too late
         */
        fragment@0 {
                target-path = "/aliases";
                __overlay__ {
                        rtc0 = "/soc/i2c@1c2ac00/ds1307@68";
                };
        };

        fragment@1 {
                target = <&i2c0>;
                __overlay__ {
                        #address-cells = <1>;
                        #size-cells = <0>;
                        ds1307@68 {
                                compatible = "dallas,ds1307";
                                reg = <0x68>;
                                status = "okay";
                        };
                };
        };
};
[root@PKTEST ~]#

 

The address in fragment@0 is determined by looking where system placed i2c0 bus (I am sure that my RTC is connected to bus 0).

 

It is giving /dev/rtc1,m which I have verified as following:

 

[root@PKTEST ~]# ll /dev/rtc*
crw------- 1 root root 253, 0 May 22  2016 /dev/rtc0
lrwxrwxrwx 1 root root      4 May 22  2016 /dev/rtc -> rtc0
crw------- 1 root root 253, 1 May 22  2016 /dev/rtc1
[root@PKTEST ~]# hwclock -r -f /dev/rtc0
Sun 22 May 2016 12:38:25 AM CEST  -1.593015 seconds
[root@PKTEST ~]# hwclock -r -f /dev/rtc1
Fri 05 Oct 2018 11:57:03 AM CEST  -0.927469 seconds
[root@PKTEST ~]#

 

Unfortunately it seems that line frogment@0 is not making this device available as rtc0 (it is assigning rtc1):

 

[root@PKTEST ~]# dmesg | grep -i rtc
[    3.636229] [drm] Cannot find any crtc or sizes
[    3.756932] sun6i-rtc 1f00000.rtc: rtc core: registered rtc-sun6i as rtc0
[    3.756939] sun6i-rtc 1f00000.rtc: RTC enabled
[    4.641465] [drm] Cannot find any crtc or sizes
[    9.740172] rtc-ds1307 0-0068: /aliases ID 0 not available
[    9.741555] rtc-ds1307 0-0068: registered as rtc1
[root@PKTEST ~]#

 

Can anybody help and answer if it is possible somehow "override" the device? Of course I have my own systemd script to use it and set correct date at boot time. If "overriding" is not possible then I will use it.

 

 

 

Posted

You may try to rename your fragment@1 to fragment@2 and insert a new fragment@1 which will do a "/delete-node/ rtc0;" preventing the sun6i-rtc to be loaded ...

 

Posted

Hi, I am using rtc ds1307 on mainline with the following way, works correrctly:

 

add to armbianEnv.txt:

overlays=i2c0

 

 

next from shell do :

 

echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-0/new_device

rm /dev/rtc

ln -s /dev/rtc1 /dev/rtc

 

hwclock -s -f /dev/rtc

 

 

But it is really more correct to use ds1307.dts. Thank you for sharing.

 

 

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines