Difference between revisions of "RTC"

From ArmadeusWiki
Jump to: navigation, search
(Configuration)
m
 
(44 intermediate revisions by 5 users not shown)
Line 1: Line 1:
On this page, you will find usefull informations to use an external DS1374 Real Time Clock.
+
On this page, you will find useful informations to use the Real Time Clock of your boards (if chip is mounted).
This feature apply to the armadeus software release 2.0 and above.
+
  
 
== Hardware ==
 
== Hardware ==
 +
===APF9328/APF27===
 +
No permanent RTC is present on the [[APF9328]]/[[APF27]] modules, but you can have one (DS1374, as an option) on the development boards or add it yourself if you are an electrician (it is not so complex to add a DS1374 (with integrated quartz) on the I2C bus). Do not forget to provide the two power-supply (VCC and Vbackup)).
 +
Currently only Maxim's DS1374 has been tested on [[APF9328Dev]]/[[APF27Dev]] but any I2C RTC, supported by Linux, should work the same way.
  
No permanent RTC is present on the APF9328 but it is not so complex to add a DS1374 (with quartz integrated) on the I2C bus. Do not forget to provide the power-supply.
+
===APF51/APF28===
 +
[[APF51]] and [[APF28]] modules have an onboard PMIC with an integrated RTC.
 +
[[APF51Dev]] has a CR032 receptacle to allow APF51 RTC backup.
  
== Configuration ==
+
===APF6===
 +
[[APF6Dev]] has an onboard external RTC chip: MCP794000.
  
 +
== Driver installation ==
 +
===APF9328/APF27===
 +
DS1374 driver is by default included in standard Armadeus Linux kernel. To check if your board (Linux) has correctly detected the RTC:
 +
<pre class="apf">
 +
# dmesg | grep ds1374
 +
ds1374-legacy 0-0068: chip found, driver version 1.0
 +
ds1374-legacy 0-0068: rtc core: registered ds1374-legacy as rtc0
 +
ds1374-legacy 0-0068: setting system clock to 1970-01-01 00:00:07 UTC (7)
 +
</pre>
  
First be sure to use an armadeus 2.0 or higher.
+
===APF51===
The RTC/DS1374 support is already present in U-BOOT and linux kernel 2.6.18.1 and higher.
+
Driver is by default installed and launched. To check if your board (Linux) has correctly detected the RTC:
Therefore you have nothing to configure to use the RTC.
+
<pre class="apf">
Nevertheless these are the parameters to check to have the RTC supported:
+
# dmesg | grep rtc
$ make linux-menuconfig
+
wm831x-rtc wm831x-rtc: rtc core: registered wm831x as rtc0
** check the i2c module drivers  i2c-imx  and i2c-dev 
+
wm831x-rtc wm831x-rtc: setting system clock to 2011-05-03 13:27:26 UTC (1304429246)
** check the RTC module driver rtc-dev and rtc-ds1374
+
</pre>
** if you intagrates these module statically in the kernel then the system date will be set at power-up.
+
** fix me..;
+
$ make
+
and reload your kernel and/or rootfs
+
  
== Installation ==
+
===APF28===
  
