maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Nokia N900 (https://talk.maemo.org/forumdisplay.php?f=44)
-   -   How can N900 sync time? GPS, NTP, and/or GSM? (https://talk.maemo.org/showthread.php?t=37662)

myk 2009-12-18 13:43

How can N900 sync time? GPS, NTP, and/or GSM?
 
I noticed the n900 clock had drifted a few minutes off.
Odd, since it has access to accurate time over the internet, the phone network (other phones use this), and the GPS.
The GPS should be obscenely accurate, so why does it let the clock drift? I've ticked the box now to update automatically, but am wondering what it does. There was no instant change, so will see in the morning if it has caught up.
Ntpd does not seem to be installed or in the repository.

jrkalf 2009-12-18 14:37

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
BIG WARNING SIGN (devs want this or kill me if I don't):

NEVER USE MAEMO TESTING UNLESS YOU KNOW WHAT RIDE YOU'RE IN FOR!


ntpd can be found in maemo testing

o/

myk 2009-12-18 14:43

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
OK, so that confirms that NTP is not standard.
Then what does the "update automatically" checkbox do then?

sjgadsby 2009-12-18 14:46

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
Quote:

Originally Posted by myk (Post 433414)
Then what does the "update automatically" checkbox do then?

It enables clock synchronization with the cellular network, if an activated SIM is in the N900.

myk 2009-12-18 15:46

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
Thanks, but I don't think my network (3AU) supports that. I just switched it over to roam on Telstra and the clock was corrected before it jumped back to '3'.

I don't suppose there is a way to use GPS for time? Nanosecond accuracy would be cool :-)

TA-t3 2009-12-18 15:59

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
My clock is also drifting noticably. I'm quite surprised by this because the N800 clock doesn't drift at all (and no, I don't have ntpd running). Either the N800 OS2007 uses some kind of built-in time synch whenever it's online, or that device's hardware clock is simply extremely stable. The N900 clock is drifting way too much.

ruskie 2009-12-18 18:19

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
I tried getting ntpd working but it seems to fail. If anyone has any luck. What have you done to get it runnnig.

youxing 2009-12-24 13:43

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
I got openntpd working!

This is what I did!
Make sure you have a working internet connection!
Install rootsh over application manager if you haven't yet.

Open XTerminal

type:

Code:

sudo gainroot

apt-get install openntpd

(wait until it's done installing)

Then type:

Code:

ntpd
after around 20 seconds, the time on the N900 should have updated!

You can check whether you suceeded using the
Code:

date
command!

Everytime you want to update the time on your phone, you need to type

Code:

sudo gainroot
ntpd


RobbH 2010-01-15 16:50

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
Quote:

Originally Posted by youxing (Post 440254)
I got openntpd working!

[much snipped]

Everytime you want to update the time on your phone, you need to type

Code:

sudo gainroot
ntpd


If this works for you, that's great. I'm not seeing any change when I run this version of ntpd. In addition, this is not the way it's intended to work.

I would really like to see a working implementation of ntpd or some other form of ntp on the N900. At present, if my N900 is set to update time automatically (from AT&T), it's consistently six seconds fast. Otherwise it's consistently four to ten seconds slow.

Rob1n 2010-01-15 16:57

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
Quote:

Originally Posted by RobbH (Post 474439)
At present, if my N900 is set to update time automatically (from AT&T), it's consistently six seconds fast. Otherwise it's consistently four to ten seconds slow.

Crikey, you must have a really tight schedule :p

debernardis 2010-01-15 16:59

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
Search the forum for rdate, which works very well

RobbH 2010-01-16 14:02

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
Quote:

Originally Posted by debernardis (Post 474458)
Search the forum for rdate, which works very well

Many, many thanks! I found rdate here: http://nitapps.com/

I'm still hoping for a working ntpd to maintain clock accuracy without my intervention, but this serves my purposes very well.


Quote:

Originally Posted by Rob1n (Post 474453)
Crikey, you must have a really tight schedule :p

Well, yeah! Sometimes. :D

I work in broadcasting. When you're trying to hit a network feed that begins at precisely one minute past the top of the hour, a six-second error sounds really nasty!

vinc17 2010-01-30 23:19

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
Quote:

Originally Posted by RobbH (Post 474439)
If this works for you, that's great. I'm not seeing any change when I run this version of ntpd. In addition, this is not the way it's intended to work.

I would really like to see a working implementation of ntpd or some other form of ntp on the N900.

When running ntpd directly as suggested, this doesn't work either on my N900. I get the error message "fatal: stat: No such file or directory" in /var/log/syslog. However "/etc/init.d/openntpd start" works.

youxing 2010-02-09 17:38

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
1 Attachment(s)
Quote:

Originally Posted by vinc17 (Post 503143)
When running ntpd directly as suggested, this doesn't work either on my N900. I get the error message "fatal: stat: No such file or directory" in /var/log/syslog. However "/etc/init.d/openntpd start" works.

Thats great! I created a shell script:
Code:

# Start openntpd
/etc/init.d/openntpd start

# Run ntpd in foreground (not as daemon)
ntpd -d

Step by step instructions:

You need rootsh installed from Extras repository and the openntpd package from Extras-Testing to do this. Please remember to always be very careful when running stuff as root as this may damage your device if you don't know what you are doing!

1. Download the attachment ntpd.sh.txt to your N900 directory. (Which means just don't put it into any folder.) You should see this file when you open the file manager and then tap on "N900".

2. Open XTerminal and type
Code:

sudo gainroot

cd /usr/sbin/

cp /home/user/MyDocs/ntpd.sh.txt ntpd.sh

chmod 755 ntpd.sh

3. You should be all set! Everytime you'd like to synchronize the time on your N900, open up XTerminal and type:

Code:

sudo gainroot

ntpd.sh

After you see that the time is set (it usually takes around 30 seconds), you have to manually terminate the process by pressing Ctrl+C twice.

I hope this works for you all!

Have fun syncing your clocks!

RobbH 2010-02-10 01:50

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
Quote:

Originally Posted by vinc17 (Post 503143)
When running ntpd directly as suggested, this doesn't work either on my N900. I get the error message "fatal: stat: No such file or directory" in /var/log/syslog. However "/etc/init.d/openntpd start" works.

I think this post on an Ubuntu list may have something to do with the failure of openntpd to launch at startup on the N900. However, I think the "patch" offered needs some work before it will solve the problem on the N900. And so far, it's beyond me.

RobbH 2010-02-28 21:13

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
Thanks to vinc17 and youxing for pointing the way to an effective workaround.

First, as root, I created a file, /usr/bin/ntpdstart, containing this:

Code:

#! /bin/sh
#
rootsh /etc/init.d/openntpd start

Make it executable:
chmod +x /usr/bin/ntpdstart

Now, invoking ntpdstart from the command line will start ntpd as a daemon, updating system time regularly.

The next step I found in another thread, and I don't remember who to credit. Again, as root, I creaed this file: /etc/event.d/startopenntpd:

Code:

description "Start ntpd"
start on started clock-daemon
console none
script
              /usr/bin/ntpdstart
end script

This file should NOT be executable. After a reboot, I had ntpd starting automatically on system startup, and it has worked great since.

As always, there are no guarantees that this will work for anyone else.

RobbH 2010-05-28 01:27

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
Just in case anyone is still seeking a solution, there is now a compatible version of openntpd in Extras. Installs cleanly and is configured to run at startup, so the old workarounds are no longer needed.

I had to uninstall the old version; it would not update. There was also already an openntpd script in /etc/event.d, which had to be deleted manually before the installation could be completed.

Taomyn 2010-05-28 13:21

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
Quote:

Originally Posted by RobbH (Post 684486)
Just in case anyone is still seeking a solution, there is now a compatible version of openntpd in Extras. Installs cleanly and is configured to run at startup, so the old workarounds are no longer needed.

Thanks, I just installed this and it seems to be running ok after shutting the N900 down (reboot wouldn't start it), though I'm waiting for it to do it's first update. I've deliberately set the clock 5 minutes fast to see if it gets updated and nothing so far.

Is there a log file or anything that I can check to see if the changes I made to the time servers it uses are ok?

**UPDATE** don't worry, I figured out how to run it so I could see the results, stopped the daemon "openntpd stop", then ran it again as "ntpd -s -d"

maemo.it 2010-12-23 17:18

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
hi guys, let me know understand why at start on my n900 ps aux shows me /usr/sbin/ntpd daemon working but if I connect to internet it doesn't update automatically my date and time?
I've to launch manually ntpd command to do it!
so, what do this daemon?

delta.br 2010-12-23 19:17

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
Why not use the Automatic time sync feature provided by the cell phone network in the clock settings? Is there a special reason to update the clock by ntp?

maemo.it 2010-12-23 19:35

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
Quote:

Originally Posted by delta.br (Post 903004)
Why not use the Automatic time sync feature provided by the cell phone network in the clock settings? Is there a special reason to update the clock by ntp?

http://talk.maemo.org/showpost.php?p=433416&postcount=4

soeiro 2011-01-28 16:37

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
Quote:

Originally Posted by maemo.it (Post 903019)

I think this link doesn't answer the question. I am trying to get my N900's clock accurate, but I'm failing. It seems that with or without the "update automatically" checkbox selected my N900 still is never accurate. Maybe it is an operator issue or maybe it is a N900 bug.

So, I would like to hear from you guys: does "update automatically" using the cell network works for you any better than the NTPd?

Thks

Creamy Goodness 2011-01-28 16:47

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
Quote:

Originally Posted by myk (Post 433489)
Thanks, but I don't think my network (3AU) supports that. I just switched it over to roam on Telstra and the clock was corrected before it jumped back to '3'.

I don't suppose there is a way to use GPS for time? Nanosecond accuracy would be cool :-)

It works for most people
not this guy
...
how is it a bug if you disable that, and it doesn't update?

alimkdm 2011-01-29 23:50

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
hello guys
i set my clock in n900 on update automatically
but sometimes it does and other it stays the same
isnt supposed to correct itself when it s wrong even if i set it wrong!
i noticed that sometimes i get the info that it update to in the field below
and most of the times it s empty
i dont know what control that!
and i wanna ask NTPD use internet not the GSM network!
thanks for reply

prometoys 2011-03-27 13:29

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
hi,

i activated the "Update automatically" feature in date and time setting, but nothing changes. Over the last months the difference on my N900 clock slowly increased up to 10min behind. How I can debug the sync feature, can I run it from the shell manually? How often it checks the time?

Thanks,

Keywan

shadowjk 2011-03-27 15:40

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
Btw, be a bit careful with openntp. It polls for time every 64 sec, which is a significant drain on standby battery life.

Of course, if you've already got so much crap running that you're below 12 hour standby, you probably wont notice, but those with 3 day standby would find it cut to 1 day probably.

casketizer 2011-03-27 16:13

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
I have been using ntpd for ages and i dont notice a significant loss in battery time. Both its threads combined use about 20sec of cpu time per 24h. It only has a big impact if your device would otherwise not be online 24/7. Then indeed it will cause battery drain.

shadowjk 2011-03-27 17:09

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
CPU time isn't an issue, and not a good metric for standby power use.

Biggest impact would be openntpd on 3g. In worst case (operator dependent), it polls once every 64 secs, and each packet of traffic causes 5 seconds of radio activity.

ndi 2011-03-27 17:23

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
I don't need second accuracy (have my wrist watch for that) so I manually sync the clock to GPS every now and then, it usually under 20 seconds. There's an app called GPS Recorder or somesuch that also syncs clock when getting a lock.

Only issue is, it's too big. It wants a file to log to, has several buttons, etc. It would be nice if it stopped the GPS but it sorta doesn't, so it's a drain. Also, like I said, big.

I wouldn't mind an app that powered up the GPS every 2 hours or so and tried to get a lock, correcting time (in background). Even an app that did that without a daemon could be easily scheduled via alarmed (my alarmed is broken, but yours will work).

casketizer 2011-03-27 17:23

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
As I said. If you need to go online for it, it's clear that it eats battery.
Mine only updates on wifi to which I'm connected almost 24/7. It doesn't connect thru 2G/3G unless that is online for other reasons.

ME2g 2011-03-27 20:34

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
Quote:

Originally Posted by myk (Post 433352)
I noticed the n900 clock had drifted a few minutes off.
Odd, since it has access to accurate time over the internet, the phone network (other phones use this), and the GPS.
The GPS should be obscenely accurate, so why does it let the clock drift? I've ticked the box now to update automatically, but am wondering what it does. There was no instant change, so will see in the morning if it has caught up.
Ntpd does not seem to be installed or in the repository.

Maybe you are interested in this:
http://forums.internettablettalk.com...d.php?p=884697
;-)
I did not try, but maybe you can write a script and use it with a cronjob?

tmarinos 2011-05-11 06:31

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
I just installed openntpd. How do I know if its working?

chemist 2011-05-11 09:27

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
If your time is right it is working properly?! You may use a ntp server close to your location to have the sync most accurate.

Some GPS apps do also sync the internal clock and I think it was columbus telling me how far off it was after syncing with satellite-time.

kureyon 2011-05-11 11:58

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
Quote:

Originally Posted by tmarinos (Post 1003928)
How do I know if its working?

Manually set the time to a few minutes off. After a little while (maybe an hour?) it will gradually sync to the correct time. NB I think the default behaviour for openntpd is to not make huge corrections but make multiple small corrections hence you won't see the clock corrected immediately.

negus72 2011-09-09 23:32

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
TANKS!!!
i fix my problem!


Quote:

Originally Posted by youxing (Post 440254)
I got openntpd working!

This is what I did!
Make sure you have a working internet connection!
Install rootsh over application manager if you haven't yet.

Open XTerminal

type:

Code:

sudo gainroot

apt-get install openntpd

(wait until it's done installing)

Then type:

Code:

ntpd
after around 20 seconds, the time on the N900 should have updated!

You can check whether you suceeded using the
Code:

date
command!

Everytime you want to update the time on your phone, you need to type

Code:

sudo gainroot
ntpd



m4r0v3r 2011-09-10 00:48

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
gps recorder syncs time with gps

int_ua 2014-03-12 10:28

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
How can I debug clockd? It was working ideally on my first N900, and doesn't seem to work on the second with the same software, SIM and settings.

vask 2014-08-30 21:35

Re: How can N900 sync time? GPS, NTP, and/or GSM?
 
Without a sim card and with inserting a new battery, I can make my n900 sync time over wifi on startup with:

Code:

root
vi /etc/event.d
  start on started hildon-desktop
  script
    sleep 60
    exec /usr/sbin/ntpd ntp.ubuntu.com
  end script

To disable the prompt that requires you to set the date and time each boot on a new battery insert do:
Code:

sudo apt-get remove osso-startup-wizard
See: http://talk.maemo.org/archive/index.php/t-87080.html

= More Info =
My usb charging port is broken. However, I have 2 batteries and charge them in an external charger. I have to swap them 2x a day. I do not have a sim card.

Previously I had to manually sync time every time I changed a battery (pressing a few buttons or running a script) and click on the set date and time prompt!

= Failed Attempts =
My n900 doesn't have the man command (not sure how to get it) so writing scripts was kind of difficult. Below are my failed automation attempts.

== sh ==
shell script works but can not be used with:
* alarmd GUI (only runs the first reboot after saving an event)
* event.d (couldn't get it to run correctly)

=== script ===
vi vask.timesync.sh
#!/bin/sh
echo '/usr/sbin/ntpd ntp.ubuntu.com' | /usr/bin/root
chmod +x vask.timesync.sh
./vask.timesync.sh

== rootsh ==
won't let me run it because it says deprecated and security risk


All times are GMT. The time now is 18:41.

vBulletin® Version 3.8.8