Setting Date and Time

From Openmoko

(Difference between revisions)
Jump to: navigation, search
(Future Work: Added the word "automatically" to make the text compatible with the gps sight article.)
m (Setting the date/time automatically with gps: fixed layout)
Line 49: Line 49:
 
The second step is to install GPS Sight:
 
The second step is to install GPS Sight:
  
#opkg install http://projects.openmoko.org/frs/download.php/227/gpssight_0.8.4_freerunner.armv4t.ipk
+
# opkg install http://projects.openmoko.org/frs/download.php/227/gpssight_0.8.4_freerunner.armv4t.ipk
  
 
The last step is the actual syncing of the clock. For this, simply run the GPS Sight program from the main menu, wait for it to find the gps time and click the button labeled "Sync clock".
 
The last step is the actual syncing of the clock. For this, simply run the GPS Sight program from the main menu, wait for it to find the gps time and click the button labeled "Sync clock".

Revision as of 11:22, 17 August 2008

Linux systems (such as the Freerunner) prefer that the system clock be set to universal time (UTC). Then, you will need to configure the timezone to display the time adjusted to local time.

See Timezone for instructions on changing the time zone.

For more information on Linux timekeeping, see Linux, Clocks, and Time. (But ignore mentions of /etc/sysconfig/clock. That doesn't apply to the Openmoko environment.)

Contents

Setting the date/time using "date"

To change the date on your Freerunner, issue one of the following commands:

date -s MMDDhhmm
date -s MMDDhhmmYYYY
date -s MMDDhhmmYYYY.ss

where MM is the month, 01-12; DD is the day, 01-31; hhmm is the time, 0000-2359; YYYY is the optional year, and .ss is the optional seconds.

Setting date/time from your linux box

 ssh root@openmoko "date -s `date --utc +%m%d%H%M%Y.%S`"

Setting the date/time automatically with NTP

If your Freerunner is connected to the internet, you can instead set the time automatically:

 opkg install ntpclient
 ntpclient -s -h pool.ntp.org

If your Freerunner is connecting to the internet through a USB host, make sure you allow UDP traffic to pass through on port 123 (NTP) on your host machine or you may get a "no route to host" error from ntpclient.

Syncing the hardware clock

No matter which method you used above, sync the hardware clock with the system time to make your change persist over reboots:

hwclock --systohc

Note: if you run the ASU image, hwclock will not work. Instead you can use:

echo "W\n" > /var/spool/at/trigger

Here is a link from the community mailing list for using hwclock with the ASU image

http://lists.openmoko.org/pipermail/community/2008-July/023849.html

Setting the date/time automatically with gps

GPS Sight has a button to sync the hardware clock to the gps clock.

First you have to make sure gps works on you neo. You can do that by following the steps in the Getting_Started_with_your_Neo_FreeRunner#Use_the_GPS.

The second step is to install GPS Sight:

# opkg install http://projects.openmoko.org/frs/download.php/227/gpssight_0.8.4_freerunner.armv4t.ipk

The last step is the actual syncing of the clock. For this, simply run the GPS Sight program from the main menu, wait for it to find the gps time and click the button labeled "Sync clock".

Future Work

Presumably it might also be possible to use gpspipe (or something else) to set the date once you have a gps fix automatically? In addition, the phone stack should set the date, time, and timezone once connected to a network.

Personal tools

Linux systems (such as the Freerunner) prefer that the system clock be set to universal time (UTC). Then, you will need to configure the timezone to display the time adjusted to local time.

See Timezone for instructions on changing the time zone.

For more information on Linux timekeeping, see Linux, Clocks, and Time. (But ignore mentions of /etc/sysconfig/clock. That doesn't apply to the Openmoko environment.)

Setting the date/time using "date"

To change the date on your Freerunner, issue one of the following commands:

date -s MMDDhhmm
date -s MMDDhhmmYYYY
date -s MMDDhhmmYYYY.ss

where MM is the month, 01-12; DD is the day, 01-31; hhmm is the time, 0000-2359; YYYY is the optional year, and .ss is the optional seconds.

Setting date/time from your linux box

 ssh root@openmoko "date -s `date --utc +%m%d%H%M%Y.%S`"

Setting the date/time automatically with NTP

If your Freerunner is connected to the internet, you can instead set the time automatically:

 opkg install ntpclient
 ntpclient -s -h pool.ntp.org

If your Freerunner is connecting to the internet through a USB host, make sure you allow UDP traffic to pass through on port 123 (NTP) on your host machine or you may get a "no route to host" error from ntpclient.

Syncing the hardware clock

No matter which method you used above, sync the hardware clock with the system time to make your change persist over reboots:

hwclock --systohc

Note: if you run the ASU image, hwclock will not work. Instead you can use:

echo "W\n" > /var/spool/at/trigger

Here is a link from the community mailing list for using hwclock with the ASU image

http://lists.openmoko.org/pipermail/community/2008-July/023849.html

Setting the date/time automatically with gps

GPS Sight has a button to sync the hardware clock to the gps clock.

First you have to make sure gps works on you neo. You can do that by following the steps in the Getting_Started_with_your_Neo_FreeRunner#Use_the_GPS.

The second step is to install GPS Sight:

  1. opkg install http://projects.openmoko.org/frs/download.php/227/gpssight_0.8.4_freerunner.armv4t.ipk

The last step is the actual syncing of the clock. For this, simply run the GPS Sight program from the main menu, wait for it to find the gps time and click the button labeled "Sync clock".

Future Work

Presumably it might also be possible to use gpspipe (or something else) to set the date once you have a gps fix automatically? In addition, the phone stack should set the date, time, and timezone once connected to a network.