Interfacing DS1337 Real Time Clock

Go To Last Post
5 posts / 0 new
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Has anyone managed to get the DS1337 I2C Real-Time Clock functioning on an AVR32 Linux system? I've added the relevant data to the i2c_board_info struct, but the clock does not appear under /dev.

However, probing the i2c bus with the i2cdetect utility, I notice that the RTC shows up at address 0x68. So I know that it is attached, but how do I access it? Is this the right address to pass into the i2c_board_info struct?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

nkinar wrote:
Has anyone managed to get the DS1337 I2C Real-Time Clock functioning on an AVR32 Linux system?

Hello! We have an RTC onboard our system.

It is actually a DS3232 chip, but uses the 1307 driver. If you add just

I2C_BOARD_INFO("ds1337", 0x68)
to your setup.c, you should be fine. (Or an other appropriate address)
Do you see anything in dmesg after insmod or modprobe the 1307 driver?

In lsmod, the driver displays as rtc_ds1307, and your RTC should be visible in /dev and /sys/class/rtc.

My RTC has the address 0x68, but I'm not sure if that is default and unchangeable, or if that is controlled by IO-pins on the RTC-chip. Check the data sheet.

Good luck!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Roger--

Thank you for your help! The hardware clock works well, and I am able to see /dev/rtc1 and /sys/class/rtc1. On my system, rtc0 defaults to the Atmel AVR32 system clock.

Here's what I did to get this started. The i2c board info struct is:

static struct i2c_board_info __initdata i2c_info[] = {

