Linux Toshiba Libretto 70 "Retro
Mediaplayer"
1/2010
By
Greg Menke
gmlathe@comcast.net
My brother and I have a little game we play when we happen to be
travelling together;
- observe the license plates of surrounding cars, looking for those
which have three letters amidst the numbers. The letters need not
be adjacent- some states have the letters grouped, others don't.
- given the three letters, find words that use all three in the order
shown on the plate, but not necessarily adjacent each other
For example; the license plate "PRL 123" yields the letters P,R, and L-
one word in which they are used in order is "parallax", "prelate" is
another.
To help discover words that we were unable to think of quickly, I wrote
a program to search several word lists, find matches and display
them. I named it "Wordfiend" or wfiend, it is described in more
detail below.
A laptop is a convenient platform for this sort of application. Its
preferable to have something really small w/ a keyboard, running Linux
so its easy to maintain and manage. So I got a Libretto 70.
wfiend is set up to run on virtual terminal 0, at bootup. This
way, all I need to do to play it is turn on the Libretto. Once
booted, wfiend is ready to go.
Overall
Libretto's are nice, but getting an OS onto them is tedious.
PCMCIA floppy drives exist, but they always seem to be more trouble
than they're worth. My preference is to put the Libretto's hard
disk in a larger (faster) laptop with a cdrom, install Linux, then move
the disk
back into the Libretto. There are a couple nuances;
- The Libretto uses a fairly ancient Pentium cpu- i586 as far as Linux
is concerned. The candidate distro must offer an i586 target,
this likely precludes many of the modern binary distros- the install
must be targetted to the Libretto's cpu, not the host computer's.
- The host "laptop" (likely being newer) may use /dev/sda for the hard
disk, whereas the Libretto uses /dev/hda. This isn't a big
problem because you can edit /etc/grub/grub.conf and /etc/fstab before
transplanting the hard drive back into the Libretto. Ideally, the
host laptop (or PC) would be old enough to use /dev/hda, so the issue
won't arise.
- A modern SATA laptop will not work- you have to be able to install
the PATA hard disk. Alternatively, adapters that permit
connecting the laptop hard disk to a PC motherboard's PATA connector
are common, so you can host the Libretto's hard disk in a regular PC
for the Linux install.
- when partitioning the Libretto's disk, you should consider leaving
space unallocated where APM suspend writes the memory image. If
you don't reserve the space and suspend the Libretto, that chunk of
your filesystem will be summarily overwritten.
The sections below detail configuration settings I put in place to set
up the Libretto how I like it. Tastes vary, so these might be a
good starting point. The entire tree containing the files
referenced below starts here.
/etc/fstab
(link to fstab)
the disk partition is as follows;
Disk /dev/hda:
80.0 GB, 80026361856 bytes
255 heads, 63
sectors/track, 9729 cylinders
Units =
cylinders of 16065 * 512 = 8225280 bytes
Disk
identifier: 0x5f8d7688
Device Boot
Start
End Blocks Id System
/dev/hda1
*
1
5 40131 83 Linux
/dev/hda2
6
22 136552+ 82 Linux swap /
Solaris
/dev/hda3
1170 9713
68629680 83 Linux
Note the holes left both at the end of the disk, and below cylinder
1024. From various google references it sounds as if the
Libretto's BIOS suspend function writes to cylinders below 1024, so I
left them open- but also those at the end of the disk in case it writes
there. This leaves something like 20gb of the disk unavailable,
if I get to a point where I'm running out of space then I'll track down
where the writes actually go and reconfigure the partitions to be more
efficient.
Kernel
Because its so easily tailored, I used Gentoo Linux. I
prefer Fedora but it would not boot on the Libretto, its i586 target
was too new apparently. Regardless of distro, with the Libretto
disk in the host computer and the install completed, a kernel should be compiled,
tailored to the Libretto. This kernel is configured to be fairly
minimal, but it does include PCMCIA
(including PCMCIA lanboard drivers), audio, APM, and the IP
stack.
Linux wfiend
2.6.27-gentoo-r7 #13 Sat Jun 20 17:53:12 EDT 2009 i586 Pentium MMX
GenuineIntel GNU/Linux
(link to .config)
(link to /boot/grub/grub.conf)
Daemons, applications
As much software as possible should be installed with the disk
in the host computer- otherwise you'll probably be compiling for days
and some apps won't compile at all due to lack of memory. This
isn't a problem if you happen to use a binary distro with a suitable
target, but is when using Gentoo.
/etc/make.conf for my Gentoo installation
(link to /etc/make.conf)
As far as daemons are concerned, ssh, nfs, ntp are
helpful. Since the Libretto 70's performance is modest, its
helpful
to have the network related demons NOT start by default (saves memory
and boot-time when the unit is not going to be connected to a LAN,
which for me is most of the time). But when connection to a
network is intended, a PCMCIA lan board is inserted and the
appropriate daemons are started manually. This usually means
sshd,
which allows the user to log in from a PC which offers a
much more convenient keyboard and display.
I also found it helpful to leave the ntpd turned off, and instead issue
'ntpdate' manually when the Libretto is on the network. If you
allow its battery to run out, the system will lose its calendar
time. That doesn't present a problem as far as wordfiend and the
mediaplayer, but is annoying when you intend to
compile/maintain/install software- ntpdate is a simple one-step command
you can run when you need it.
/etc/inittab
I modified /etc/inittab to automatically login to various of the
virtual terminals, avoiding the tedium of typing accounts and passwords
on that tiny keyboard. As it happens, this was very helpful for
the Retro Mediaplayer- since a mixer can be started on one virtual
terminal while in another the media player resumes to where I
previously had paused & suspended. It also avoids the problem
of forgetting passwords if you don't use the computer for a
while. Security of the computer isn't of much concern (in my
application at least), since without a USB port, cdrom or network
nothing much is going into or out of the Libretto and I don't keep
anything important on it.
(link to inittab)
The following .bashrc handles starting the applications on a
per-virtual terminal basis
(link to .bashrc)
Suspend/Resume
To suspend the Libretto, I wrote a little script '/rc.suspend' which
handles the details of initiating an APM suspend, and upon wakeup,
reconfiguring the sound and hdparms. If the hardware reconfig is
not done, the soundboard will produce noise and the hard disk interface
will be slow. To run the script, I installed sudo and configured
my user account as NOPASSWD: ALL- thus "sudo /rc.suspend" can be
invoked
from anywhere.
(link to rc.suspend)
Sound
I chose to use Alsa for sound. The configuration I used is;
options
snd-opl3sa2 enable=1 isapnp=0 port=0x370 sb_port=0x220 wss_port=0x530
fm_port=0x388 midi_port=0x330 irq=5 dma1=1 dma2=0
Mouse
I found 'gpm' picks up the onboard mouse as PS/2 with no trouble.
I
usually leave the daemon off since the cursor is susceptible to
inadvertent select and paste when grabbing the Libretto's lid, where
the mouse buttons are.
Video
I installed X with my preferred desktop
(WindowMaker). It runs fine but the display being so small and
cpu so slow, using a gui requires patience. For one thing, the
mouse buttons and "eraser" pointer make window focus problematic.
Here is the xorg.conf;
(link to xorg.conf)
I did have success using 'dillo' as a web browser, though getting the
font sizes under control so webpages can be browsed was
difficult. Mozilla/Firefox are far too large to run efficiently
on a 32 meg Libretto 70.
Userspace
Having the Libretto working and configured, I installed the wordfiend
and player software. With respect to writing and maintaining
software for the Libretto, a cm system such as cvs or svn or equivalent
is extremely helpful. The software can "live" on a local Linux
box, maintained and enhanced there- and whenever the Libretto is
connected to the local network, the older revisions on it can be
updated trivially.
I also have a 64 meg Libretto 100, which is substantially faster and
uses nearly the exact same configuration. In fact I can move the
hard disk from the 70 to the 100 and it works fine. The X-Windows
driver is different, however the 100's faster cpu and additional memory
are advantageous- and I prefer its keyboard & display. I'd
switch to the 100 but do not have a good battery or a power adaptor for
it, both of which I have for the 70.
Wordfiend aka wfiend
located in /home/wfiend/wfiend
(link to files)
wfiend is a Common Lisp application. It accepts one or more
characters on the command-line (case insensitive), searches its word
lists and produces a set of matches. A match is defined as a word
that uses each of the three letters, in order but not necessarily
adjacent to one another. Each match is given a score. The
score is the reciprocal of the standard deviation of the number of
characters between each of the matching characters. I call it the
"dispersion" score. The higher the score, the more evenly the
matching characters are distributed amongst the other characters forming
the word. If the standard deviation == 0, then an arbitrary
perfect score of 1,000,000 is given. As it happens, perfect scores
are relatively rare so an artifically high perfect score causes the word
to jump out of the list of other matches.
The effective value of a match is primarily dependent on its subtlety,
with dispersion as a secondary factor. Seeing the license plate
"DOG
999" and yelling "dog" is worth little even though it has perfect
dispersion, however given "KGB 999" and
deducing "packageable" or "mockingbird" in real time is an overwhelming
victory regardless of dispersion. Dispersion is a reasonable way
of scoring words that are viewed as similarly "good".
Scrabble rules are used to specify acceptable words. Generally,
matches that use prefixes or suffixes are not preferred, although
they are acceptable, moreso when a given set of letters produces few
matches.
Dispersion is something of an aesthetic score, another score based upon
the frequency of use would be a useful enhancement. Possibly,
dispersion could be one axis and frequency (sans prefix and suffix,
lower frequency is better) another, the total score being the area
described. The perfect dispersion score would have to be
redefined, and frequency would have to be strengthened relative to
dispersion. I have downloaded some word frequency tables, but
haven't implemented the "frequency" score yet.
With respect to word lists, I found and downloaded the "12dicts" and SIL
International's "wordsEn.txt" English lists, both available on the
Internet. Handily, they include variations of words due to
prefixes and suffixes, so wfiend doesn't have to do any extra work
testing for them. Obviously these lists are not exhaustive, but
they are good for this purpose. Certainly good enough for
etymological sparring whilst on the road.
I wrote and tested wfiend using CLISP (an open source Common Lisp), but
the search is too slow on the Libretto (approx 40 secs). Compiling
wfiend using CMUCL improved performance considerably. I had the
best results by compiling wfiend in Lispworks, then copying the
executable onto the Libretto. This approach requires about 7
seconds to perform a search, which has proved adequate.
Implementation-wise, wfiend does a brute-force search of the lists,
scores each match and produces two lists, one sorted by word, the other
by score. Thus, a word can be found and evaluated either way-
helpful when a set of letters yields many matches. The search
algorithm has to find each letter of the search "vector", wherever it
exists in a candidate word, so checking for a match amounts to several
substring searches, one for each character, starting from the position
of the previous character's first match. A brute force search was
the easiest to implement, and not prohibitively expensive in cpu time or
index space, so I didn't develop it further.
Retro Mediaplayer aka player
located in /home/wfiend/player
(link to files)
(link to rc.book)
This is another Common Lisp application, written using CLISP.
This app does not present performance issues since the actual media
playing is done by mpg123, which player invokes. player's
function is to present a very simple and useful menu to control playing
"long" media such as ripped books-on-cd. It keeps a book's
"state" (which file of the set of files is being played, and the #
seconds
into that file) so a book can be resumed later (even much later).
Since each book
has its own state, any number of books can be in progress. My
usual procedure is to buy a book-on-cd, rip the tracks to mp3 files and
put them on the Libretto in a subdirectory which is given the book's
name, beneath ~/books. The original media is stored as
a backup. Thus, the directory "~/books/right-ho-jeeves"
contains the mp3 files comprising that audio book.
A book is played via "~/rc.book ~/books/[bookname]" where [bookname] is
the subdirectory in which the book's mp3 files are located. When
the player is stopped (perhaps to suspend the Libretto), the state is
saved to a text file named after the book's name. To resume
playing the book, the command is re-run, the text file is read, and the
player continues from where it was stopped. Since the book state
is in a file, resuming the book is not dependent upon suspend/resume or
restarts. player saves state every 1000 audio frames, so if the
app terminates (perhaps the Libretto runs out of battery and turns
off), then playback can be resumed from a point not too far before the
power-off.
player offers the usual sort of commands Pause, Quit, start Next file,
start Previous file, forward/rev the current file and Suspend.
Suspend pauses the playback, then invokes /rc.suspend- a convenient way
to stop playing the book and have the Libretto turn itself off.
Later, when the Libretto is unsuspended, player will be back where it
started and playback is easily resumed.
When player scans the directory containing the book's files, it
acquires a listing of all the mp3 files present and sorts them in alphanumeric
order. The mp3 files should be named so they end up in the proper
order. That usually means ensuring things like cd numbers and
track numbers are two digits (ensure the 2nd disc is named 'disc-02' so that
'disc-10' does not sort before it).
One advantage of player is that when it is not actually playing, the
audio device is not held open. This permits the suspend/resume
logic to work in a simple manner, and avoids interference with other
audio players. Although player will work fine for shorter mp3's
such as music files, it will not shuffle. In such an application
it will remember which song was in progress and will work its way
through an arbitrary number of songs, but skipping forward/backward
within a song is unlikely to work conveniently.
Note- player does not yet properly handle the case where it is playing
and suspend is initiated elsewhere. In such a case, when resumed,
garbled sound will be produced until the file being played is restarted
or player Quit.
;;;
eof
(home)