This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

关于DM8168 pcf8563 硬件时钟问题

Other Parts Discussed in Thread: PCM1865

各位好

我使用DVRRDK_04.00.00.03开发包,在DM8168启动后可以通过hwclock 写入和读取硬件时钟。

root@dm816x:/# date 010100002011
Sat Jan 1 00:00:00 UTC 2011
root@dm816x:/# hwclock -w
root@dm816x:/# hwclock -r
Sat Jan 1 00:00:07 2011 0.000000 seconds
root@dm816x:/# date 040404042014
Fri Apr 4 04:04:00 UTC 2014

但是重启之后,读取系统的硬件时钟的数据无效。pcf8563使用纽扣电池供电,断电后测得pcf8563供电电压正常(3.3V);

rtc-pcf8563 1-0051: retrieved date/time is not valid.
rtc-pcf8563 1-0051: hctosys: invalid date/time

是我的内核配置有问题吗?请问我要怎么修改。

以下是开机的相关信息:

Creating 6 MTD partitions on "omap2-nand.0":
0x000000000000-0x000000260000 : "U-Boot"
0x000000260000-0x000000280000 : "U-Boot Env"
0x000000280000-0x000000580000 : "U-Boot Logo"
0x000000580000-0x0000009c0000 : "Kernel"
0x0000009c0000-0x00001d1c0000 : "File System"
0x00001d1c0000-0x000020000000 : "Reserved"
davinci_mdio davinci_mdio.0: davinci mdio revision 1.6
davinci_mdio davinci_mdio.0: detected phy mask fffffffd
davinci_mdio.0: probed
davinci_mdio davinci_mdio.0: phy[1]: device 0:01, driver ET1011C
usbcore: registered new interface driver cdc_ether
usbcore: registered new interface driver dm9601
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
usbcore: registered new interface driver cdc_wdm
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
mice: PS/2 mouse device common for all mice
omap_rtc omap_rtc: rtc core: registered omap_rtc as rtc0
rtc-pcf8563 1-0051: chip found, driver version 0.4.3
rtc-pcf8563 1-0051: rtc core: registered rtc-pcf8563 as rtc1
i2c /dev entries driver
Linux video capture interface: v2.00
usbcore: registered new interface driver uvcvideo
USB Video Class driver (v1.0.0)
OMAP Watchdog Timer Rev 0x00: initial timeout 60 sec
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
notify_init : notify drivercreated for remote proc id 2 at physical Address 0xbfb00000
usbcore: registered new interface driver snd-usb-audio
usbcore: registered new interface driver snd-ua101
Registered pcm1865 audio codec
asoc: pcm1865-hifi <-> davinci-mcasp.0 mapping ok
Failed to add route HPLOUT->Headphone Jack
dapm: tlv320aic32x4.2-0018: configuring unknown pin MONO_LOUT
dapm: tlv320aic32x4.2-0018: configuring unknown pin HPLCOM
dapm: tlv320aic32x4.2-0018: configuring unknown pin HPRCOM
asoc: tlv320aic32x4-hifi <-> davinci-mcasp.2 mapping ok
asoc: HDMI-DAI-CODEC <-> hdmi-dai mapping ok
ALSA device list:
#0: TI81XX_RECORDER_CARD0
#1: TI81XX_RECORDER_CARD1
nf_conntrack version 0.5.0 (7687 buckets, 30748 max)
ip_tables: (C) 2000-2006 Netfilter Core Team
TCP cubic registered
NET: Registered protocol family 17
VFP support v0.3: implementor 41 architecture 3 part 30 variant c rev 3
omap_voltage_late_init: Voltage driver support not added
Power Management for TI81XX.
smartreflex smartreflex: Driver initialized
rtc-pcf8563 1-0051: retrieved date/time is not valid.
rtc-pcf8563 1-0051: hctosys: invalid date/time
davinci_mdio davinci_mdio.0: resetting idled controller
net eth0: attached PHY driver [ET1011C] (mii_bus:phy_addr=0:01, id=282f014)
IP-Config: Complete:
device=eth0, addr=192.168.129.199, mask=255.255.255.0, gw=192.168.129.1,
host=192.168.129.199, domain=, nis-domain=(none),
bootserver=192.168.129.139, rootserver=192.168.129.139, rootpath=
Waiting 5sec before mounting root device...

  • 驱动位置在

    ti_tools/linux_lsp/kernel/linux-dvr-rdk/drivers/rtc/rtc-pcf8563.c

    自己参考芯片手册,重点在读和写两个函数,看看格式是否正确。

  • 一开始DM8168没有设置pcf-8563硬件时钟时,在/sys/class/rtc/rtc1路径下读取date 和time数据是正常的,

    但是通过 hwclock -w -f /dev/rtc1 和open("/dev/rtc1", O_RDWR); retval = ioctl(fd, RTC_SET_TIME, &rtc_tm); 两种方法设置pcf 8563时钟

    第一种方法:

    root@dm816x:/# date 070117522016
    Fri Jul  1 17:52:00 UTC 2016
    root@dm816x:/# hwclock -w -f /dev/rtc1

    第二种方法:

            rtc_tm.tm_year = 2016-1900;
            rtc_tm.tm_mon  = 07 - 1;
            rtc_tm.tm_mday = 01;
            rtc_tm.tm_hour = 17;
            rtc_tm.tm_min  = 52;
            rtc_tm.tm_sec  = 57;
            fd = open("/dev/rtc1", O_RDWR); //O_RDWR
            if (fd == -1) { 
                    perror("/dev/rtc1"); 
                    exit(errno); 
            }
            retval = ioctl(fd, RTC_SET_TIME, &rtc_tm); 
            if (retval == -1) { 
                   perror("ioctl set"); 
                    exit(errno); 
            } 
            close(fd);
           fprintf(stderr, "RTC date/time: %02d/%02d/%04d %02d:%02d:%02d\n", 
                    rtc_tm.tm_mday, rtc_tm.tm_mon + 1, rtc_tm.tm_year + 1900, 
                    rtc_tm.tm_hour, rtc_tm.tm_min, rtc_tm.tm_sec);
    后再到  /sys/class/rtc/rtc1路径下 cat dade 和 cat time 发现有些数据位读不出来
    如小时的某些位和秒钟个位8对应的那个位读取有问题(但是里面是有数据的,只是读不出来)
     root@dm816x:/sys/class/rtc/rtc1# cat time
    00:53:44                                   (秒二进制:100 0100)
    root@dm816x:/sys/class/rtc/rtc1# cat time
    00:53:45                                   (秒二进制:100 0101)
    root@dm816x:/sys/class/rtc/rtc1# cat time
    00:53:46                                   (秒二进制:100 0110)
    root@dm816x:/sys/class/rtc/rtc1# cat time
    00:53:47                                   (秒二进制:100 0111)
    root@dm816x:/sys/class/rtc/rtc1# cat time
    00:53:40                                   (秒二进制:100 1000)
    root@dm816x:/sys/class/rtc/rtc1# cat time
    00:53:41                                   (秒二进制:100 1001)
    root@dm816x:/sys/class/rtc/rtc1# cat time 
    00:53:50                                   (秒二进制:101 0000)
    root@dm816x:/sys/class/rtc/rtc1# cat time
    00:53:51                                   (秒二进制:101 0001)
    root@dm816x:/sys/class/rtc/rtc1# cat time
    00:53:52                                   (秒二进制:101 0010)
    root@dm816x:/sys/class/rtc/rtc1# cat time
    00:53:57                                   (秒二进制:101 0111)
    root@dm816x:/sys/class/rtc/rtc1# cat time
    00:53:50                                   (秒二进制:101 1000)
    root@dm816x:/sys/class/rtc/rtc1# cat time
    00:53:51                                   (秒二进制:101 1001)
    root@dm816x:/sys/class/rtc/rtc1# cat time
    00:54:00                                   (秒二进制:000 0000)
    root@dm816x:/sys/class/rtc/rtc1# cat time
    00:54:01                                   (秒二进制:000 0001)
    换了一个好的pcf 8563芯片还是一样的情况。应该不是芯片的问题。

    请问:是 ti_tools/linux_lsp/kernel/linux-dvr-rdk/drivers/rtc/rtc-pcf8563.c 里面设置硬件时钟的程序有错误(把某些位屏蔽了)?

    我需要如何操作?