FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo Embedded

 
 
LinkBack Thread Tools
 
Old 03-30-2011, 02:06 AM
Joe Sapp
 
Default Getting network time early in boot

Hi all,

I've got a board with no RTC so there are some problems during boot.
Currently there's a hack in the udev init script to get the time from the
network (via ntp or rdate), but I'm wondering if somebody else has solved
this in a better way. Any ideas?

Thanks,
Joe
 
Old 03-30-2011, 04:47 AM
Mike Frysinger
 
Default Getting network time early in boot

On Tue, Mar 29, 2011 at 10:06 PM, Joe Sapp wrote:
> I've got a board with no RTC so there are some problems during boot.
> Currently there's a hack in the udev init script to get the time from the
> network (via ntp or rdate), but I'm wondering if somebody else has solved
> this in a better way. *Any ideas?

add your own init.d script, mark it "before udev', and add it to boot runlevel ?
-mike
 
Old 03-30-2011, 08:59 AM
Wolfgang Denk
 
Default Getting network time early in boot

Dear Joe Sapp,

In message <4D92902B.5000300@gentoo.org> you wrote:
>
> I've got a board with no RTC so there are some problems during boot.
> Currently there's a hack in the udev init script to get the time from the
> network (via ntp or rdate), but I'm wondering if somebody else has solved
> this in a better way. Any ideas?

If your board uses U-Boot as boot loader, you can enable SNTP support
in U-Boot and get and set the time already there, before you even boot
into Linux.

Best regards,

Wolfgang Denk

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de
"Faith: not *wanting* to know what is true." - Friedrich Nietzsche
 
Old 03-30-2011, 01:59 PM
Ed W
 
Default Getting network time early in boot

On 30/03/2011 05:47, Mike Frysinger wrote:
> On Tue, Mar 29, 2011 at 10:06 PM, Joe Sapp wrote:
>> I've got a board with no RTC so there are some problems during boot.
>> Currently there's a hack in the udev init script to get the time from the
>> network (via ntp or rdate), but I'm wondering if somebody else has solved
>> this in a better way. Any ideas?
>
> add your own init.d script, mark it "before udev', and add it to boot runlevel ?

You would still have the problem that you can't run it until at least
after you start network of course?

Some people might not know of /etc/init.d/swclock. It writes the time
at shutdown and restores *that* old time on bootup. For some scenarios
that might get you a time close to reality... (eg if you just want to
check stuff like "has this file changed" and avoid "clock moved
backwards" kind of issues)

Good luck

Ed W
 
Old 03-30-2011, 02:21 PM
Mike Frysinger
 
Default Getting network time early in boot

On Wed, Mar 30, 2011 at 9:59 AM, Ed W wrote:
> On 30/03/2011 05:47, Mike Frysinger wrote:
>> On Tue, Mar 29, 2011 at 10:06 PM, Joe Sapp wrote:
>>> I've got a board with no RTC so there are some problems during boot.
>>> Currently there's a hack in the udev init script to get the time from the
>>> network (via ntp or rdate), but I'm wondering if somebody else has solved
>>> this in a better way. *Any ideas?
>>
>> add your own init.d script, mark it "before udev', and add it to boot runlevel ?
>
> You would still have the problem that you can't run it until at least
> after you start network of course?

that depends on how the board comes up. if the boot loader provides
network settings to the kernel (autoconfig), it might be up. or if
people have an initramfs that brings things up.

> Some people might not know of /etc/init.d/swclock. *It writes the time
> at shutdown and restores *that* old time on bootup. *For some scenarios
> that might get you a time close to reality... (eg if you just want to
> check stuff like "has this file changed" and avoid "clock moved
> backwards" kind of issues)

that can be useful depending on the system needs. i tend to forget about it .
-mike
 
Old 03-31-2011, 11:55 AM
Joe Sapp
 
Default Getting network time early in boot

On 03/30/2011 04:59 AM, Wolfgang Denk wrote:
> Dear Joe Sapp,
>
> In message <4D92902B.5000300@gentoo.org> you wrote:
>>
>> I've got a board with no RTC so there are some problems during boot.
>> Currently there's a hack in the udev init script to get the time from the
>> network (via ntp or rdate), but I'm wondering if somebody else has solved
>> this in a better way. Any ideas?
>
> If your board uses U-Boot as boot loader, you can enable SNTP support
> in U-Boot and get and set the time already there, before you even boot
> into Linux.

It does use U-Boot, so maybe a combination of this and swclock (from
sys-apps/openrc) is the most reliable way to set the time for my application.

Thanks all for the ideas.

Joe
 

Thread Tools




All times are GMT. The time now is 04:39 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org