Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FS#831 - /etc/init.d/sysfixtime doesn't set sensible time with wrt1200ac/wrt1900ac at boot #6439

Closed
openwrt-bot opened this issue Jun 8, 2017 · 4 comments
Labels

Comments

@openwrt-bot
Copy link

muddyfeet:

The WRT1200AC and the WRT1900AC (and quite possibly the WRT3200AC) has a hardware RTC on the Marvell SoC. The kernel recognises this and creates a /dev/rtc0 device.

The RTC is not battery backed so can come up with any random time set - have seen dates around 1970 and 2034 and 2036.

The /etc/init.d/sysfixtime script is designed to bring up the system with a sensible time and date (sourced from file dates in /etc) until it can be accurately set via NTP on systems with and without hardware RTCs.

The problem is at boot it assumes that because /etc/rtc0 exists and /sbin/hwclock exists, then it can obtain the sensible time from the hardware clock. This causes problems on my router with syslog-ng, vnstat and collectd if the date is in the future (collectd doesn't log any data and syslog-ng writes spurious logs based on the date).

The issue is further compounded in that the hardware RTC appears to lock up sometimes (probably due to the hardware RTC Vbatt line having no power on boot) and can only be reset by doing a "date reset" command under U-Boot. When the RTC has locked up the command "hwclock -s -u -f /dev/rtc0" or "hwclock -w" has no effect.

The solution may be to not create /dev/rtc0 on devices with an RTC but no battery back up. Another solution may be to modify /etc/init.d/sysfixtime to account for systems with no RTC, systems with battery backed RTCs, and systems like this with an RTC but no battery backup.

Has also been noted by someone else on https://dev.openwrt.org/ticket/20629

/etc/init.d/sysfixtime
....

boot() {
start && exit 0

local maxtime="$(maxtime)"                            <------ this is not executed because start() succeeds
local curtime="$(date +%s)"
[ $curtime -lt $maxtime ] && date -s @$maxtime

}

start() {
[ -e "$RTC_DEV" ] && [ -e "$HWCLOCK" ] && $HWCLOCK -s -u -f $RTC_DEV
}

.....

@openwrt-bot
Copy link
Author

muddyfeet:

Further to the above, I can confirm that the hardware RTC doesn't keep time. It seems to run about half the speed of realtime...so it's not very useful at all..

@openwrt-bot
Copy link
Author

jow-:

Maybe it easier then to just disable the RTC on this targets, that would allow us to keep the script side logic simple...

@openwrt-bot
Copy link
Author

muddyfeet:

Agree with disabling the RTC being the easiest. Have just disabled CONFIG_RTC_DRV_MV and CONFIG_RTC_DRV_ARMADA38X in the kernel on my system and all works well now as expected.

Not sure about other mvebu targets but can confirm the WRT1200AC and WRT1900AC do not have batteries. Can't comment about WRT3200AC, clearfog etc.

I'm not sure how to go about making the relevant change to the code, so will need someone else to do it.

@openwrt-bot
Copy link
Author

muddyfeet:

Fixed in 8605ac8

Thanks to hauke

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant