Linux on the Webpal
This page describes what I did to run Linux on the
Webpal.
Flash Partitions
There are two version of flash SIMM on the Webpal, a 1MB flash (512K x
16) and a 2MB flash (512K x 32). It's easy to tell the
difference: the 1MB flash SIMM has only a single flash chip while the
2MB flash has two flash chips. Most Webpals came with the
1MB flash. Some
2MB systems are now showing up or with a careful hand, one can add a
second flash chip to a 1MB SIMM to turn it into a 2MB flash
SIMM. I've done this myself by removing the flash
chip from one SIMM board and adding it to a second SIMM
board. I use the ChipQuik®
SMD removal kit #SMD1 to help make it possible to remove the SIMM
chip without damaging it. This kit contains two very
useful items, flux in a syringe and very low temperature
solder. The kit costs between
$15-$20. I bought mine at Digikey but I've seen it at
Fry's stores in the San Francisco Bay area.
The starting offsets of the first three partitions are fixed -- they
are hardcoded in the bootp program. The starting offset of
the
root partition can be moved. This gives the ability to
adjust the sizes of the zImage (kernel) and root partitions to meet a
particular application's needs. For example, one might want
a larger kernel and use NFS for the root partition.
In this case, the root partition start could be set to zero and the
zImage partition would then be 992K.
If you have a SIMM with a 1MB, the flash is divided into the
following
partitions:
Partition Description
|
Starting Location
|
Length
|
bootstrap loader
|
0x00000
|
24K
|
parameters
|
0x06000
|
8K
|
zImage
|
0x08000
|
variable (default = 608K )
|
root
|
variable (default = 0xa0000 )
|
variable (default = 384K
|
If you have a SIMM with a 2MB flash, the flash is
divided into the following
partitions:
Partition Description
|
Starting Location
|
Length
|
bootstrap loader
|
0x00000
|
32K
|
parameters
|
0x08000
|
16K
|
zImage
|
0x0c000
|
variable (default = 592K)
|
root
|
variable (default = 0xa0000 )
|
variable (default = 1408K)
|
As you can see, there is not much room to store
a reasonably useful root partition on the 1MB flash. For a
1MB flash system, most people either mount root via NFS or install some
sort
of
IDE
device as described below. For 2MB flash systems,
there is the possiblility of using the Webpal with only the
onboard flash since the root partition is now over 1MB.
Here is a short description of the partitions:
- The bootstrap loader partition contains the bootstrap
loader. This is the program that runs when the system
is reset or powered on. It initializes the the hardware,
copies
the Linux kernel from the zImage partition into memory, and
branches to it. The bootstrap loader also contains a flash
programmer that can reprogram any of the partitions.
- The parameters partition contains parameters for the
bootstrap loader. This partition consists of zero or more keyword=value
parameter lines. The end of the parameters lines is
marked with a null line (at least two NLs in a row). The
parameters are described below.
- The zImage partition contains the kernel
zImage. The bootstrap loader copies this into RAM and
then branches to it.
- The root partition contains space for a root
partition. If the kernel parameters specify root is /dev/mtdblock3,
this partition must contain the root filesystem
image. Because of space issues, this will probably be
a cramfs
image. Using a cramfs image for root is allowed in this
case since the kernel image does not reside on the root
partition. If you are not using the root partition, it is
possible to tell the bootstrap loader and programmer to use part or all
of its
space for a larger zImage partition.
Bootstrap loader (V3.3)
The bootstrap loader initializes the Webpal, copies the zImage from
flash into RAM, and branches to it. Status messages are output to
either the video interface or serial port. V3.3 supports
both
1MB
(16 bit wide) and 2MB (32 bit wide) flash. A new wpflash program is required when
using V3.x for flash programming. The new wpflash
program supports both V3.x or V2.x for flash programming.
By default, bootstrap messages are output to the VGA port and the
parallel port is used to connect to a
Linux system for flash programming. If you wish to
build a
serial interface, you can use the serial port for
both
bootstrap messages and flash programming. This is
done using the
serialbootp parameter as
described in the parameters section.
Holding down the SW2
button inside the Webpal while resetting will cause the bootstrap to
use the alternate device(s) used for output/programming.
For example, if
normallythe serial port was used, holding down the SW2 button
during
reset would cause the webpal to use the video and parallel ports
instead.
The bootstrap loader contains a flash programmer that can erase,
program, and read any of the partitions on the flash.
A program called wpflash runs
on another Linux system and communicates with the flash
programmer via either the Webpal's serial or parallel port.
Use of the serial port requires the construction of the RS-232-C level
adapter described elsewhere on this page. Use of the
parallel port requires
a parallel Laplink cable which you can purchase at your local computer
store. Use of the parallel port also requires that your Linux
system
contains the parport driver, a driver that allows user level access to
the
low level parallel port routines in the kernel.
The bootstrap loader can detect both known versions of the Webpal
CPU board and whether a 16 bit or 32 bit flash SIMM has been
installed. This information is displayed as the system
boots.
If you program a 32 bit flash SIMM as a 16 bit flash, the bootstrap
loader will still work. However, if you then program the
flash using the bootstrap loader, its will
reprogram the flash in 32 bit mode. This provides a method
of bootstrapping 32 bit
systems. First, bring the bootstrap up as though the
flash were 16 bits wide. Then, use the onboard programmer to
reprogram it in 32 bit mode.
Bootstrap loader parameters
Data in the parameters partition controls the bootstrap loader
behaviour. The data consists of ASCII lines of
text in the
format:
name=value
The end of the parameters file is indicated by a NULL line (two or more
NLs in a row)
Here are the parameters supported by the bootstrap loader:
If value
is 1, bootstrap messages are
sent to
the serial port and the serial port is used for
the flash programming. If value
is 0 or this parameter
is not specificed, bootstrap messages are sent to the VGA screen and
the parallel port is used for flash programming. Holding
down SW2 inside the Webpal while resetting will change negate the serialbootp value.
text is appended to the command
argument passed to the kernel (example:
command=boot=/dev/mtdblock3 )
Defines the IDE parameters passed to
the kernel (example: ide=0x170,0x376,11 ). Generally, this
parameter is not needed as the bootstrap loader will automatically
configure the IDE interface to match the IDE parameters in the Linux
Webpal port.
Defines the console parameters for the
kernel (example: console= ttyS0,115200 )
Defines the parallel port parameters
for the kernel (example: parport=0x278,13 )
The root file
system is mounted readonly. Otherwise, the root file
system is mounted read/write.
TV output is disabled, saving power and
allowing the Webpal to run much
cooler. This is recommended unless you are using the TV
outputs. Note that setting tvoff does NOT disable the VGA
outputs. This option is required if you plan on using
the IO pins for the RTC mod.
Specifies a new hexadecimal value for the
starting offset of the root partition. Since the zImage partition
immediately precedes the root partition, this value also specifies the
end of the zImage partition. A value of zero means no root
partition and the entire root partition space is added to the
zImage
partition. The value must make a sector address in the
flash. This means that
the address must be divisable by 0x10000 for a 1MB flash or 0x20000 for
a 2MB flash. During programming, the wpflash
program read this parameter from
the flash before programming and will take its
setting into account when calculating a partition start and
stop. In addition, the bootp program passes all
the partition information to the kernel using the 'Compaq'
format. If this option (Compaq bootldr
partition table parsing in the Memeory Technology
Devices (MTD) section) is specied during kernel configuration,
then the kernel will correctly determine the starting offsets for the
partitions.
Here are the pointers to the source code and a compiled binary of the
bootstrap loader.
As an aid to getting started, I can program your flash with the
bootstrap loader
if you mail me your flash chip with return postage. Please
contact me at the email address below for more information.
Flash programming
To initially program the bootstrap loader into flash, I built a standalone flash programmer.
Both this standalone programmer and the programmer in the bootstrap
communicate
with a Linux system via either the serial or parallel
port.
The program running on the Linux system is called wpflash.
Here are short instructions for running the flash programmer:
wpflash [-p] [-nowait] <operation> <partition>
<optional filename>
-p
use parallel port (requires user space parallel port control via
/dev/parport0).
-nowait use standalone programmer
(don't wait to synchronize with bootstrap loader reboot)
operation:
read read flash partition
to file
write write flash partition
from file (partition is automatically erased)
writehex write flash partition from hex file
(partition is automatically erased)
erase erase partition
partition:
all the whole flash
boot the bootstrap
loader partition
params the bootstrap params
zImage the kernel zImage
root the root partition
Start wpflash first and then press the
reset button on the
Webpal and programming should commence. If you have
problems synchronizing (this generally happen only in the parallel port
mode), hold down the reset button, start the wpflash
command, and then release the reset button.
Kernel Building
Here is a
toolchain that can be used to build kernels on x86 linux systems.
The kernel patches are relative to the rmk patches on the ARM Linux site.
Apply these patches after you have applied the appropriate version of
the rmk patches to the base kernel vesion.
The current Webpal patch
is relative to:
Linux-2.4.18 and
2.4.18-rmk4 .
A sample config file and zImage:
- Includes NFS client device driver and ethernet
driver. Can be set up to boot root from an NFS
volume. Console is VGA output / PS-2 or IR keyboard.
No IDE driver. Check out the config file for more details.
Here are some kernel configuration options of note:
- Compaq
bootldr partition table parsing under Memeory Technology
Devices (MTD): this option should be enabled so that the kernel
can correctly determine the partition starting
offsets. The bootstrap loader passes the partition
offsets to the kernel in this format.
- Plug
and Play support and ISA Plug and Play support
under Plug and Play configuration:
these options should be enabled if you are using an ISA PNP
ethernet card so that the card will be correctly configured by the
kernel. If you do not enable these options, then you must
manual configure you ethernet card to enable it in non-PNP mode.
- Webpal
IR keyboard support under Frame-buffer
support / Console drivers: this
option should be enabled if you wish to use the IR
keyboard. If you do not enable this option, then you
will have only the PS2 keyboard port and the serial port coming from
the 805x microprocessor will be instead accessable via
/dev/ttyS1. This is useful for debugging the IR
keyboard keycodes or for applications where the 805x
microprocessor to perform other functions.
Root file system
For the root file system, there are several options:
- use the built-in IDE interface and hook up a Compact Flash or
2.5 inch IDE drive using an adapter.
- get everything to fit in the 384K available on the root
partition on the onboard flash.
The Debian ARM distribution is a good source of precompiled binaries
for building your root partition, either NFS or on an IDE
device. Of course, the usual popular embedded Linux
packages like busybox and uClib can be used by compiling
them for the ARM processor.
Here is a source of some binaries
and source files.
Root file system on Compact Flash
I generally use a Compact Flash via an IDE to Compact Flash
Adapter.
I mounted the adapter under the main Webpal PC board on the bottom
metal
cover and then cut a slot in either the front or back panel so I can
insert
a Compact Flash card. Here is a picture
showing the back panel version.
Due to a bug in the Webpal hardware, you need to pin
that needs to be lifted to make the IDE interface work.
Root file system on 2.5 inch IDE notebook drive
A normal IDE drive can also be used. 2.5 inch drives are
easier to use because they fit into the available space and only
require +5V. You can steal the +5V from the existing 5V
regulator,
although it will run hotter. You'll need some sort
of adapter between the larger 40 pin adapter and the 44 pin connector
on
the 2.5 inch drive. There is about 11/16 of an inch
clearance
if you decide to mount the disk inside the unit, so be sure to use a
12mm
or thinner drive. Here are some pictures of adding a disk to the
webpal:
Root file system on onboard flash
To use the root partition on the onboard flash, your root image must
fit in 384K with a 1MB system. This means probably only a
few applications and maybe busybox.
Ethernet boards
I've replaced the serial modem with an NE2000-clone ethernet
card. Due to restrictions in the ISA bus interface on
the Webpal, experience has shown that only ISA ethernet boards based on
the Realtek
8019(AS) chip seem to work. An example of such a card is
the
Kingston KNE20T.
The current kernel supports ISA PNP if enabled during kernel
configuration. This allows
you to use the ISA PNP ethernet cards without having to set the card to
non-PNP
using its DOS utility.
If you wish to run a kernel without ISA PNP enabled, then you will need
to set the ethernet card to 0x300
and make sure it is set to use IRQ3 since that's the only interrupt
line wired to the ISA bus slot. This maps to
interrupt #9 in ARM linux.
The ne driver should work either compiled into the kernel or as a
loadable module.
On a non-PNP system, load the driver
with these two commands:
insmod 8390
insmod ne io=0x80400300 irq=0x09
For a PNP system, use:
insmod 8390
insmod ne
Serial Port
I built a RS-232-C serial port
adapter to use the sytem without a display in various server
applications.
Be sure to cut JP1. If you don't,
the IR receiver is also connected to this RS-232-C port and can cause
garbage
characters on the serial port.
IR keyboard / smart card slot
The current kernel patches support both the PS2 keyboard port or the
IR keyboard. There is a configuration option in the video driver
section to enable/disable the IR keyboard. If the IR
keyboard is disabled, the serial path used by the IR keyboard appears
as /dev/ttyS1. This is useful if you wish to reprogram the
AT89C52 for other purposes.
Based on my initial disassembly of the code in
the AT89C52, it doesn't appear there is any smart card support.
Reprogramming the AT89C52
As supplied, the AT89C52 decodes IR keyboard input and sends it on a
serial port to Linux. Normally, this data goes to a
keyboard driver in Linux. However, if
the IR keyboard is
disabled, the serial port data from the AT89C52 appears to Linux as
/dev/ttyS1.
I use this option when I want to reprogram the AT89C52 microprocessor
to do other things. For example, I've reprogrammed the
AT89C52 to decode wireless weather station signals from a small
receiver and send the results via the serial port to the
Webpal. The application on Linux simply reads the data by
opening /dev/ttyS1. Many other possibilities exist to reprogram
the AT89C52 for other tasks and have it communicate with
Linux.
Modem
If you are using the modem that came with the Webpal, it now appears to
Linux as /dev/ttyS2. This is a change from older
kernels where it appeared at as /dev/ttyS1.
What works and what doesn't
The following devices seem to work:
- Serial debugger port (ttyS0)
- Modem port (ttyS2)
- Display
- Sound
- PC Keyboard port
- PC Mouse port
- IDE (be sure to raise the pin as described above)
- Parallel port
- Some NE2000 compatible Ethernet boards (those using RTL8019AS)
- MTD driver allowing you to read and program the flash from
Linux
- LEDs (red LED shows activity; yellow LED flashes once per second)
- IR keyboard
Not working (or not tested):
- Floppy. No one has tried it.
- Smart card slot. There is no code to
support the smart card slot in the AT89C52 chip. That code would
need
to
be written before the smart card slot could be
used. The code could communicate via the second
serial port (shared with the IR
keyboard data) to Linux.
Other Webpal links
codeman's original
bootstrap loader (for 2.2 kernels)
rscott's loader
(including bootstrapping so you don't need a flash programmer -- but
still requires a serial port)
justdave has an ftp site that
contains some binaries and source packages for your root partition.
aswx has a schematic
and lot of info on the
Wepbal hardware.
tomw has a buildroot
script.
luban has a 64K DRAM
modification.
Last updated: March 4 2005 by Bill Danielson (
)