| # Copyright 2019 The Chromium OS Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| description "Ensure the Wilco EC RTC is in sync with local time" |
| author "chromium-os-dev@chromium.org" |
| |
| # The RTC on the Wilco EC is used to schedule charging policies. The Wilco |
| # EC does not perform any logging, and the time information is not |
| # critical for other features, so it's acceptable for the RTC to be |
| # inaccurate for up to 5 minutes and for the time to jump around/backwards. |
| |
| start on starting system-services |
| stop on stopping system-services |
| respawn |
| |
| # Every 300 seconds run |
| # `/sbin/hwclock --systohc --localtime --rtc=/dev/rtc1 --noadjfile` with a 5 |
| # second timeout. This command sets the RTC at /dev/rtc1 to the system time, in |
| # the local time, without adjusting the /etc/adjtime cache. The localtime flag |
| # is important, as most linux RTCs use UTC, not local. We don't adjust the |
| # adjfile because this step is not important, and it would try to adjust the RO |
| # filesystem. The name of this periodic_scheduler job is wilco_sync_ec_rtc. |
| exec periodic_scheduler 300 5 wilco_sync_ec_rtc \ |
| /sbin/hwclock --systohc --localtime --rtc=/dev/rtc1 --noadjfile |
| |
| # Sync the RTC at boot and shutdown, so users see changes right away at boot |
| # if the time changed, and since the RTC can't be updated when shutdown |
| post-start exec /sbin/hwclock --systohc --localtime --rtc=/dev/rtc1 --noadjfile |
| post-stop exec /sbin/hwclock --systohc --localtime --rtc=/dev/rtc1 --noadjfile |