element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Raspberry Pi Forum Pi configuration for Real time clock
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
Raspberry Pi Wishlist
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Suggested Answer
  • Replies 2 replies
  • Answers 1 answer
  • Subscribers 664 subscribers
  • Views 1602 views
  • Users 0 members are here
  • raspberry_pi
Related

Pi configuration for Real time clock

colporteur
colporteur over 6 years ago

What is the optimum/ideal Pi configuration setup to trigger a refresh of system clock from the RTC on reboot?

 

The RTC post raised in the Pi 4 discussion provided motivation to ask the question.

 

I just discovered a time sync loss between the RTC and the system clock after the Pi was left powered off for three weeks. On boot up the system clock had a time based on or around the time the unit was powered down. The RTC closely reflected the current time.

 

What is the link between system clock and RTC on bootup? I placed the following command hwclock --hctosys in /etc/rc.local to seed the system clock with the hwclock time on boot. This seems like a kludge. I assumed an RTC installation would provide a mechanism to ensure this happens. I haven't found anything that closely resembles that I am looking for.

 

This adafruit setup https://learn.adafruit.com/adding-a-real-time-clock-to-raspberry-pi/set-rtc-time  doesn't provide any reboot configuration details for Jessie but Wheezy it does make reference to /etc/rc.local

 

The RTC is working satisfactorily. The system clock is working satisfactorily. I only notice the issue of time sync loss after the Pi was powered down for an extended time.

 

What are your solutions to sync'ing the clocks?

 

BoM

  • Pi3B+
  • Raspbian 2019-04-08
  • RTC DS3231

 

Sean

  • Sign in to reply
  • Cancel
Parents
  • luislabmo
    0 luislabmo over 6 years ago

    Hello Sean,

     

    In the past as long as the time zone was set in raspi-config the RPi would automatically update the date/time on boot after an Ethernet interface is brought up -if connected to the internet.

     

    The ntp clock update could be forced-sync by doing:

    sudo /etc/init.d/ntp stop
    sudo ntpd -q -g
    sudo /etc/init.d/ntp start

     

    Few years have passed and my understanding is that is now done differently. Now ntp update is handled by the systemd-timesyncd daemon.

    In summary, sudo timedatectl set-ntp True activates the ntp update. To check the status timedatectl status

     

    If a manual force-update doesn't work, maybe a firewall is blocking the NTP. Is also worth checking the timezone configuration

     

    Luis

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • colporteur
    0 colporteur over 6 years ago in reply to luislabmo

    Thanks for the response.

     

    If I use the Adafruit posting as a reference, the Wheezy section /etc/rc.local is used to sync system time by drawing from the RTC. That would have been with NTP in play.

     

    I recall in my NTP days, NTP daemon was not capable of syncing time if the system time was >1000sec off from the NTP sourced clock. An ntpdate was required to get the clock close and then NTP could kick system time in the pants when needed.

     

    systemd-timesyncd.service uses NTP to draw time on boot of the Pi. A last system clock value is stored on shutdown that is also used.

     

    I speculating, if the system clock is to far a skew on boot up, does the same limit apply to system clock that  NTP can't correct it.

     

    The scenario of the time being out of sync when the Pi has been turned off for an extended period of time has happened more than once. It took me a while to twig to the condition. The last time it happened I noticed because I had just worked on the unit a short time ago.

     

    Sean

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • colporteur
    0 colporteur over 6 years ago in reply to luislabmo

    Thanks for the response.

     

    If I use the Adafruit posting as a reference, the Wheezy section /etc/rc.local is used to sync system time by drawing from the RTC. That would have been with NTP in play.

     

    I recall in my NTP days, NTP daemon was not capable of syncing time if the system time was >1000sec off from the NTP sourced clock. An ntpdate was required to get the clock close and then NTP could kick system time in the pants when needed.

     

    systemd-timesyncd.service uses NTP to draw time on boot of the Pi. A last system clock value is stored on shutdown that is also used.

     

    I speculating, if the system clock is to far a skew on boot up, does the same limit apply to system clock that  NTP can't correct it.

     

    The scenario of the time being out of sync when the Pi has been turned off for an extended period of time has happened more than once. It took me a while to twig to the condition. The last time it happened I noticed because I had just worked on the unit a short time ago.

     

    Sean

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube