Time Keeping on a Psion 5MX
The problem: With every reboot of the psion (linux back to EPOC,
or EPOC to linux) the clock gets reset to 5 pm 1 January 1999. The clock
needs to be reset every time. Having the clock/time go backwards in linux
presents a variety of problems; the situation is unhappy. I don't believe
that the psion has a hardware clock like PC's have.
An awk script to interactively set the date in linux can be downloaded HERE.
The plan: With the time properly set in either linux or EPOC, have the
system write the date and time to a file at shutdown/reboot, and then
have the new system read the file and set the time from it. A few seconds
will be lost between reboots, but it is better than the alternative. (One could
get clever and add a few seconds before writing the time to the file, but that
may be just asking for trouble.)
I will call the file with the single line that keeps track of the time"date.txt"
and it is located on the msdos partition of the compactflash. It is thus
accessible from either linux or EPOC. My msdos partition is /msdos in linux,
and it is merely the "D:" disk in EPOC.
In linux:
At boot up: In the file /etc/rc, there is a
line /bin/date $(cat /msdos/date.txt)
that
sets the time from date.txt
At shutdown: In the file /etc/halt, there is a line
/bin/date +%m%d%H%M%Y.%S > /msdos/date.txt
This saves the date/time in a convenient format for setting the date/time
at bootup.
For a while I also ran the date command from /etc/crontab, with the idea
that saving the time regularly would give better timekeeping in the event
of a crash (which only happened when the batteries ran out). However, I was
reminded that the compactflash only has a finite number of writes before it
"wears out". A number of 100,000 writes has been mentioned. If one wrote
the time every 5 min., 100,000 writes would occur in little under a year (but
the compactflash cards are smarter than that and they "even the wear out"
over the entire disk. In any case, lets not save the time using crontab. The
line to do so, should you need it, is:
*/5 * * * * root /bin/date +%m%d%H%M%Y.%S > /msdos/date.txt
which will save the time every 5 minutes.
The form of the date.txt file is (using today's time and date as an example):
020321512002.05
for Feb 3 at 21:51:05 o'clock in 2002.
This form is that required by the linux "date" command to set the system time.
In EPOC:
Things are a little more difficult because there are programs that need to
be run to read the date/time and then set the system's clock, or get the
system time and then write the date/time to the d:\date.txt file [known as
/msdos/date.txt to linux].
At boot up: With a strong hint from an e-mail from Mikko's, I wrote
a program called "setdate" that will read d:\date.txt and set the psion's
system clock. I had heard that one can run programs at startup, by making a
text file called d:\System\data\wsini.ini with the line "STARTUP d:\setdate.opo".
This should make the psion run this program at startup. For example
"STARTUP d:\arlo\arloapp.exe" causes ARLO to startup immediately.
However, the wsini.ini file does not seem to work to run the setdate.opo
program (but it will work to run ARLO). I thought I had it working for a while
but it won't work now. If the d:\System\data\wsini.ini file is in error somehow,
the psion will not boot up, and gave me repeated beeps. One can pull out the
compactflash card to get the psion to continue its bootup. So at the moment I
run "setdate" manually; see Mikko's notes below for tips on programs that will
autoexecute the setdate program.
The OPL32 program can be downloaded in its text form HERE. It is a slight
variation on Mikko's program given in the e-mail noted below. The program
needs the "date.oxh" file, which I gather comes standard with the psion
computers - if you need it you can get it from HERE (the DATE OPX).
At ARLO startup: This stage is easier, although one has to be careful to write
the d:\date.txt file in a form that is readable by linux (there are hidden
characters in the EPOC text files). The program to do this can be downloaded
in its text form HERE.
At some future time, it would be nice if ARLO did this automatically to avoid
having to remember to run this program - I put the program in the same
directory as the arloapp.exe program to remind me to run it before booting
to linux. Or more generally, perhaps ARLO could use a file like the wsini.ini file,
which would allow the user to automatically run custom programs before
booting to linux for a cleaner shutdown of EPOC.
I think that's all I wanted to say.... B. Dushaw 2/3/02, revised 3/17/02
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Mikko's e-mail can be found HERE.