OESF Portables Forum
Everything Else => General Support and Discussion => Zaurus General Forums => Archived Forums => Software => Topic started by: jdv on January 08, 2005, 11:48:53 am
-
Here is how to set and maintain the Zaurus SL-5600 clock through reboots, suspends, etc.
It should work on any Zaurus (as always YMMV):
First download and install the "ntp_4.1.1-0vl1_arm.ipk" package.
This will install the ntpd daemon and ntp utilities in the /usr/local/bin directory.
Go to http://www.ntp.org/ntpfaq/NTP-a-faq.htm (http://www.ntp.org/ntpfaq/NTP-a-faq.htm) to learn all about ntp.
You definitely want to know how to configure the /usr/local/bin/ntp.conf file so visit:
http://docsrv.sco.com/NET_tcpip/CTOC-ntpN.ntp.html (http://docsrv.sco.com/NET_tcpip/CTOC-ntpN.ntp.html)
to learn about the ntp.conf parameters.
Then go to http://www.eecis.udel.edu/~mills/ntp/servers.html (http://www.eecis.udel.edu/~mills/ntp/servers.html) and select some open time servers.
I use some (five) publicly available servers.
This is advantagous if you are off your home network (accessing Internet via airport Tmobile network or local coffeeshop "free wifi hotspot".
Note: NTP server authentication and generating keys to access secure NTP time servers is beyond the scope of this article. (If you NEED that kind of NTP time service; GPS receivers are cheap.)
I should set up my own "stratum 1" time server using a GPS receiver but then I'm not coordinating a "time-on-target" ICBM strike or Mars mission with my Zaurus, either. ;-)
I created a symbolic link in /etc to the ntp.conf file in /usr/local/bin.
(ln -s /usr/local/bin/ntp.conf /etc/ntp.conf)
I then created a "timed" script in my /etc/rc.d/init.d directory:
#!/bin/bash
#
# /etc/rc.d/init.d/timed - Start/Stop the ntpd daemon(s).
#
# Comment out the following exit line to enable this script.
# exit 0
# Source function library.
. /etc/rc.d/init.d/functions
DAEMON="/usr/local/bin/ntpd"
case "$1" in
start)
msg -n "Starting ntpd:"
daemon --survive=5 $DAEMON
if [ "$?" = "0" ]; then
touch /var/lock/subsys/ntp
fi
msg
;;
stop)
msg -n "Stopping ntpd:"
killproc $DAEMON
msg
rm -f /var/lock/subsys/ntp
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
Then I chmoded the timed file as follows:
chmod +x /etc/rc.d/init.d/timed
I then created a symbolic link to timed in the /etc/rc.d/rc5.d directory:
ln -s /etc/rc.d/init.d/timed /etc/rc.d/rc5.d/S98ntp
Now reboot ( issue "init 6" from the console).
Once your Zaurus has rebooted either connect to your network via wireless (which should set up
your routes ) or create a route to the network via your usb port:
route -v add -net default gw 192.168.129.1 netmask 0.0.0.0 metric 2 usbd0
OR you can edit your /etc/rc.d/net.agent file wilth the following at line 76 or there abouts:
75 usbd_net_if_up
76 # The following line adds a route via the usb interface to the network.
77 route -v add -net default gw $GATEWAY netmask 0.0.0.0 metric 2 usbd0
and place a "GATEWAY=192.168.129.1" entry in your " usbdnet.conf" file.
Now sit back and wait until the ntpd damon has synced up with the ntp server(s) you put in your ntp.conf file.
To check and make sure you're syncing with your NTP time servers, issue a "ntpq -p" command from the console; you should see something like this:
root@/home/root> ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
+tick.usno.navy. .USNO. 1 u 69 256 311 178.362 44.337 34.849
*tock.usno.navy. .USNO. 1 u 67 256 273 177.761 52.138 25.023
-swisstime.ee.et .PPS. 1 u 16 256 377 162.823 18.540 3.752
-cuckoo.nevada.e tick.usnogps.na 2 u 70 256 377 99.848 4.237 5.439
+filbert.cc.colu gnomon.cc.colum 2 u 14 256 377 100.287 34.793 2.574
If you see the following your route is bad, you are not connected to the Internet, ie. something is wrong:
root@/home/root> ntpq -p
No association ID's returned
Another BAD example:
Any enty that looks like the following means you are not syncing with that NTP time server:
root@/home/root> ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
tick.usno.navy. 0.0.0.0 16 u - 64 0 0.000 0.000 4000.00
If the stratum for any ITD (st) time server is "16" then your server is not synchronizing successfully with the ITD time server.
-
Just a quick note: your shell script is missing the "esac" for the end case block. Elsewise you get unexpected end of file errors.
Automatic updating seems to be not working regardless. Is there an example ntp.conf file you can show me? All I have right now is the server option enabled. ntpq -p shows connections, but I guess there's more to it than that.
I did create a script saying ntpdate pool.ntp.org and that seemed to work just fine, so at least I can create a Qtopia icon to sync time.
-
Oops. old timed script (not to mention bad cut-n-paste). Sorry about that.
Try this one:
#!/bin/bash
#
# /etc/rc.d/init.d/timed - Start/Stop the ntpd daemon(s).
#
# Comment out the following exit line to enable this script.
# exit 0
# Source function library.
. /etc/rc.d/init.d/functions
DAEMON="/usr/local/bin/ntpd"
case "$1" in
start)
#initalize clock if ntpd not running.
/usr/local/bin/ntpdate tock.usno.navy.mil
sleep 1
msg -n "Starting ntpd:"
daemon --survive=5 $DAEMON
if [ "$?" = "0" ]; then
touch /var/lock/subsys/ntp
fi
msg
pidof ntpd > /var/run/ntpd.pid
;;
stop)
msg -n "Stopping ntpd:"
killproc $DAEMON
msg
rm -f /var/lock/subsys/ntp
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: $0 (start|stop|restart)"
exit 1
;;
esac
exit 0
Example ntp.conf file:
# restrict default noquery notrust nomodify
server tick.usno.navy.mil
server tock.usno.navy.mil
server swisstime.ethz.ch
server cuckoo.nevada.edu
server sundial.columbia.edu
restrict 127.0.0.1
restrict swisstime.ethz.ch nomodify notrap
restrict tick.usno.navy.mil nomodify notrap
restrict tock.usno.navy.mil nomodify notrap
restrict cuckoo.nevada.edu nomodify notrap
restrict sundial.columbia.edu nomodify notrap
driftfile /etc/ntp.drift
setvar panic = 0 default
logfile /var/log/ntp.log
Examine your ntp log file (see above ntp.conf example)
to check for errors, etc.
Assumptions: that there is some type of network connection. (ie. 802.11b, wired ethernet, or tcpip over usb running on your Zaurus.
Your Zaurus clock error is not greater than 1000 sec. NTP won't sync a clock
with an error that great.
Good Luck.
-
Thanks. It was the 1000 second limit that was preventing the time from syncing, as I was testing what would happen when the time was an hour off (3600 seconds). Now it seems okay.
I'm keeping a manual sync icon around using ntpdate as a result, in case the Zaurus gets *that* bad.
-
Don't forget slutils (sltime). Its useful to prevent too much of a timeloss on a crash.
- Bundabrg