HOWTO setup gentoo on a pda or embedded system
From Gentoo Linux Wiki
| Installation • Kernel & Hardware • Networks • Portage • Software • System • X Server • Gaming • Non-x86 • Emulators • Misc |
Please format this article according to the guidelines and Wikification suggestions, then remove this notice {{Wikify}} from the article
Contents |
[edit] PDAs
[edit] Introduction
The goal of this HOWTO is to show a (quite experimental) way to install Gentoo/Embedded on a PDA, focused on the SHARP Zaurus SL-5x00, but probably easily adaptable to any other PDA out there, for which kernel and driver support exists. We will use uclibc instead of glibc, which should keep more RAM free for your applications.
There are not only good applications missing for embedded purposes, we currently have a hard time to get a X-Server up and running.
To make it clear, this IS NOT READY FOR USERS, but perhaps intersting for advanced users or developers, that might want to help us.
[edit] Steps Outline
- setup a build environment over NFS (or other +4GB mass storage device) to build all the needed packages to set up the packages we want to run on PDA.
- build all the packages that we are going to install to the PDA
- test the installation over network
- deploy files to SD card
- boot into the SD card
This are the steps we want to go and they are basically the same for every PDA. Before you start doing this, make sure that you have the ability to boot into SD and over network. If you have no zaurus SL-5x00 we don't (yet) support your PDA. That means you will probably have to do some handwork, at least with the X-Server, but possible other stuff, too. If you want to make that work on our base here, contact us and help us to extend number of supported handhelds.
[edit] Prepare PC
| Linux Kernel Configuration: Activate in kernel nfsd |
File systems --->
Network File Systems --->
<*/M> NFS server support
[*] Provide NFSv3 server support
|
And setup userland:
emerge -av nfs-utils
add to /etc/exports (replacing 192.168.1.z by Zaurus' IP address):
| File: /etc/exports |
/exports/collie/devroot 192.168.1.z(async,rw,no_root_squash,no_all_squash) /usr/portage 192.168.1.z(async,rw,no_root_squash,no_all_squash) |
In /exports/collie/devroot we will unpack the stage-archive, it will be the root-directory of your building-environment. Place it whereever you like.
| Code: [re]start nfs service |
/etc/init.d/nfs [re]start |
[edit] Prepare Z
For now we need the Zaurus to have Altboot[1] to boot to Gentoo once it's installed on NFS/SD/CF and the easiest way to get it is to install hentges' ROM [2] with the 64-0 kernel (we'll need all the RAM we can get to compile). But this is not needed now, you will need it when you want to boot into your gentoo.
It is also highly recommended to have a ssh daemon (openssh/dropbear) and GNU Screen installed on Zaurus. Easiest way is to install openzaurus from www.openzaurus.org, the non-graphical version are enough for our purposes. If you use another PDA than the zaurus, you must find the right distribution by yourself.
[edit] NFS Mount Working Area
Now we need to mount our work area where we will compile all the needed packages that will latter be installed on NFS/SD/CF.
| Code: Mount NFS |
mkdir /mnt/gentoo mount -t nfs 192.168.1.pc:/exports/collie/devroot /mnt/gentoo -o nolock,hard,rw,rsize=8192,wsize=8192,noatime,async |
The nolock-option is very important, without it portage will fail doing its job!
[edit] Setup build environment
First we need to download the latest arm softfloat uclibc stage (available at http://yvasilev.main.hsphere.com/zentoo/ [4]) and then unpack it:
# tar -xjpf /mnt/misc/gentoo/stages/stage3-arm-uclibc-softfloat-20050915.tar.bz2 -C /mnt/gentoo
In this example we used stage3 as other stages won't give us any extra advantage over it.
Then we mount some other partitions needed by build environment we care creating:
| Code: Mount some other partitions |
mkdir /mnt/gentoo/usr/portage mount -t nfs 192.168.1.pc:/usr/portage /mnt/gentoo/usr/portage -o nolock,hard,rw,rsize=8192,wsize=8192,noatime,async mount -o bind /dev /mnt/gentoo/dev mount -t proc none /mnt/gentoo/proc |
(You probably want to put the mounting-actions into a shell script, you will have to retype them at every restart of your PDA otherwise)
Copy dns server information so we can resolve domain names form withing the build env:
cp /etc/resolv.conf /mnt/gentoo/etc/resolv.conf
And Finally chroot into our build env:
| Code: chroot |
chroot /mnt/gentoo /bin/bash --login env-update source /etc/profile |
[edit] Setup overlay & packages directories
The latest portage overlay for zentoo is available at [3]. Put into a good place in the zentoo-root.
[edit] configure portage
First we make sure /etc.make.profile points to 2.4 kernel profile, when you are using a 2.4 kernel (as they are still use on the SL-5x00).
# ls -l /etc/make.profile lrwxrwxrwx 1 root root 38 Nov 9 07:54 /etc/make.profile -> ../usr/portage/profiles/uclibc/arm/2.4
If you are lucky and you run a working 2.6 kernel, let it point simply to ../usr/portage/profiles/uclibc/arm.
Then edit /etc/make.conf. The following would be a good set of USE-flags:
| File: /etc/make.conf |
USE="X aac apm avi bash-completion divx4linux fbcon fbdev ffmpeg flac \
freetype gif gtk2 imlib2 jpeg libwww mad matroska minimal mpeg \
ncurses nocxx oss pcmcia python qt readline truetype uclibc \
win32codecs wxwindows vcd vorbis -perl -opengl -qt -fortran -berkdb"
|
We recommend using -Os and -fomit-frame-pointer as CFLAGS. Your -march settings depends on your PDA. For the SL-5000 and SL-5500 you should use -march=armv4, on XSCALES (as in the SL-5600) you can use -march=armv5te -mtune=xscale. You should set buildpkg in FEATURES, as your builds will be that damn slow, that you will be happy to have binary packages later.
You may add LDFLAGS="-Wl,-O1" to your make.conf and you should set UCLIBC_CPU, depending on your CPU. For xscales it should be UCLIBC_CPU="ARM_XSCALE".
You should set MAKEOPTS="-j1", too. Your PDA will have a hard time even with only one make running.
Add nocxx to the USE-flags, that way you work around a bug in uclibc-0.9.28 and keep the time for compiling gcc shorter. We don't support any C++ apps until now anyway.
To
| File: /etc/portage/package.keywords |
sys-libs/uclibc -* |
With all this we unmask uClibc v0.9.28 and the parts of Modular X.Org we are going to use, make sure that we use the right versions of glib/gtk+ and add some extra categories into the list of the valid ones.
Finally we can run `emerge info` to verify some of the information we have just set.
[edit] update system
Now we finally can start using our build env for what it is. This means we start to merge stuff. Before you do that, you should make as much RAM free as possible. Make sure that there is no OPIE or GPE running (you can stop both via init.d scripts)and see, what else is running on your PDA. Kill everything you don't need.
Moreover you probably need swap, many builds will segfault with only 32 MB RAM (with 64 MB they might work). You have two possibilitys with their own advantages and disadvantages:
1. Mount swap via nfs:
Create an empty file in your zenntoo-root and make loop-device out of it on the zaurus. Then create a swap-filesystem in the loopback-device and activate it with swapon
This way you can mount nearly as much RAM as you want without damaging anything.
Disadvantage is, that this swap will be awfully slow.
Moreover some builds will freeze might zaurus, when you build them with nfs-mounted swap. There are only a few packages which fail that way and this might be true only for 32 MB RAM systems. For this packages you have to switch to the second possibility.
2.Missuse a flash-card for swap:
Using a CF-card is quite simple. mkswap /dev/hda1 and swapon /dev/hda1 should be all you need in many cases. But flash cards have a limited write-cycle lifetime and as being a swap device, there will be much writing. So using a flash card as a swap-device, you will reduce it's lifetime.
But perhaps you have an old flash-card, that you don't use anymore. An old 64 MB CF-card will do it's duty and is cheap to buy.
Make sure that you have the latest portage on your host-computer.
The stage is optimized for the armv4, if you have a more modern CPU, you may want to recompile your stage for making use of the better CPU: emerge -e world
Update the rest of the build env: emerge -uDav system
[edit] Test it, boot into it
- missing*
[edit] Emerging into Final ROOT
To make installation a little bit easier (and make sure we don't forget any of the needed parampeters) we can set an alias to emerge program for when we want to emerge packages to the device.
alias zmerge="ROOT=/mnt/root emerge --usepkgonly"
Where /mnt/root can be an directory inside the nfs mount we are working in, in which case we will be able to nfs boot into it with altboot. Or it can be a bind mounted SD/CF card // FIXME: this needs pcmcia-cs package to be installed for wireless cards to work. //
// FIXME: This will be replaced by a PDA profile + zmerge -av system // And then we start emerging all the needed parts
zmerge -av baselayout util-linux gawk module-init-tools grep net-tools findutils procps coreutils kbd
At this stage it may complain that there is a package for witch there is no precompiled form, so emerge can't do it with the usepkgonly option. So we need to generate binary packages for all the packages and their dependencies we are going to use, this can be done with:
emerge -ebkav system
| Code: Install libc |
zmerge -av uclibc |
| Code: Install GUI |
zmerge -av kdrive zmerge -av gtk+ zmerge -av matchbox-common zmerge -av gpe |
[edit] try 2
zmerge -av portage zmerge -av baselayout zmerge -av uclibc install -d /mnt/root/usr/local/portage mount -o bind /usr/local/portage/packages /mnt/root/usr/local/portage chroot /mnt/root /bin/bash --login
[edit] Configure the Installation
Set the time zone (available values are in [5]): echo
Edit fstab
Copy /dev cd ${ROOT}/dev/ ; ./MAKEDEV generic
[1] http://hentges.net/misc/openzaurus/docs/altboot.shtml
[2] http://hentges.net/misc/openzaurus/index.shtml
[3] http://yvasilev.main.hsphere.com/zentoo/test/zoverlay-test.tar.bz2
[4] http://yvasilev.main.hsphere.com/zentoo/stages/
[edit] Contact us
This work is done by Yuri Vasilevski aka yvasilev and Björn Ruberg aka Jinidog. You can find us in #gentoo-embedded on freenode. Feel free to consult us, if you want to help out (we need helpers!) or have questions.
[edit] Routers and Modems
- More code
->new page for other embeded system