	/*Add support for DS1337 RTC*/

In my initial trial, I had the name of the driver "rtc-ds1307" listed in I2C_BOARD_INFO instead of "ds1337". Then, in the board setup code, I add the i2c_board_info struct:

i2c_register_board_info(0, i2c_info, ARRAY_SIZE(i2c_info));

Because there are no I2C address pins on the DS1337, there is no need to change the address. The address of the DS1337 is fixed at 0x68. However, this also implies that only one device of the DS1337 is allowed on the I2C bus.

To load the driver,

modprobe rtc-ds1307

The RTC shows up as rtc1 in the dmesg log.

Thank you once again for your help, roger! :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


I couldn't manage to work external rtc (DS1337) with my Atngw100 board. I changed the setup.c and config files.But I couldn't see /dev/rtc1 device.

My bootlog is

U-Boot 1.3.4-atmel.buildroot.1 (Aug  1 2010 - 01:25:36) 

U-Boot code: 00000000 -> 000110b8  data: 00017998 -> 0004e2a8
CPU: 140 Mhz HSB: 70 MHz PBA: 35 MHz PBB: 70 MHz
malloc: Using memory from 0x11f71000 to 0x11fb1000
DMA: Using memory from 0x11f6d000 to 0x11f71000
Flash:  8 MB at address 0x00000000
DRAM Configuration:
Bank #0: 10000000 32 MB
In:    serial
Out:   serial
Err:   serial
Net:   macb0
Press SPACE to abort autoboot in 1 seconds
## Booting kernel from Legacy Image at 00040000 ...
   Image Name:   Linux-
   Image Type:   AVR32 Linux Kernel Image (gzip compressed)
   Data Size:    1252685 Bytes =  1.2 MB
   Load Address: 10000000
   Entry Point:  90000000
   Verifying Checksum ... OK
   Uncompressing Kernel Image ... OK

Starting kernel at 90000000 (params at 11f71008)...

Linux version (root@erhan-laptop) (gcc version 4.2.2-atmel.1.1.3.buildroot.1) #20 Mon Sep 6 15:40:58 EEST 2010
CPU: AT32AP700x chip revision C
CPU: AP7 [01] core revision 0 (AVR32B arch revision 1)
CPU: MMU configuration: Shared TLB
CPU: features: dsp simd ocd perfctr java
CPU: Running at 140.000 MHz
Physical memory:
Reserved memory:
  10000000-101818af: Kernel code
  101818b0-10219407: Kernel data
Exception vectors start at 90013000
CPU: Paging enabled
Node 0: start_pfn = 0x10000, low = 0x12000
Node 0: mem_map starts at 9021c000
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 8128
Kernel command line: console=ttyS0 root=/dev/mtdblock2 rootfstype=jffs2
PID hash table entries: 128 (order: 7, 512 bytes)
avr32_comparator: irq 0, 140.000 MHz
console [ttyS0] enabled
Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
Memory: 30328k/30328k available (1466k kernel code, 2440k reserved, 111k data, 76k init)
SLUB: Genslabs=10, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Calibrating delay using timer specific routine.. 281.85 BogoMIPS (lpj=563715)
Mount-cache hash table entries: 512
net_namespace: 756 bytes
smc smc.0: Atmel Static Memory Controller at 0xfff03400
NET: Registered protocol family 16
add i2c_gpio_device ret : 0
pdc pdc.0: Atmel Peripheral DMA Controller enabled
at32_eic at32_eic.0: External Interrupt Controller at 0xfff00100, IRQ 19
at32_eic at32_eic.0: Handling 4 external IRQs, starting with IRQ 64
AVR32 AP Power Management enabled
dw_dmac.0: DesignWare DMA Controller, 3 channels
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
NET: Registered protocol family 1
JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
msgmni has been set to 59
io scheduler noop registered
io scheduler cfq registered (default)
atmel_usart.0: ttyS0 at MMIO 0xffe01000 (irq = 7) is a ATMEL_SERIAL
atmel_usart.1: ttyS1 at MMIO 0xffe01400 (irq = 8) is a ATMEL_SERIAL
MACB_mii_bus: probed
eth0: Atmel MACB at 0xfff01800 irq 25 (00:11:95:00:00:00)
eth0: attached PHY driver [Generic PHY] (mii_bus:phy_addr=0:01, irq=-1)
physmap platform flash device: 00800000 at 00000000
physmap-flash.0: Found 1 x16 devices at 0x0 in 16-bit bank
 Amd/Fujitsu Extended Query Table at 0x0041
number of CFI chips: 1
cfi_cmdset_0002: Disabling erase-suspend-program due to code brokenness.
RedBoot partition parsing not available
Using physmap partition information
Creating 4 MTD partitions on "physmap-flash.0":
0x00000000-0x00040000 : "u-boot"
0x00040000-0x00200000 : "kernel"
0x00200000-0x007f0000 : "root"
0x007f0000-0x00800000 : "env"
atmel_spi atmel_spi.0: Atmel SPI Controller at 0xffe00000 (irq 3)
atmel_spi atmel_spi.0: Using bounce buffer at 0x24000000 len 4096
mtd_dataflash spi0.0: AT45DB642x (8448 KBytes) pagesize 1056 bytes
at32ap700x_rtc at32ap700x_rtc.0: rtc core: registered at32ap700x_rtc as rtc0
at32ap700x_rtc at32ap700x_rtc.0: Atmel RTC for AT32AP700x at fff00080 irq 21
at32_wdt at32_wdt.0: AT32 WDT at 0xfff000b0, timeout 2 sec (nowayout=0)
Registered led device: sys
Registered led device: a
Registered led device: b
TCP cubic registered
Initializing XFRM netlink socket
NET: Registered protocol family 10
IPv6 over IPv4 tunneling driver
NET: Registered protocol family 17
NET: Registered protocol family 15
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
cpufreq: AT32AP CPU frequency driver
drivers/rtc/hctosys.c: unable to open rtc device (rtc1)
VFS: Mounted root (jffs2 filesystem).
Freeing init memory: 76K (90000000 - 90013000)
init started: BusyBox v1.13.1 (2008-12-18 14:53:49 CET)
Mounting virtual filesystems:
  /proc mounted
  /sys mounted
  /dev mounted
  /dev/pts directory made
  /dev/pts mounted
  /dev/shm directory made
  /config mounted
  /tmp mounted
  /var/run mounted
  /var/log mounted
Setting up mdev: done
Setting hostname: ''
Starting syslogd: done
Log messages to syslog: done
Starting klogd: done
Probing modules: 
Starting portmap: done
Network interfaces: done
Starting ProFTPD: done

kernel says : drivers/rtc/hctosys.c: unable to open rtc device (rtc1)

I think i2c_gpio must be init before hctosys.c.May be this is the problem.I attached the setup.c and defconfig files.

Please help me
Thanks for advice


  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


Yes, you must load the i2c_gpio-module before you try to load the ds1337-module. However, if you try loading the module by modprobe rtc-ds1307 you should be fine, since dependencies should be solved. Make sure you have enabled I2C in the kernel?