HOWTO-Linux-On-WinCE-Hobbyist
Brandon Knitter
[email protected]
http://unixce.blandsite.org/
Copyright (c) 2002 Brandon Knitter.
Permission granted to copy and display.
Version: $Revision: 1.1 $
SUMMARY
This document is to describe how to get Linux running on a handheld device
that typically runs WindowsCE. Being this a limited discussion, it is
important to note that the test platform for this HOWTO is a
Hewlett-Packard Jornada HP680, and that although you may find other
devices work with this description herein, there are no guarantees.
The document and it's descriptions will not necessarily get you a fully
functional and useful Linux. Each time you reboot, everything will be
lost! So keep that in mind. Like the name of this HOWTO, this is for
hobbyists. If you want to get a more useful system, this is a great
place to start, but I don't currently have a distribution for you yet.
Please check my web site (above) frequently as I really want a useful
system, and I'm willing to share! :)
One of the best places I found out my information was the GNU/Linux on
SuperH Project page. Not only was there good information there, but
there is also a link to the mailing list, as well as the archives. I
read the entire archive and got a wealth of knowledge. I suggest
pulling for the whole site, and taking the time to read it before
asking questions. For the most part people there have been VERY
helpful, and have offered solutions to questions that I should have
known, but just didn't.
OVERVIEW
As stated above, I am using an HP680 Jornada with an SH3 chipset. I don't
know the specifics of the kernel nor the bootloader, but references to
more descriptions and information are attempted. Although this guide will
not (at this time) get you a fully usable Linux on your handheld, you will
at least be able to get a prompt and say "Weeeeeeeeeeeeeeeeee!".
! WARNING ! WARNING ! WARNING ! WARNING ! WARNING ! WARNING ! WARNING !
It is vary likely that you will blow up, harm, or otherwise do bad things
to yourself, others, or your cute little device by following these
instructions. There is no warranty expressed or implied by your usage of
this document. My usage and experience is that I lose everything on my
handheld each time I play with it. Expect to do so yourself. In some
cases, this might even wipe out your entire OS, and render your little
device completely useless. Don't expect the manufacturer to be too
much help when this happens.
! WARNING ! WARNING ! WARNING ! WARNING ! WARNING ! WARNING ! WARNING !
QUICK START
Before you start too fast, did you read the warning above? Read, then,
if you just want to see it working you will need four files, and you can
get them at: http://unixce.blandsite.org/download/BlandLinuxCE-0.0.1.tgz
or by visiting the download page itself at the following location:
http://unixce.blandsite.org/download/ .
1) shlo.exe - This is the actual bootloader
2) shlo.txt - This is the boot loaders configuration
3) zImage - This is the kernel...you know, the Linux kernel
4) initrd.gz - This is the initial root device (basic filesystem)
So you're impatient, right, that's why you're reading this section.
Drop those files onto the HPC and double click the shlo.exe. A window
will pop stating that it's gonna load zImage and initrd.gz. And you're
away. Be patient, be very patient, it takes my device about 30 seconds
to boot up to a penguin.
With any luck, you'll end up with a prompt that says "enter runlevel".
Just then an "S" or "s" (no quotes) and press enter. Whammo, you are
in. This is not terribly useful, but it is a bash shell in Linux on
your previously WinCE device. Press the reset button to reboot and see
all your data is gone! :( If you used a CF (compact flash) card, you
will keep everything you had previously, on that card. So I suggest
you use that for the four files, or you'll be copying all day again!
DO IT YOURSELF
So, hopefully by now you did the quick start. I'm a big proponent of
just seeing something working, and then going back and doing it myself.
If I don't see something working first, I tend to a) no believe it will
ever work...and the world is gonna end, and b) no have a clue what the
heck I'm looking for. So I'd say start there, and then come back. If
you're someone that like to just forge ahead and can stand the
suspense, or maybe you're stuck on the road, traveling half way around
the world to meet your relatives, and you printed this out so that you
may have something to do, first of all, say "hi" to everyone, secondly,
read on!
To get things working you will need to go through and make each of the
components as mentioned in the QUICK START section. See that section
for the list and follow the directions below for more information.
I didn't use anything too specific, and I did all my work on a
combination of Linux (2.2.15-4mdk), Windows (2000 Professional), and my
little WinCE. Make sure that before you start that you do already have
the partnership between your HPC and your desktop working. The main
reason for the Windows machine and partnership is for copying files to
your HPC. There are many other ways to get them there including
getting your CF card to mount under Linux or get your HPC serial
connection to talk to Linux. In any case, you need a link, and it is
beyond the scope of this HOWTO to describe those. I'll try to add a
REFERENCES section at some point.
BOOTLOADER
The bootloader is that takes the kernel (zImage) and loads it into
memory, with specific switches and such. It's only job is to load the
kernel, then it's just about done. As the file size suggests, it's
got a fairly small amount of code, to do a small job. At the time of
this writing, I have not secured the source code for shlo.exe, nor do I
intend to.
NOTE: The shlo bootloader provided will only work on WinCE 2.10 or
greater. And I'm not sure if it will work on WinCE 3.x or greater.
There is a trick that the bootloader must do to load the kernel into
memory. Basically, it needs to tell WinCE to get the hell out, drop
down to the chip (sh3) and start executing the kernel code at the
kernel level. Most apps run at the user level, and, well, that's just
not good enough for the kernel to load. To accomplish this amazing
feat there is a system call of "bool setKMode(bool)" that is made.
(Feel free to check out the Windows CE Development Kit from Microsoft
if you want more specifics.) This system call is NOT available in
earlier version of WinCE (<2.10), and from some rumors I've read, it's
not in 3.x+ either. With that said, if you run shlo.exe and you get a
bad referenced function, or some sort of error like a "0x0000000" or
something, changes are your OS won't load the kernel. Are you now shit
out of luck? YES! Until someone comes up with a way to get into
kernel mode on earlier version, you're just hosed. Sorry, do what I
did, buy a version with WinCE 2.10+, or find out if you can get a
flash/rom upgrade from the mfg. HP doesn't offer such a beast, so my
320lx and 660lx are just laying around. If you have or write something
to load on a newer version , PLEASE PLEASE PLEASE tell me about it!
BOOTLOAD CONFIG
This thing is fairly easy to work with, and for the most part, you
shouldn't need to stray too far. There are little tweaks and such you
can do, but I'm just gonna drop you in a basic one. If you want to
write up a nice doc for how to config shlo, I'd be willing to reference
your site, or even add it to this HOWTO.
For the most part, my config looks like this:
-- cut here --
platform = hp680
boot page = 0x0c000000
load file = 0x0c210000 zImage
load file = 0x0c400000 initrd.gz # ram disk image
start address = 0x8c210000
set long = 0x8c001000 0 # MOUNT_ROOT_RDONLY
set long = 0x8c001004 0 # RAMDISK_FLAGS
set long = 0x8c001008 0x0100 # ORIG_ROOT_DEV
set long = 0x8c00100c 1 # LOADER_TYPE
set long = 0x8c001010 0x00400000 # INITRD_START
set long = 0x8c001014 0x00400000 # INITRD_SIZE
set string = 0x8c001100 mem=16M ramdisk_size=8192
-- cut here --
Pretty straight forward? There are other things you can pass to the
kernel on that last line, including ethernet driver config and such,
but that's beyond the scope of this document. Keep in mind that if you
build a bigger initrd.gz file (from more than 8M of stuff) you need to
adjust the "ramdisk_size" parameter to match it. That goes for a
reduction in size too. I'm at 8M right now cause I just chucked a
bunch of stuff into the initrd.gz. I'll be making it smaller once I
figure out how to do the whole pivot_root call in the kernel startup.
One thing that confuses the hell out of me is the INITRD_SIZE entry.
That's just not right. I get 0x0040000 in hex converted to dec as
4194304, assuming that's bytes, then I only get 4M. Even though my
ramdisk_size entry is set to 8192. Perhaps I'm missing something here?
I'll just take a guess and say that the "set long" is overridden by the
"ramdisk_size" entry? I think I remember reading that somewhere, but
then again I read that on a page that I translated from Japanese to
English...
If you don't have an initrd.gz file, you can remove the "load file" and
both "set long" entries, and remove the "ramdisk_size" entry as well.
You should still see your kernel boot, but it will quit after it boots,
cause there is no initial root device.
KERNEL
I am NOT going to tell you have to compile that in this document. Just
use the one I gave you, or figure out how to compile the kernel on your
own! And if you figure it out, tell me about it! ;-) There are plenty
of docs out there that will tell you how to do this, and I'll even
write one myself when I figure it out...and I will, damnit! So check
back frequently. Meanwhile there is a decent page listed in the
REFERENCES.
INITIAL ROOT DEVICE
Well, for a section to be big, this will be it! The other sections I
just spoke about the pieces, and then told you I knew nothing out.
Well this section actually has some meat! How about them apples? :)
The initial root device is the first compressed drive image that the
kernel loads. There are some good docs on how this is loaded from the
kernel, I suggest you read that at some point, but it's not really
absolutely important to read it right now.
The basic thing you are going to do is to grab a bunch of already
compiled RPMs, expand them into a dir, and then make that directory
into a filesystem image. It's not as hard as it may sound, but I've
made shell scripts to make it all work quickly. I'll include them
below.
To get the precompiled files, I went to the SH-Linux home page and
grabbed their "development tools" stuff. It's a great site cause they
have sh3 and sh4, both with little and big endian support. Great
people to give us all this precompiled stuff. And, well, it just
works. For my usage, I needed little endian sh3. If you don't know,
then ask around.
Here is my script that I use to create my root file system image:
-- cut here --
#!/bin/sh
rm -rf /tmp/rootfs
mkdir /tmp/rootfs
mkdir /tmp/rootfs/dev
mknod /tmp/rootfs/dev/console c 5 1
mknod /tmp/rootfs/dev/ttyS0 c 4 64
mkdir /tmp/rootfs/{proc,sbin,bin,usr,etc}
mkdir /tmp/rootfs/usr/{bin,sbin}
rpm2cpio rpms/mirror.sh-linux.org/rpm/RPMS/sh3/SysVinit-2.78-2.sh3.rpm \
| (cd /tmp/rootfs ; cpio -v -i -d)
rpm2cpio rpms/mirror.sh-linux.org/rpm/RPMS/sh3/glibc-2.2.4-4.sh3.rpm \
| (cd /tmp/rootfs ; cpio -v -i -d)
rpm2cpio rpms/mirror.sh-linux.org/rpm/RPMS/sh3/bash2-2.05-1.sh3.rpm \
| (cd /tmp/rootfs ; cpio -v -i -d)
rpm2cpio rpms/mirror.sh-linux.org/rpm/RPMS/sh3/libtermcap-2.0.8-6.sh3.rpm \
| (cd /tmp/rootfs ; cpio -v -i -d)
rpm2cpio rpms/mirror.sh-linux.org/rpm/RPMS/sh3/gcc-libgcc-3.0.3-3.sh3.rpm \
| (cd /tmp/rootfs ; cpio -v -i -d)
rpm2cpio rpms/mirror.sh-linux.org/rpm/RPMS/sh3/fileutils-4.0-2.sh3.rpm \
| (cd /tmp/rootfs ; cpio -v -i -d)
# get rid of the crap not used yet
rm -rf /tmp/rootfs/sbin/ldconfig
rm -rf /tmp/rootfs/sbin/sln
rm -rf /tmp/rootfs/usr/share/i18n/charmaps/BIG*
rm -rf /tmp/rootfs/usr/share/i18n/charmaps/JOHAB.gz
rm -rf /tmp/rootfs/usr/share/i18n/charmaps/UTF*
rm -rf /tmp/rootfs/usr/share/i18n/charmaps/EUC*
rm -rf /tmp/rootfs/usr/share/i18n/locales/translit*
find /tmp/rootfs/usr/share/i18n/locales/ \
! -name "en_US" -and ! -name "." -and ! -name ".." \
| xargs rm -rf
find /tmp/rootfs/usr/share/locale -type d ! -name "en" \
-and ! -name "." -and ! -name ".." | xargs rm -rf
rm -rf /tmp/rootfs/usr/lib/gconv/IBM*
rm -rf /tmp/rootfs/usr/lib/gconv/BIG*
rm -rf /tmp/rootfs/usr/lib/gconv/libCNS.so
rm -rf /tmp/rootfs/usr/lib/gconv/
# chown it all
chown -R 0:0 /tmp/rootfs/
du -ks /tmp/rootfs
-- cut here --
I'm sure this isn't the best way to do it, but it does work for me.
After this all runs, you'll end up with /tmp/rootfs looking like
something that could be mounted as a root filesystem on a new unix
installation. I have things likes a shell in the where is why things
like libtermcap are installed. Typically the initrd won't have all of
that, but I'm not a typical systems builder, I'm a newbie! :)
After expanding everything I take the time to remove stuff which I
found my system to boot without. I was looking for the bare minimum.
Also, I had to keep it under 8M, otherwise my system won't boot. I
tried 11M or 12M, but no! Anything 8M or less worked like a charm.
Finally, I chown it all to root, and do a du -ks just to make sure that
I'm under my 8M limit. At this point, I'm happy. If you wanted to put
more in there, please do, and let me know what you get to fit! As part
of a usable distro, I will need to get another space mounted, but for
the purposes of this discussion, this will work!
The next step is to make that directory into a compressed image. This
is fairly easy, maybe you've done it, I hadn't.
-- cut here --
#!/bin/sh
SIZE=`echo "8*1024" | bc`
rm -rf /tmp/image /tmp/fs
dd if=/dev/zero of=/tmp/image bs=1k count=$SIZE
mke2fs -F -vm0 /tmp/image $SIZE
mkdir /tmp/fs
umount /tmp/fs
mount -o loop /tmp/image /tmp/fs
(cd /tmp/rootfs ; tar cf - .) | (cd /tmp/fs ; tar xvf -)
umount /tmp/fs
echo Compressing...
cat /tmp/image | gzip -c > initrd.gz
-- cut here --
The main goal here is to make a disk image out of a file, mount it,
copy everything in, unmount it, then compress the image file. I'm not
sure on the specifics of the compression ratio of the image, so I just
left it as is. Feel free to play with that and let me know if it
works.
CONCLUSION
I have to say I'm really tired. I vowed not to sleep till I got a
prompt. I'm going to sleep now! Please excuse any misspellings. If
you are like me, you get a geeky idea, and you just can't sleep till
you take care of it.
QUESTIONS/COMMENTS/COMPLAINTS
If you don't like something I said, or the way I said it, please let
me know. I'm not an expert at anything here...yet! Also, if I've left
out something important, or should clarify something for sake of
confusion, I'd be more than happy to dress things up. Finally, if you
see that I've either missed the boat in a section, or just missing
in general, feel free to give me more info, or write it up yourself,
and I'll include it here. I'm more than happy to collaborate. the
more people we get to this point, the faster we can all move forward.
TO DO
* get source for shlo
* get better docs for shlo
* find/make a boot loader for < wince 2.10
REFERENCES
Gnu/Linux Project - http://www.m17n.org/linux-sh/
My Distro - http://unixce.blandsite.org/download/
Kernel Compile - http://linuxsh.sourceforge.net/docs/building-source.php3
InitRD - http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/linuxsh/kernel/Documentation/initrd.txt?rev=HEAD&content-type;=text/vnd.viewcvs-markup
SH-Linux - http://www.sh-linux.org/
$Id: HOWTO-Linux-On-WinCE-Hobbyist.txt,v 1.1 2026/02/05 04:38:38 gnb Exp $
|
Last update: 28/08/2026 |