1,381
edits
Changes
From IGEP - ISEE Wiki
no edit summary
IGEP Boards have two RTC clocks, each one located at MPU and PMIC:
* '''RTC System clock''': system clock is controlled by MPU using its internal RTC peripheral. Every boot-up, the default firmware (/etc/init.d/hwclock.sh) copies the hardware clock data from /dev/rtc to system clock data to keeps clock up to date.
* '''RTC Hardware clock''': hardware clock is controlled by PMIC using its internal RTC peripheral. RTC PMIC affords two behaviours:
** '''RTC battery is not used''': PMIC RTC peripheral keeps hardware clock alive when OS isn't running and power source is active. If the power source fails, the PMIC RTC peripheral will lose its clock.
** '''RTC battery is used''': PMIC RTC peripheral keeps hardware clock alive when OS isn't running and backup battery powers the backup state as far as the input voltage is high enough(at least 2 weeks into IGEPv2). == Simplified RTC diagram ==
==Simplified RTC diagram=={| cellspacingborder="1" cellpaddingwidth="1150" widthcellspacing="1501" bordercellpadding="1" align="center"
|-
|| [[Image:RTC diagram.png|800px|Block diagram from IGEP0033]]<br>
|}
= Requirements =
This How-to has been tested with an IGEPv2 RC Board (DM3730 and TPS65950), steps used below can be slightly different for other boards:
* PC
= Rectify clock drift=IGEP Boards use as a source clock an external 32,768 kHz crystal. This passive component can add clock drifts due: * General drift error* Ambient temperature drift error* Aging drift error* ...
<pre>ntpd -d -c /etc/ntp.conf -q</pre>===(alternative) ntpdate program===Ntpdate program is not installed into firmware by default, use zypper program to download and install the package:
* Uninstall ntp deamon:
<pre> zypper rm ntp</pre>
* Install ntpdate
<pre>zypper in ntpdate</pre> Once you installed the programfinished it, make sure that IGEP is connected to Internet.
* Synchronize system clock and hardware clockwith NTP server:
<pre> ntpdate pool.ntp.org; hwclock --systohc </pre>
* Compare offset between ntp server and your system clock:
<pre> ntpdate -q pool.ntp.org && date </pre> If your result is positive, it means that your system clock is delayed and viceversa.
* Calculate systematic clock error
* Rectify systematic clock error using configuring PMIC RTC registers
=== Calculate systematic clock error ===Each IGEP Board has its own systematic clock error. To guess it, Can be helpful use [http://labs.isee.biz/index.php/How_to_adjust_Hardware_RTC_clock#ntpdate__program ntpdate program] to calculate systematic clock error added every day:
==== Overview Calculate COM_REG value====If autocompensation is enabled PMIC RTC peripheral will compensate every hour and 1 second the clock drift using the COMP_REG value, It adds or substract a second. The next formula shows how to calculate it:
<pre> i2cset -f -y 1 0x4b 0x29 0x05 </pre>
* Write RTC_COMP registers:
<pre>i2cset -f -y 1 0x4b 0x2d 0x13
i2cset -f -y 1 0x4b 0x2c 0x33 </pre>
* Check register values:
<pre>i2cdump -y -f 1 0x4b </pre>
More information at [http://www.ti.com/litv/pdf/swcu050g TPS65950 TRM] section 3.4.2 ==== Correct system clock ====Hardware clock will be compensated automatically, to transfer hardware clock to system clock is necessary use hwclock command:
<pre> hwclock --hctosys</pre>
[[Category:RTC]]