== Usage ==
+
On APF28 the RTC is integrated under the [http://www.freescale.com/webapp/sps/site/taxonomy.jsp?code=IMX28_FAMILY i.MX28] processor. See the reference manual chapter 22 "Real-Time Clock Alarm Watchdog Persistent Bits".
Load the module:
+
# insmod /lib/modules/kernel/pwm/pwm.ko
+
  
...........
+
There isn't button-lithium backup battery under APF28dev board, if we unplug the power, clock is not saved and then we could ask : what the interest of RTC if not backuped ?
  
 +
The interest is when we power the whole board with a battery and we poweroff the apf28 with the command :
 +
 +
<pre class="apf">
 +
$ poweroff
 +
</pre>
 +
 +
The processor will be powered of ... except the RTC. Then we could power on the board pushing power switch and keep the clock up to date.
 +
 +
{{Warning| To enable poweroff on APF28dev the board must be powered by battery (J10 pin 4) and the USB-powering must be disconnected. To disconnect it, just '''unsolder the self L7''' (behind the usb J3 connector)}}
 +
{{Note| Currently, the clock doesn't work in poweroff it must be fixed. The date and hour are keeped but not incremented}}
 +
 +
==== Clock ====
 +
 +
To read the hardware value of clock use hwclock command on file /dev/rtc0:
 +
 +
==== Keep clock ====
 +
 +
To power off the board type :
 +
 +
<pre class="apf">
 +
# poweroff
 +
The system is going down NOW!
 +
Sent SIGTERM to all processes
 +
Sent SIGKILL to all processes
 +
P
 +
Communications disconnect (Back at localhost)
 +
----------------------------------------------------
 +
(/home/fabien/) C-Kermit>
 +
</pre>
 +
 +
And to wake-up the board push the button 'ON'. The date and hour will be keeped when you type 'date' or 'hwclock'.
 +
 +
===APF6===
 +
MCP794000 driver is integrated by default in armadeus BSP's Linux kernel for [[APF6]].
 +
<pre class="apf">
 +
# dmesg | grep mcp
 +
[    1.665275] rtc-mcp7940x 1-006f: rtc core: registered mcp7940x-rtc as rtc0
 +
</pre>
 +
 +
== Usage ==
 +
{{Note|We recommand to store time in [[wikipedia:UTC|UTC]] format in the RTC; that will ease the timezone/summer time handling.}}
 +
* From Linux use the command '''hwclock''' to read, write, synchronize the RTC (here we pre-suppose that RTC is storing time in UTC format).
 +
<pre class="apf">
 +
# hwclock --help
 +
# hwclock -r -u      to read hardware clock and print result (localtime)
 +
# hwclock -s -u      to set the system time from the hardware clock
 +
# hwclock -w -u      to set the hardware clock to the current system time (UTC)
 +
</pre>
 +
{{Warning|Security "features" prevent to change RTC time more than 8 times per hour '''on the APF51''' !!}}
 +
* Use '''date''' command to read and update system date and time while running:
 +
<pre class="apf">
 +
# date --help        for more information
 +
# date -R            to read hardware clock and print result
 +
# date 013122302011          to sets the system date to january 31th 2011 22h30 (localtime)
 +
# date 2011.01.31-22:30:00    also do the job
 +
</pre>
 +
* Then, when booting you will see something like this:
 +
<pre class="apf">
 +
ds1374 0-0068: setting the system clock to 2011-xxxx
 +
or
 +
wm831x-rtc wm831x-rtc: setting system clock to 2011-xxxx
 +
</pre>
 +
* TimeZone/Summer time handling can be configured in ''/etc/TZ'' (uClibc particularity):
 +
<pre class="apf">
 +
# cat /etc/TZ
 +
CET-1DST,M3.5.0/2:00,M10.5.0/3:00
 +
</pre>
 +
Examples for TZ can be found here:http://www.sonoracomm.com/support/20-voice-support/107-uclibc-tz
 +
 +
* you can update RTC from a NTP (Network Time Protocol) server if your board is connected to internet or a NTP server
 +
<pre class="apf">
 +
# ntpd -nqp 217.147.208.1
 +
ntpd: setting clock to Mon Apr 23 22:36:39 DST 2012 (offset 1335216961.855897s)
 +
# hwclock -wu  # to set the hardware clock to the current system time (UTC)
 +
</pre>
 +
* if Alarm/wakeup is supported by the RTC driver then the alarm/wakeup time may be set like that for a 60 sec delay with RTC0
 +
<pre class="apf">
 +
# sec=`date '+%s'`
 +
# let "sec=$sec+60"
 +
# echo $sec > /sys/class/rtc/rtc0/wakealarm
 +
</pre>
 +
* if the time specified in wakealarm is earlier than the current time, then the Alarm/wakeup is disabled
  
 
== Links ==
 
== Links ==
*  
+
* [http://datasheets.maxim-ic.com/en/ds/DS1374-DS1374U.pdf Maxim's DS1374 datasheet]
*
+
* [http://www.yoannsculo.fr/uclibc-et-timezone-info-tz/ uClibc et Timezone Info (TZ)] (French)
 +
 
 +
[[Category:Time]]

Latest revision as of 14:47, 19 September 2016

On this page, you will find useful informations to use the Real Time Clock of your boards (if chip is mounted).

Hardware

APF9328/APF27

No permanent RTC is present on the APF9328/APF27 modules, but you can have one (DS1374, as an option) on the development boards or add it yourself if you are an electrician (it is not so complex to add a DS1374 (with integrated quartz) on the I2C bus). Do not forget to provide the two power-supply (VCC and Vbackup)). Currently only Maxim's DS1374 has been tested on APF9328Dev/APF27Dev but any I2C RTC, supported by Linux, should work the same way.

APF51/APF28

APF51 and APF28 modules have an onboard PMIC with an integrated RTC. APF51Dev has a CR032 receptacle to allow APF51 RTC backup.

APF6

APF6Dev has an onboard external RTC chip: MCP794000.

Driver installation

APF9328/APF27

DS1374 driver is by default included in standard Armadeus Linux kernel. To check if your board (Linux) has correctly detected the RTC:

# dmesg | grep ds1374
ds1374-legacy 0-0068: chip found, driver version 1.0
ds1374-legacy 0-0068: rtc core: registered ds1374-legacy as rtc0
ds1374-legacy 0-0068: setting system clock to 1970-01-01 00:00:07 UTC (7)

APF51

Driver is by default installed and launched. To check if your board (Linux) has correctly detected the RTC:

# dmesg | grep rtc
wm831x-rtc wm831x-rtc: rtc core: registered wm831x as rtc0
wm831x-rtc wm831x-rtc: setting system clock to 2011-05-03 13:27:26 UTC (1304429246)

APF28

On APF28 the RTC is integrated under the i.MX28 processor. See the reference manual chapter 22 "Real-Time Clock Alarm Watchdog Persistent Bits".

There isn't button-lithium backup battery under APF28dev board, if we unplug the power, clock is not saved and then we could ask : what the interest of RTC if not backuped ?

The interest is when we power the whole board with a battery and we poweroff the apf28 with the command :

$ poweroff

The processor will be powered of ... except the RTC. Then we could power on the board pushing power switch and keep the clock up to date.

Warning Warning: To enable poweroff on APF28dev the board must be powered by battery (J10 pin 4) and the USB-powering must be disconnected. To disconnect it, just unsolder the self L7 (behind the usb J3 connector)
Note Note: Currently, the clock doesn't work in poweroff it must be fixed. The date and hour are keeped but not incremented


Clock

To read the hardware value of clock use hwclock command on file /dev/rtc0:

Keep clock

To power off the board type :

# poweroff
The system is going down NOW!
Sent SIGTERM to all processes
Sent SIGKILL to all processes
P
Communications disconnect (Back at localhost)
----------------------------------------------------
(/home/fabien/) C-Kermit>

And to wake-up the board push the button 'ON'. The date and hour will be keeped when you type 'date' or 'hwclock'.

APF6

MCP794000 driver is integrated by default in armadeus BSP's Linux kernel for APF6.

# dmesg | grep mcp
[    1.665275] rtc-mcp7940x 1-006f: rtc core: registered mcp7940x-rtc as rtc0

Usage

Note Note: We recommand to store time in UTC format in the RTC; that will ease the timezone/summer time handling.
  • From Linux use the command hwclock to read, write, synchronize the RTC (here we pre-suppose that RTC is storing time in UTC format).
 # hwclock --help
 # hwclock -r -u      to read hardware clock and print result (localtime)
 # hwclock -s -u      to set the system time from the hardware clock
 # hwclock -w -u      to set the hardware clock to the current system time (UTC)
Warning Warning: Security "features" prevent to change RTC time more than 8 times per hour on the APF51 !!
  • Use date command to read and update system date and time while running:
 # date --help        for more information
 # date -R            to read hardware clock and print result
 # date 013122302011           to sets the system date to january 31th 2011 22h30 (localtime)
 # date 2011.01.31-22:30:00    also do the job
  • Then, when booting you will see something like this:
ds1374 0-0068: setting the system clock to 2011-xxxx
or
wm831x-rtc wm831x-rtc: setting system clock to 2011-xxxx
  • TimeZone/Summer time handling can be configured in /etc/TZ (uClibc particularity):
 # cat /etc/TZ
 CET-1DST,M3.5.0/2:00,M10.5.0/3:00

Examples for TZ can be found here:http://www.sonoracomm.com/support/20-voice-support/107-uclibc-tz

  • you can update RTC from a NTP (Network Time Protocol) server if your board is connected to internet or a NTP server
 # ntpd -nqp 217.147.208.1
 ntpd: setting clock to Mon Apr 23 22:36:39 DST 2012 (offset 1335216961.855897s)
 # hwclock -wu  # to set the hardware clock to the current system time (UTC)
  • if Alarm/wakeup is supported by the RTC driver then the alarm/wakeup time may be set like that for a 60 sec delay with RTC0
 # sec=`date '+%s'`
 # let "sec=$sec+60"
 # echo $sec > /sys/class/rtc/rtc0/wakealarm
  • if the time specified in wakealarm is earlier than the current time, then the Alarm/wakeup is disabled

Links