LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices


Reply
  Search this Thread
Old 12-10-2014, 08:43 AM   #1
cdr_nitjsr@yahoo.com
LQ Newbie
 
Registered: Oct 2012
Posts: 10

Rep: Reputation: Disabled
Synchronise RTC from NTP server


Dear friends i am having a System on module having arm processor and external rtc on it. The system is having embeded linux installed on it. I want to synchronise the RTC time from a NTP server on the network. How can i do this . Plese suggest possible soln with C code.
Thanking You all in advance.
 
Old 12-10-2014, 11:56 AM   #2
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,905
Blog Entries: 43

Rep: Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142
Member response

Hi,

Quote:
Originally Posted by cdr_nitjsr@yahoo.com View Post
Dear friends i am having a System on module having arm processor and external rtc on it. The system is having embeded linux installed on it. I want to synchronise the RTC time from a NTP server on the network. How can i do this . Plese suggest possible soln with C code.
Thanking You all in advance.
You could use 'ntpd' and cron job to update the time via a script;
Code:
#!/bin/sh
#11-06-06 gws use ntp
 /usr/sbin/ntpdate -v 0.us.pool.ntp.org ntp-1.mcs.anl.gov ntp-2.mcs.anl.gov &&hwclock --systohc
#--hctosys


#/usr/sbin/netdate time.mtco.com && /sbin/hwclock --systohc
No need to write 'c" to re-invent a function that is readily available. I place the above script in my '/etc/cron.hourly' as 'time' to update time. Be sure to make the 'time' script 'x' via chmod a+x /etc/cron.hourly/time
Hope this helps.
Have fun & enjoy!
 
Old 12-10-2014, 11:43 PM   #3
cdr_nitjsr@yahoo.com
LQ Newbie
 
Registered: Oct 2012
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by onebuck View Post
Hi,


You could use 'ntpd' and cron job to update the time via a script;
Code:
#!/bin/sh
#11-06-06 gws use ntp
 /usr/sbin/ntpdate -v 0.us.pool.ntp.org ntp-1.mcs.anl.gov ntp-2.mcs.anl.gov &&hwclock --systohc
#--hctosys


#/usr/sbin/netdate time.mtco.com && /sbin/hwclock --systohc
No need to write 'c" to re-invent a function that is readily available. I place the above script in my '/etc/cron.hourly' as 'time' to update time. Be sure to make the 'time' script 'x' via chmod a+x /etc/cron.hourly/time
Hope this helps.
Have fun & enjoy!
Thank u for replying. I got some idea but my BSP package has given API like GetExtRTCTime and SetExtRTCTime. If i use ntpd to synch how can i use these api to get and set time of RTC. Plz suggest thanking you.
 
Old 12-11-2014, 02:56 AM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 24,972

Rep: Reputation: 5677Reputation: 5677Reputation: 5677Reputation: 5677Reputation: 5677Reputation: 5677Reputation: 5677Reputation: 5677Reputation: 5677Reputation: 5677Reputation: 5677
Not enough information provided but if the system came with the RTC as a package or as an option then it might already be configured, nothing special is required and the above should work. Is there a kernel driver for the RTC?
 
Old 12-11-2014, 12:10 PM   #5
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,905
Blog Entries: 43

Rep: Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142
Member response

Hi,
Quote:
Originally Posted by cdr_nitjsr@yahoo.com View Post
Thank u for replying. I got some idea but my BSP package has given API like GetExtRTCTime and SetExtRTCTime. If i use ntpd to synch how can i use these api to get and set time of RTC. Plz suggest thanking you.
I agree with michaelk. If the RTC has support by the kernel then you can use 'nptd'. Simple & easy to do. You should check that systems documentation for information as to how the RTC is handled.
Hope this helps.
Have fun & enjoy!
 
  


Reply

Tags
linux, ntp


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Allow NTP client to synchronise any stratum lvnt Linux - Software 3 04-20-2014 10:52 AM
[SOLVED] NTP configuration in client to synchronize with NTP server. antnish Linux - General 12 04-01-2013 02:49 PM
ntp server keeps on changing time-local ntp server Gil@LQ Linux - Newbie 3 01-23-2013 10:33 AM
How to use NTP to synchronise linux boxes on a LAN? MoschopsUK Programming 1 07-01-2008 01:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 12:11 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration