Loading...
 

Setup Real-time Clock

This page will show you how to activate and program the on-board RTC on MACCHIATObin. There is a battery installed on the MACCHIATObin board to keep the RTC working when the board is not powered on. This way even when the MACCHIATObin is not powered up, the RTC is still working and the date/time will be current once the MACCHIATObin is turned back on.

Activate the RTC

The RTC has to be activated under U-Boot before it can function properly. This is one time activation process, once it is done on a particular board, it does not to be done on this board again.

Under U-Boot command prompt, do the date command a couple of time. If you find the date information is printed incorrectly and the time is not moving at all, that means the RTC is not activated yet.

Marvell>> date
Date: 1996-10-23 (Wednesday)    Time: 16:53:39
Marvell>> date
Date: 1996-10-23 (Wednesday)    Time: 16:53:39
Marvell>> date
Date: 1996-10-23 (Wednesday)    Time: 16:53:39
Marvell>> date
Date: 1996-10-23 (Wednesday)    Time: 16:53:39
Marvell>> date
Date: 1996-10-23 (Wednesday)    Time: 16:53:39


The example above show the date/time is not moving at all. Now issue "date reset" command to activate the RTC.

Marvell>> date reset
Reset RTC...
Date: 1970-01-01 (Thursday)    Time:  0:00:00


Try the date command again, you'll see the second starts moving.

Marvell>> date
Date: 1970-01-01 (Thursday)    Time:  0:00:01
Marvell>> date
Date: 1970-01-01 (Thursday)    Time:  0:00:02
Marvell>> date
Date: 1970-01-01 (Thursday)    Time:  0:00:03

 

Setup RTC in U-Boot


To setup the date/time correctly under U-Boot, use the command below. Note the Date info printed after the date command is the previous date/time info, to confirm your setting is taken by U-Boot, use the date command to confirm again.

Marvell>> date 050523412017
Date: 1970-01-01 (Thursday)    Time:  0:00:47
Marvell>> date
Date: 2017-05-05 (Friday)    Time: 23:41:03


Now you can power down and power up the board again to confirm the date/time is still running even when MACCHIATObin is in the power down state. Please use the help command "help date" to get the detail description of the date command.

Marvell>> help date
date - get/set/reset date & time

Usage:
date [MMDDhhmm[[CC]YY][.ss]]
date reset
  - without arguments: print date & time
  - with numeric argument: set the system date & time
  - with 'reset' argument: reset the RTC

Setup RTC in kernel

You may want to take advantage of the ntp time you can acquire through the network to program the RTC with the precise time on your MACCHIATObin. The example below assumes you are using the Ubuntu file system on MACCHIATObin.

Make sure to setup your MACCHIATObin with network connection and have Internet access in Ubuntu. Install the ntpdate application.

root@localhost:~# apt-get install ntpdate


Update the time with ntpdate, and confirm you have the correct time.

root@localhost:~# ntpdate -s time.nist.gov
root@localhost:~# date
Sat May  6 00:21:04 UTC 2017


Write the current time to RTC.

root@localhost:~# hwclock -w


Now you have updated the RTC on your MACCHIATObin with the correct time.