Hardware clock - Busybox linux

275 views
Skip to first unread message

Tom

unread,
Jul 20, 2023, 11:50:41 AM7/20/23
to MLUG Listserve
Hello all. I have a device, and old power-pc based environmental monitoring widget, which runs under busybox linux. I'm baffled by the hardware clock. The unit is accessed 99% of the time via its web interface, which has no provision for setting the clock. But the device is an environmental monitor, with graphs & history, so have the time set right is important.
 
There was once an advanced configuration utility, which one could run on a workstation, to configure it. It was written in Java, and is now unobtainium. Even if I had it, I'm not sure it would run in a modern environment.
 
The device has no ssh or telnet access, only a serial port and a 10/100 ethernet. So setting the time after a reboot requires a serial cable. Arrrg.
 
I ran nmap against it.
PORT STATE SERVICE
21/tcp open ftp
80/tcp open http
443/tcp open https
 
I was hoping that port 21 was a disguised telnet port, but no, it's really ftp.
 
I plugged into the serial port and can access a shell prompt. I managed to locate the root password and can kill the config program that runs for root at login, which gets me a prompt.
 
I can set the date/time,  but that's lost when it reboots- It reverts to the hardware clock, which lets me set it, but then spools off into random times. I can set the hwclock as many times as I like, but it floats around by hours/days within a very short time.
 
I do see this in the bootup:
root: NTP sync using 192.168.0.1 time.nist.gov
Looking for host 192.168.0.1 and service ntp
host found : 192.168.0.1
Looking for host time.nist.gov and service ntp
host found : 2610:20:6f15:15::26
root: NTP sync failed
But it's not on that network, and I can't figure out how to change the NTP server.
 
# uname -a
Linux EnvMon420 2.4.26 #1 Wed Oct 31 18:09:53 CDT 2007 ppc unknown
 
Last time I rebooted it, I set the linux clock and ran this to see how far off the hardware clock and linux clock are:
# date
Thu Jul 20 10:30:09 CDT 2023
# hwclock -r
Thu Jul 27 04:18:39 2023 0.000000 seconds
 
; write the linux clock to the hardware clock:
# hwclock -w
; read the hardware clock: 
# hwclock -r
Thu Jul 20 10:39:38 2023 0.000000 seconds
; show linux clock:
# date
Thu Jul 20 10:31:52 CDT 2023
; read hardware clock within a second of 'date' command:
# hwclock -r
Thu Jul 20 11:14:23 2023 0.000000 seconds
; it's off by an hour
 
; compare again after 3 minutes or so:
# date;hwclock -r
Thu Jul 20 10:34:45 CDT 2023
Fri Jul 21 01:43:11 2023 0.000000 seconds
 
As you can see, it's off in space somewhere, having drifted a full day.
 
The other day, I ran a script that looped,  writing the linux clock to the hardware clock, reading back the hardware clock, then 'sleep 10' -- I let it run over night. The readback immediately after the set was always pretty accurate.  But as soon as I stop it,  it jumps to random times/dates again.
 
Any ideas?
-T
 

Tom Peters • a50m...@gmail.com • N9QQB (amateur radio)
"HEY YOU" (loud shouting) • Second Tops (Set Dancing) • FIND ME ON FACEBOOK
43° 7' 17.2" N by 88° 6' 28.9" W • Elevation 815' • Grid Square EN53wc
Sr. Systems Administrator • Open-source Dude • Musician • Registered Linux User 385531
--... ...-- / -.. . / -. ----. --.- --.- -...
 

Roger M. Jenson

unread,
Jul 20, 2023, 1:53:08 PM7/20/23
to Milwau...@googlegroups.com

Hello Tom,

Is there a RTC battery on the system that you can replace?

A quick bit of research indicates BusyBox requires a specific format of the command to set the date/time. Review the man/help pages on the system to learn the command format that it supports (e.g. date -s 2010.02.17-19:14:32 or # date -s 202006020937, other).

I have used the edit feature in filezilla to read and change configuration files on systems without a terminal interface ;). Maybe you could cause the ntp client to look to a functional ntp server.

Best Regards,
Roger M. Jenson

--
Homepage: http://www.milwaukeelug.org/home
This forum online: https://groups.google.com/forum/#!forum/MilwaukeeLUG
---
You received this message because you are subscribed to the Google Groups "Milwaukee Linux User's Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to MilwaukeeLUG...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/MilwaukeeLUG/5401.-190354384.1689868234%40gmail.com.

Tom

unread,
Jul 20, 2023, 2:37:26 PM7/20/23
to Milwau...@googlegroups.com
I haven't been able to get the case open- the lens of the camera protrudes, and even unscrewing and removing the lens leaves enough of the mount sticking through to block removal.
 
I'm not sure why the rtc wanders around that much, even with the local power on. Within a few minutes, it's all over the place. Seems like with the power on, the RTC shouldn't lose it's mind, especially not in  few seconds or minutes.
 
I don't seem to have a problem setting the Linux clock. When I set it, it stays pretty accurate, and the web page reflects that time/date correctly. But power loss or reboot makes it set the linux clock from the hardware clock, so it becomes wrong.
 
I can't find where the NTP servers are defined. I have a root shell session, but the usual files for NTP configuration don't seem to be here.
 
-T

Joe Baker's Remedy Report

unread,
Jul 21, 2023, 1:22:59 PM7/21/23
to Milwau...@googlegroups.com
I'd run a dns server and hard code time.nist.gov to your 192.168.0.1 ip. 

"Time is an illusion so run an NTP server to manage the illusion."

Nice to see your email Tom.

--
Reply all
Reply to author
Forward
0 new messages