Hi,
I am currently learning how to interface DS1337 with LPC17xx Board. I am using uclinux2.6.33 right now. The drivers are also present in drivers/rtc/rtc-ds1307.c
Here is my .config sample :
Code:
CONFIG_RTC_LIB=y
CONFIG_RTC_CLASS=y
CONFIG_RTC_HCTOSYS=y
CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
CONFIG_RTC_DEBUG=y
#
# RTC interfaces
#
CONFIG_RTC_INTF_SYSFS=y
CONFIG_RTC_INTF_PROC=y
CONFIG_RTC_INTF_DEV=y
CONFIG_RTC_INTF_DEV_UIE_EMUL=y
CONFIG_RTC_DRV_TEST=y
#
# I2C RTC drivers
#
CONFIG_RTC_DRV_DS1307=y
# CONFIG_RTC_DRV_DS1374 is not set
# CONFIG_RTC_DRV_DS1672 is not set
# CONFIG_RTC_DRV_MAX6900 is not set
# CONFIG_RTC_DRV_RS5C372 is not set
# CONFIG_RTC_DRV_ISL1208 is not set
# CONFIG_RTC_DRV_X1205 is not set
# CONFIG_RTC_DRV_PCF8563 is not set
# CONFIG_RTC_DRV_PCF8583 is not set
# CONFIG_RTC_DRV_M41T80 is not set
# CONFIG_RTC_DRV_BQ32K is not set
# CONFIG_RTC_DRV_S35390A is not set
# CONFIG_RTC_DRV_FM3130 is not set
# CONFIG_RTC_DRV_RX8581 is not set
# CONFIG_RTC_DRV_RX8025 is not set
#
# SPI RTC drivers
#
#
# Platform RTC drivers
#
CONFIG_RTC_DRV_CMOS=y
# CONFIG_RTC_DRV_DS1286 is not set
# CONFIG_RTC_DRV_DS1511 is not set
# CONFIG_RTC_DRV_DS1553 is not set
# CONFIG_RTC_DRV_DS1742 is not set
# CONFIG_RTC_DRV_STK17TA8 is not set
# CONFIG_RTC_DRV_M48T86 is not set
# CONFIG_RTC_DRV_M48T35 is not set
# CONFIG_RTC_DRV_M48T59 is not set
# CONFIG_RTC_DRV_MSM6242 is not set
# CONFIG_RTC_DRV_BQ4802 is not set
# CONFIG_RTC_DRV_RP5C01 is not set
# CONFIG_RTC_DRV_V3020 is not set
#
# on-CPU RTC drivers
#
# CONFIG_RTC_DRV_PL030 is not set
# CONFIG_RTC_DRV_PL031 is not set
# CONFIG_RTC_DRV_LPC178X is not set
# CONFIG_DMADEVICES is not set
# CONFIG_AUXDISPLAY is not set
# CONFIG_UIO is not set
Kernel Logs ::
Code:
Booting kernel from Legacy Image at a0000000 ...
Image Name: Linux-2.6.33-arm1
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1384224 Bytes = 1.3 MB
Load Address: a0008000
Entry Point: a0008001
Verifying Checksum ... OK
Loading Kernel Image ... OK
OK
Starting kernel ...
�Linux version 2.6.33-arm1 (vk18434@vk18434-OptiPlex-9010) (gcc version 4.4.1 (Sourcery G++ Lite 2010q1-189) ) #238 Wed M4
CPU: ARMv7-M Processor [412fc230] revision 0 (ARMv7M)
CPU: NO data cache, NO instruction cache
Machine: NXP LPC178x/7x
Built 1 zonelists in Zone order, mobility grouping off. Total pages: 8128
Kernel command line: lpc178x_platform=ea-lpc1788 console=ttyS0,115200 panic=10 ethaddr=C0:B1:3C:88:88:88
PID hash table entries: 128 (order: -3, 512 bytes)
Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
Memory: 32MB = 32MB total
Memory: 31076k/31076k available, 1692k reserved, 0K highmem
Virtual kernel memory layout:
vector : 0x00000000 - 0x00001000 ( 4 kB)
fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB)
vmalloc : 0x00000000 - 0xffffffff (4095 MB)
lowmem : 0xa0000000 - 0xa2000000 ( 32 MB)
modules : 0xa0000000 - 0x01000000 (1552 MB)
.init : 0xa0008000 - 0xa0058000 ( 320 kB)
.text : 0xa0058000 - 0xa014b000 ( 972 kB)
.data : 0xa014c000 - 0xa0159f20 ( 56 kB)
Hierarchical RCU implementation.
NR_IRQS:41
Calibrating delay loop... 31.23 BogoMIPS (lpj=156160)
Mount-cache hash table entries: 512
NET: Registered protocol family 16
I2C: i2c-0: LPC2K I2C adapter
I2C: i2c-1: LPC2K I2C adapter
I2C: i2c-2: LPC2K I2C adapter
Switching to clocksource cm3-systick
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 1024 (order: 1, 8192 bytes)
TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
TCP: Hash tables configured (established 1024 bind 1024)
TCP reno registered
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
Serial: 8250/16550 driver, 2 ports, IRQ sharing disabled
serial8250.0: ttyS0 at MMIO 0x4000c000 (irq = 5) is a 16550A
console [ttyS0] enabled
serial8250.2: ttyS1 at MMIO 0x40098000 (irq = 7) is a 16550A
lpc_mii_bus: probed
eth0: using RMII interface
eth0: LPC mac at 0x20084000 irq 28
eth0: attached PHY driver [Generic PHY] (mii_bus:phy_addr=0:01, irq=-1)
~~~~~~~~~~~~~~~~~~~~~~~~
In DS1337 Probe function
~~~~~~~~~~~~~~~~~~~~~~~~
ds1307->type=0
ds1307->type=0
tmp=8
~~~~~~~~~~~~~~~~~~~~~~~~
tmp=69
~~~~~~~~~~~~~~~~~~~~~~~~
RTC_DS1337 0-0068: rtc core: registered RTC_DS1337 as rtc0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rtc_device_register successfull
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
RTC_DS1337 0-0068: 56 bytes nvram
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Probe function called successfully
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rtc-test rtc-test.0: rtc core: registered test as rtc1
rtc-test rtc-test.1: rtc core: registered test as rtc2
i2c /dev entries driver
TCP cubic registered
NET: Registered protocol family 17
t=-1608777852
RTC_DS1337 0-0068: setting system clock to 2000-01-01 01:02:45 UTC (946688565)
Freeing init memory: 320K
init started: BusyBox v1.17.0 (2014-03-25 15:47:56 IST)
~ #
Now I am able to set the date, but after resetting my LPC17xx, I am unable to read the present date.
i still see the below line ::
RTC_DS1337 0-0068: setting system clock to 2000-01-01 01:02:45 UTC (946688565)
Any help would be appreciated.
~ #date -u "2014-03-26 16:29:00"
Wed Mar 26 16:29:00 UTC 2014
~ # hwclock -u -w
hush: can't execute 'hwclock': No such file or directory
I am following the present page right now ::
Code:
https://developer.ridgerun.com/wiki/index.php/How_to_use_RTC_Real_Time_Clock_hardware
I also got some more info from cat/proc/kmsg
Code:
~ # cat /proc/kmsg
app bin/ dev/ etc/ mnt/ proc/ root/ sys/ usr/ var/
~ # cat /proc/kmsg
<5>Linux version 2.6.33-arm1 (vk18434@vk18434-OptiPlex-9010) (gcc version 4.4.1 (Sourcery G++ Lite 2010q1-1894
<4>CPU: ARMv7-M Processor [412fc230] revision 0 (ARMv7M)
<4>CPU: NO data cache, NO instruction cache
<4>Machine: NXP LPC178x/7x
<7>On node 0 totalpages: 8192
<7>free_area_init_node: node 0, pgdat a01c5dd4, node_mem_map a05af000
<7> Normal zone: 64 pages used for memmap
<7> Normal zone: 0 pages reserved
<7> Normal zone: 8128 pages, LIFO batch:0
<4>Built 1 zonelists in Zone order, mobility grouping off. Total pages: 8128
<5>Kernel command line: lpc178x_platform=ea-lpc1788 console=ttyS0,115200 panic=10 ethaddr=C0:B1:3C:88:88:88
<6>PID hash table entries: 128 (order: -3, 512 bytes)
<6>Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
<6>Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
<6>Memory: 32MB = 32MB total
<5>Memory: 26700k/26700k available, 6068k reserved, 0K highmem
<5>Virtual kernel memory layout:
<5> vector : 0x00000000 - 0x00001000 ( 4 kB)
<5> fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB)
<5> vmalloc : 0x00000000 - 0xffffffff (4095 MB)
<5> lowmem : 0xa0000000 - 0xa2000000 ( 32 MB)
<5> modules : 0xa0000000 - 0x01000000 (1552 MB)
<5> .init : 0xa0008000 - 0xa0059000 ( 324 kB)
<5> .text : 0xa0059000 - 0xa01b3000 (1384 kB)
<5> .data : 0xa01b4000 - 0xa01c6e00 ( 76 kB)
<6>Hierarchical RCU implementation.
<6>NR_IRQS:41
<4>Lock dependency validator: Copyright (c) 2006 Red Hat, Inc., Ingo Molnar
<4>... MAX_LOCKDEP_SUBCLASSES: 8
<4>... MAX_LOCK_DEPTH: 48
<4>... MAX_LOCKDEP_KEYS: 8191
<4>... CLASSHASH_SIZE: 4096
<4>... MAX_LOCKDEP_ENTRIES: 16384
<4>... MAX_LOCKDEP_CHAINS: 32768
<4>... CHAINHASH_SIZE: 16384
<4> memory used by lock dependency info: 3679 kB
<4> per task-struct memory footprint: 1152 bytes
<6>Calibrating delay loop... 29.79 BogoMIPS (lpj=148992)
<4>Mount-cache hash table entries: 512
<7>PM: Adding info for No Bus:platform
<6>NET: Registered protocol family 16
<7>i2c-core: driver [dummy] registered
<7>PM: Adding info for platform:serial8250.0
<7>PM: Adding info for platform:serial8250.2
<7>PM: Adding info for platform:lpc-net.0
<7>PM: Adding info for platform:lpc2k-i2c.0
<7>PM: Adding info for platform:lpc2k-i2c.1
<7>PM: Adding info for platform:lpc2k-i2c.2
<7>PM: Adding info for platform:gen_nand
<7>PM: Adding info for platform:rtc0
<7>PM: Adding info for No Bus:default
<7>PM: Adding info for i2c:i2c-0
<7>i2c i2c-0: adapter [lpc2k-i2c.0] registered
<7>PM: Adding info for i2c:0-0068
<7>i2c i2c-0: client [RTC_DS1337] registered with bus id 0-0068
<6>I2C: i2c-0: LPC2K I2C adapter
<7>PM: Adding info for i2c:i2c-1
<7>i2c i2c-1: adapter [lpc2k-i2c.1] registered
<6>I2C: i2c-1: LPC2K I2C adapter
<7>PM: Adding info for i2c:i2c-2
<7>i2c i2c-2: adapter [lpc2k-i2c.2] registered
<6>I2C: i2c-2: LPC2K I2C adapter
<7>PM: Adding info for No Bus:lo
<6>Switching to clocksource cm3-systick
<7>PM: Adding info for No Bus:mem
<7>PM: Adding info for No Bus:null
<7>PM: Adding info for No Bus:zero
<7>PM: Adding info for No Bus:full
<7>PM: Adding info for No Bus:random
<7>PM: Adding info for No Bus:urandom
<7>PM: Adding info for No Bus:kmsg
<6>NET: Registered protocol family 2
<6>IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
<6>TCP established hash table entries: 1024 (order: 1, 8192 bytes)
<6>TCP bind hash table entries: 1024 (order: 3, 32768 bytes)
<6>TCP: Hash tables configured (established 1024 bind 1024)
<6>TCP reno registered
<6>RPC: Registered udp transport module.
<6>RPC: Registered tcp transport module.
<6>RPC: Registered tcp NFSv4.1 backchannel transport module.
<4>====[ backtrace testing ]===========
<4>Testing a backtrace from process context.
<4>The following trace is a kernel self test and not a bug!
<4>Backtrace: no frame pointer
<4>Testing a backtrace from irq context.
<4>The following trace is a kernel self test and not a bug!
<4>Backtrace: invalid frame pointer 0x00000006
<4>Testing a saved backtrace.
<4>The following trace is a kernel self test and not a bug!
<4> [] save_stack_trace_tsk+0x1/0x78
<4> [] 0xffffffff
<4>====[ end of backtrace testing ]====
<7>PM: Adding info for No Bus:tty
<7>PM: Adding info for No Bus:console
<7>PM: Adding info for No Bus:ptmx
<7>PM: Adding info for No Bus:apm_bios
<6>Serial: 8250/16550 driver, 2 ports, IRQ sharing disabled
<7>PM: Adding info for platform:serial8250
<7>PM: Adding info for No Bus:ttyS0
<7>PM: Adding info for No Bus:ttyS1
<7>PM: Removing info for No Bus:ttyS0
<6>serial8250.0: ttyS0 at MMIO 0x4000c000 (irq = 5) is a 16550A
<6>console [ttyS0] enabled
<7>PM: Adding info for No Bus:ttyS0
<7>PM: Removing info for No Bus:ttyS1
<6>serial8250.2: ttyS1 at MMIO 0x40098000 (irq = 7) is a 16550A
<7>PM: Adding info for No Bus:ttyS1
<7>PM: Adding info for No Bus:eth0
<7>PM: Adding info for No Bus:0
<7>PM: Adding info for mdio_bus:0:01
<6>lpc_mii_bus: probed
<6>eth0: using RMII interface
<6>eth0: LPC mac at 0x20084000 irq 28
<6>eth0: attached PHY driver [Generic PHY] (mii_bus:phy_addr=0:01, irq=-1)
<7>RTC_DS1337 0-0068: probe
<6>In DS1337 Probe function
<6>~~~~~~~~~~~~~~~~~~~~~~~~
<6>In i2c_check_functionality
<6>ds1307->type=0
<7>i2c i2c-0: master_xfer[0] W, addr=0x68, len=1
<7>i2c i2c-0: master_xfer[1] R, addr=0x68, len=8
<7>i2c i2c-0: Processing total messages = 2
<7>i2c i2c-0: Processing message 0 (len=1) (flags=0)
<7>i2c i2c-0: Start sent
<7>i2c i2c-0: Start sent, sending address 0xd0
<7>i2c i2c-0: ACK ok, sending (0x00)
<7>i2c i2c-0: ACK ok, idling until next message start
<7>i2c i2c-0: Transfer successful
<7>i2c i2c-0: Processing message 1 (len=8) (flags=1)
<7>i2c i2c-0: Repeated start sent
<7>i2c i2c-0: Start sent, sending address 0xd1
<7>i2c i2c-0: ACK ok, received (0x08)
<7>i2c i2c-0: ACK ok, received (0x49)
<7>i2c i2c-0: ACK ok, received (0x01)
<7>i2c i2c-0: ACK ok, received (0x01)
<7>i2c i2c-0: ACK ok, received (0x01)
<7>i2c i2c-0: ACK ok, received (0x01)
<7>i2c i2c-0: ACK ok, received (0x00)
<7>i2c i2c-0: ACK ok, received (0x00)
<7>i2c i2c-0: ACK ok, sending stop
<7>i2c i2c-0: ACK ok, idling until next message start
<7>i2c i2c-0: Transfer successful
<7>PM: Adding info for No Bus:rtc0
<7>RTC_DS1337: dev (254:0)
<6>RTC_DS1337 0-0068: rtc core: registered RTC_DS1337 as rtc0
<6>rtc_device_register successfull
<6>RTC_DS1337 0-0068: 56 bytes nvram
<6>End of Probe function
<7>i2c-core: driver [RTC_DS1337] registered
<6>cpuidle: using governor ladder
<6>TCP cubic registered
<6>NET: Registered protocol family 17
<7>PM: Adding info for No Bus:cpu_dma_latency
<7>PM: Adding info for No Bus:network_latency
<7>PM: Adding info for No Bus:network_throughput
<6>Inside rtc_read_time function in (driver/rtc/interface.c)
<6>err=0
<6>-----------------------------In ds1307_get_time---------------------------
<7>i2c i2c-0: master_xfer[0] W, addr=0x68, len=1
<7>i2c i2c-0: master_xfer[1] R, addr=0x68, len=7
<7>i2c i2c-0: Processing total messages = 2
<7>i2c i2c-0: Processing message 0 (len=1) (flags=0)
<7>i2c i2c-0: Start sent
<7>i2c i2c-0: Start sent, sending address 0xd0
<7>i2c i2c-0: ACK ok, sending (0x00)
<7>i2c i2c-0: ACK ok, idling until next message start
<7>i2c i2c-0: Transfer successful
<7>i2c i2c-0: Processing message 1 (len=7) (flags=1)
<7>i2c i2c-0: Repeated start sent
<7>i2c i2c-0: Start sent, sending address 0xd1
<7>i2c i2c-0: ACK ok, received (0x08)
<7>i2c i2c-0: ACK ok, received (0x49)
<7>i2c i2c-0: ACK ok, received (0x01)
<7>i2c i2c-0: ACK ok, received (0x01)
<7>i2c i2c-0: ACK ok, received (0x01)
<7>i2c i2c-0: ACK ok, received (0x01)
<7>i2c i2c-0: ACK ok, received (0x00)
<7>i2c i2c-0: ACK ok, sending stop
<7>i2c i2c-0: ACK ok, idling until next message start
<7>i2c i2c-0: Transfer successful
<7>RTC_DS1337 0-0068: read: 08 49 01 01 01 01 00
<6>read secs=8, mins=49,hours=1, mday=1, mon=0, year=100, wday=0
<6>tm->tm_year=100
<6>tm->tm_year=100
<6>~~~~~~~~~~Inside rtc_tm_to_time~~~~~~~~~~~~~
<6>time=-1604280424
<6>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<6>Inside do_settimeofday function in Timekeeping.c (linux/kernel/time
<6>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<6>Inside Hctosys.c (drivers/rtc)
<6>RTC_DS1337 0-0068: setting system clock to 2000-01-01 01:49:08 UTC (946691348)
<6>Freeing init memory: 324K
Any help would be really appreciated.
All I want to do is set the time and read the time.
Br
vk41286