Real Time Clock (RTC) – NVIDIA Jetson TK1

For some applications using the Jetson TK1, a Real Time Clock (RTC)may be needed. Here’s a demonstration of the steps needed to add one. Looky here:

In this article, we’ll discuss wiring an RTC over I2C to the Jetson, build and install a kernel module for the RTC, and prepare the RTC for use.


In many application using an embedded system it is desirable to have a system clock maintain the correct time when the system is not powered or connected over a network to a clock service. Most desktop/laptop computers have a real time clock in them for this purpose. You probably know about the RTC because after a few years the coin battery that powers the RTC loses power and needs to be replaced. On older desktops especially, a non-working RTC can cause all sorts of mischief when running the system. In embedded systems, or something like the Jetson TK1, an RTC can be a valuable tool.

Note that the Jetson has a built-in RTC, based on the AS3722, which has a small capacitor attached. While this is adequate for a lot of cases, the capacitor does not store enough energy for running the RTC over an extended period of time. The coin battery, on the other hand, can power a RTC for several years.


This demonstration uses a board based on the Dallas DS3231 time clock, a Donop DS3231 AT24C32 IIC module precision RTC” . This board is advertised for use with an Arduino, but will work for our application. This is also true of most of these boards built for Raspberry Pis. The SCL and SDA lines of these boards are typically 3.3V, so make sure to hook up to the appropriate Jetson I2C bus on the J3 headers.

Here’s a pic of the board:
These types of boards typically have circuitry for processing time and a coin battery to keep the circuitry powered when no external power is available. For this application, the RTC board communicates with the Jetson over the I2C serial bus through the J3A1 connector.

The DS3231 is connected to the Jetson J3A1 connector as follows:

GND J3A1-14 -> DS3231 (GND)
VCC J3A1-16 -> DS3231 (VCC – 3.3V)
SCL J3A1-18 -> DS3231 (SCL)
SDA J3A1-20 -> DS3231 (SDA)

Here are some pictures from the Jetson Wiki of J3A1 for reference :

There are several ways to actually connect the headers to the Jetson J3A1 connector, in this demo we use simple female to female jumper wires (0.1″ spacing, 2.54mm pitch – this is standard Arduino size) to attach to the DS3231, and then connect the jumper wire to a machine pin jumper wire, which is then connected to the Jetson. You should choose a more robust attachment method when applying this to your own application.

As a reminder, here’s the layout of the J3A1 connector, taken from the Jetson TK1 wiki:



Software – Kernel Module

After wiring the DS3231, it will need what is called a kernel module to interface with the Jetson operating system, L4T. There are a couple of ways to get the kernel module, the easiest of which is to install the Grinch kernel. Here’s an article on how to install the Grinch. Of course, you can also build the module for the kernel yourself. There happens to be a repository on the JetsonHacks Github account with a script to build and install the DS3231 module of which you may want to take advantage. The Grinch is a great community resource which includes may modules and drivers, but if you only need a module or two and are willing to take on the task of building modules on your own, you may find the JetsonHacks script useful. Season to taste as needed.

To build the DS3231 module:

$ git clone
$ cd buildJetsonRTCModule
$ sudo ./

If you read through the install script, you’ll see that the actual module being compiled is for a Dallas DS1307. The DS1307 is register compatible with the DS3231, so that is the module being used. Executing the script will download the Linux kernel source, compile the DS3231 module, and then install the DS3231 module.

Software Setup and Installation

In order to be able inspect the DS3231, you may find it useful to install the i2c tools:

$ sudo apt-get install libi2c-dev i2c-tools

After installation, in a Terminal execute:

$ sudo i2cdetect -y -r 1

You should see an entry of 0x68, which is the address of the DS3231.
Next, attach the device:

$ echo ds3231 0x68 | sudo tee /sys/class/i2c-dev/i2c-1/device/new_device

The RTC should show up as /dev/rtc1. You should be able to read the time stored in the RTC:

sudo hwclock -r -f /dev/rtc1

Note: Upon installation, this time will probably not reflect the system time. These devices come from the factory set at 12-31-1999, presumambly because they are ready to party.

You should be ready to write the system time to the RTC. If your system time is not correct, the Terminal command form to set the system time is:

$ sudo date –set “2015-8-15 23:00:00”

Note: You can see the system date and time by executing:

$ date

on the Terminal. This is also available through the system GUI, either in the System Settings dialogs or the clock in the toolbar.

To write the current system time to the RTC:

$ sudo hwclock -w -f /dev/rtc1

After writing the time to the RTC (hwclock), you can read it back to make sure it is correct.

When the Jetson boots, we want the Jetson to read the time from the new RTC and set the system time. In order to accomplish this task, modify a file called ‘/etc/rc.local’ which is a script that runs on system startup. You can edit this file using:

$ sudo gedit /etc/rc.local

Add two lines to the file before the ‘exit’ command:

echo ds3231 0x68 | sudo tee /sys/class/i2c-dev/i2c-1/device/new_device
sudo hwclock -s -f /dev/rtc1

and save the file. On startup, these commands will attach the clock, and then set the system time from the RTC.

Reboot the machine for the changes to take effect.


Because there are now two RTCs installed, you may want to do something called ‘blacklisting’ the on-board AS3722. This will cause the AS3722 module to not be loaded when the system boots. To the file ‘/etc/modprobe.d/blacklist.conf’ (using $ sudo gedit), add the line:

blacklist rtc_as3722

Then, modify the /etc/rc.local file as described previously and change the hwclock command to:

sudo hwclock -s -f /dev/rtc0

The DS3231 should now be on /dev/rtc0 with the blacklisting of the AS3722 module.

Note: Much of this articles information was taken from a Santyago post on the Jetson Forum and the RTC article on the Jetson Wiki.

Note: This demonstration was done on Linux for Tegra (L4T) 21.4 on a clean install with the JetsonHacks postFlash script applied.


Leave a Reply

Your email address will not be published.