Linux MIPS Architecture development
 help / color / mirror / Atom feed
* Power loss and system time when not having a battery backed RTC
@ 2007-03-28 14:39 Attila Kinali
  2007-03-28 14:47 ` Markus Gothe
  2007-03-28 20:55 ` Ralf Baechle
  0 siblings, 2 replies; 4+ messages in thread
From: Attila Kinali @ 2007-03-28 14:39 UTC (permalink / raw)
  To: linux-mips

Moin,

I have a little bit more general question than usual.
I have here a system that should be deployed in Joe
Average's house as a small appliance. While it is powered
it will gather information and store them on its flash.

Now, this system does not contain a battery backed RTC
(not enough space) and thus does not know what date/time
it is after boot. At a later time the device will
be able to get a time quote from a time server using
a wireless connection. But as the wireless connection
is triggered by a user action, it can happen hours after
boot. This means that there is a quite long period whithin
which the device does not know what time it is and hence
assumes it's 1970.

My problem lies now in the back jumps that the device
makes, when unplugged and replugged. On the filesystem
there will be files from 2007, while the system still
thinks it's 1970.

How do you handle this issue with the back jumps, if you
cannot stick in a batter backed RTC?


Thanks for your help

			Attila Kinali
-- 
Praised are the Fountains of Shelieth, the silver harp of the waters,
But blest in my name forever this stream that stanched my thirst!
                         -- Deed of Morred

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Power loss and system time when not having a battery backed RTC
  2007-03-28 14:39 Power loss and system time when not having a battery backed RTC Attila Kinali
@ 2007-03-28 14:47 ` Markus Gothe
  2007-03-28 15:22   ` Attila Kinali
  2007-03-28 20:55 ` Ralf Baechle
  1 sibling, 1 reply; 4+ messages in thread
From: Markus Gothe @ 2007-03-28 14:47 UTC (permalink / raw)
  To: Attila Kinali; +Cc: linux-mips

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Attila Kinali wrote:
> Moin,
>
> I have a little bit more general question than usual. I have here a
> system that should be deployed in Joe Average's house as a small
> appliance. While it is powered it will gather information and store
> them on its flash.
>
> Now, this system does not contain a battery backed RTC (not enough
> space) and thus does not know what date/time it is after boot. At a
> later time the device will be able to get a time quote from a time
> server using a wireless connection. But as the wireless connection
> is triggered by a user action, it can happen hours after boot. This
> means that there is a quite long period whithin which the device
> does not know what time it is and hence assumes it's 1970.
>
> My problem lies now in the back jumps that the device makes, when
> unplugged and replugged. On the filesystem there will be files from
> 2007, while the system still thinks it's 1970.
>
> How do you handle this issue with the back jumps, if you cannot
> stick in a batter backed RTC?
>
>
> Thanks for your help
>
> Attila Kinali
Be creative or use the battery, you could for example set a timestamp
in a file at shutdown and use it to set the date on power up, alas
this would be incorrect, so go for the battery.

- --
_______________________________________

Mr Markus Gothe
Software Engineer

Phone: +46 (0)13 21 81 20 (ext. 1046)
Fax: +46 (0)13 21 21 15
Mobile: +46 (0)73 718 72 80
Diskettgatan 11, SE-583 35 Linköping, Sweden
www.27m.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFGCoAR6I0XmJx2NrwRCNbtAJ9jMBSxe0WOvv3o844TCqbHKbmgOwCeNmOR
Uot4Bwa7+EYx3/8b7h4bVcM=
=X6k4
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Power loss and system time when not having a battery backed RTC
  2007-03-28 14:47 ` Markus Gothe
@ 2007-03-28 15:22   ` Attila Kinali
  0 siblings, 0 replies; 4+ messages in thread
From: Attila Kinali @ 2007-03-28 15:22 UTC (permalink / raw)
  To: Markus Gothe; +Cc: linux-mips

N'abend,

On Wed, 28 Mar 2007 16:47:48 +0200
Markus Gothe <markus.gothe@27m.se> wrote:

> Attila Kinali wrote:
> > How do you handle this issue with the back jumps, if you cannot
> > stick in a batter backed RTC?

> Be creative or use the battery, you could for example set a timestamp
> in a file at shutdown and use it to set the date on power up, alas
> this would be incorrect, so go for the battery.

We cannot stick in a battery as there is not enough space
in the housing of the print (to be exact, we don't have enough
height).

I already thought about storing the last known time somewhere
in the flash. But unfortunately the device can be unplugged
suddenly w/o correct shutdown (actualy this is the normal case).
The only way around this i could came up with was to periodically
store the current time. But this is then a trade off between
jump back period length and how long the flash will last the
continous writes, with no sweet spot that looks good.


Tack och ha det sa bra

				Attila Kinali
-- 
Praised are the Fountains of Shelieth, the silver harp of the waters,
But blest in my name forever this stream that stanched my thirst!
                         -- Deed of Morred

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Power loss and system time when not having a battery backed RTC
  2007-03-28 14:39 Power loss and system time when not having a battery backed RTC Attila Kinali
  2007-03-28 14:47 ` Markus Gothe
@ 2007-03-28 20:55 ` Ralf Baechle
  1 sibling, 0 replies; 4+ messages in thread
From: Ralf Baechle @ 2007-03-28 20:55 UTC (permalink / raw)
  To: Attila Kinali; +Cc: linux-mips

On Wed, Mar 28, 2007 at 04:39:14PM +0200, Attila Kinali wrote:

> Now, this system does not contain a battery backed RTC
> (not enough space) and thus does not know what date/time
> it is after boot. At a later time the device will
> be able to get a time quote from a time server using
> a wireless connection. But as the wireless connection
> is triggered by a user action, it can happen hours after
> boot. This means that there is a quite long period whithin
> which the device does not know what time it is and hence
> assumes it's 1970.
> 
> My problem lies now in the back jumps that the device
> makes, when unplugged and replugged. On the filesystem
> there will be files from 2007, while the system still
> thinks it's 1970.
> 
> How do you handle this issue with the back jumps, if you
> cannot stick in a batter backed RTC?

Forward jumps are usually much less of a problem.  Since your fs is based
on flash you will probably want to avoid writing timestamps all the time
but maybe a quick fs scan for the file with the latest date might provide
a reasonable value for the startup time.  At this time you know the actual
time should be newer than this date, so time will only jump forward.

Some standard also defines that time must increase strictly monotonically,
that is of two subsequent calls the second must return the higher time.
So my suggestion would also avoid triggering bugs in code that relies on
this sort of behaviour.

  Ralf

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-03-28 20:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-28 14:39 Power loss and system time when not having a battery backed RTC Attila Kinali
2007-03-28 14:47 ` Markus Gothe
2007-03-28 15:22   ` Attila Kinali
2007-03-28 20:55 ` Ralf Baechle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox