Joined: 30 Jan 2005
|Posted: Tue Jul 19, 2005 8:49 pm Post subject: Gentoo on Zaurus, partial howto
I think it was in early June 2005 when there was a note in the Gentoo Weekly Newsletter about somebody willing to reactivate the Gentoo on Zaurus project. I did some work on that and tried to contact the editors of the newsletter but never got somebody to talk to. So my question is: Has anyone Gentoo running on the Sharp Zaurus? That's what I did so far (I do have a SL-5500G):
I got all my information from:
Unfortunately most of them are quite outdated. Here's what you need:
- Recent kernel with USB and USB-Net, possibly netfilter/iptables as well
1) Turn the device on and connect it via USB to your PC. dmesg should tell you
that it connected sucessfully to your system:
usb 4-1: new full speed USB device using uhci_hcd and address 2
usb0: register usbnet at usb-0000:00:1d.2-1, Sharp Zaurus SL-5x00
usbcore: registered new driver usbnet
2) Configure the Zaurus' network (default IP: 192.168.129.201), no gateway/dns
3) Active USB-based TCP/IP networking on your Gentoo box
ifconfig usb0 192.168.129.1 netmask 255.255.255.255 up
route add -host 192.168.129.201 usb0
# ifconfig usb0
usb0 Link encap:Ethernet HWaddr 1A:1A:2D:6A:01:F8
inet addr:192.168.129.1 Bcast:192.168.129.255 Mask:255.255.255.255
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
4) Ping the Zaurus:
ping -c 3 192.168.129.201
PING 192.168.129.201 (192.168.129.201) 56(84) bytes of data.
64 bytes from 192.168.129.201: icmp_seq=1 ttl=255 time=1.65 ms
64 bytes from 192.168.129.201: icmp_seq=2 ttl=255 time=1.53 ms
64 bytes from 192.168.129.201: icmp_seq=3 ttl=255 time=1.50 ms
--- 192.168.129.201 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 1.504/1.561/1.650/0.071 ms
5) Now you need to download an ARM-based and precompiled
version of Gentoo:
# mkdir gentooforzaurus
# cd gentooforzaurus
# mkdir armv4l
# wget http://ftp.uni-erlangen.de/pub/mirrors/gentoo/experimental/arm/stages/armv4l/stage3-armv4l-20040510.tar.bz2 (80 MB)
# tar -C armv4l -xvjf stage3-armv4l-20040510.tar.bz2
6) Now enable and set up NFS:
# vi /etc/exports
# /etc/init.d/nfs restart
# distccd --daemon (or "distccd --daemon --no-detach --log-stderr") // optional
7) SSH to the Zaurus
# ssh -l root 192.168.129.201 (use "" or "zaurus" as password for root)
8) Mount the precompiled Gentoo distribution locally
# mount -t nfs -o hard,intr,nolock 192.168.129.1:/home/werner/gentooforzaurus /mnt/net
9) Enter the chroot environment
# cd /mnt/net
# /mnt/net/gentoo-dist/bin/mount -t proc proc /mnt/net/armv4l/proc
# /mnt/net/gentoo-dist/bin/mount -o bind /dev /mnt/net/armv4l/dev
# chroot armv4l /bin/bash
# route -n add default gw 192.168.129.1
10) My question now is: What to do next? How to I really install Gentoo on this thing? What must I do to make it boot Gentoo the next time?
Thanks a lot and bye,
Joined: 26 Nov 2003
|Posted: Wed Jul 20, 2005 1:59 pm Post subject:
|Gentoo on the Zaurus
This Howto is about compiling a Gentoo with uclibc for the Zaurus PDA.
This is done by using NFS and a hell lot of time.
It's not complete, untested and may be full of mistakes. It's a little outdated.
I stopped trying to bring gentoo on the zaurus after six weeks.
Now I'm using openzaurus.
Don't try to put gentoo on the zaurus as long as you don't have a good knowledge of linux and gentoo. This is a hard task, even for developers.
You may post comments here and try to get help from me in #gentoo-embedded on freenode.
This is a howto for using uclibc, but I learned that this is no good idea as the pda-suited apps make use of nls what is not supported by uclibc.
Do yourself a favour and start with glibc and ignore all uclibc stuff in this howto.
If you are a C-programmer, you may do it and move the nls stuff out of the apps.
Better you just use this howto for some hints and don't follow the steps exactly.
The Zaurus is a PDA from sharp that is nativly equipt with a Linux from Sharp.
There are various models that do differ much. All of them have an ARM-CPU and there are Opensource-Projects that provide Linux-ROMs for them.
For more information visit:
I own a Sharp SL5600 PDA.
Intel Xscale 400 Mhz
32 MB of RAM
64 MB of internal Flash-ROM
320x240 pixel display
USB networking via the dockingport
This Howto may work for other Zaurus' or other embedded devices, too. You don't know.
However, there are SL5600 specific parts (for example the CFLAGS and the CHOST) that cannot be right for the SL5500 or other models.
I'll add informations about other models if someone can contribute them.
What I have reached
Before you start putting Gentoo on the Zaurus, you should know how far I got it.
I was able to put the gentoo on an 1 GB SD-card and I was able to boot it.
It works and I can login. I can mount a portage-tree and /var/tmp/portage over NFS and I am able to use portage as on a normal PC.
Running a fullyfunctional gentoo (without the portage-tree) with GUI and many applications will fit on a 512 MB SD-card.
A small system might fit on a 256 MB card and if you leave out compiler-stuff you may bring it on a 128 MB card.
The internal flash is not touched and I can still boot a normal openzaurus.
Why should I put Gentoo on the Zaurus
There are ROMs you can flash on your Zaurus and you might be happy with them. The Openzaurus-project is doing a quite good job, so you don't need to use Gentoo if you only want a working PDA.
With the openembedded-project you even have an building environment for your Zaurus.
However, I'm only used to Gentoo and I don't like all the other ROMs (probably because I'm not used to any other Linux than Gentoo). I love to compile stuff with portage. Openembedded is inspired by portage, but it's not that advanced and you have to learn much before you can use it.
In a device with only a minimum of ressources you really want to use the features from Gentoo and try to get the maximum out of the appications by treating gcc to produce faster and smaller code, that is optimised for the CPU.
The openzaurus-ROMs are using the glibc, for an embedded device like the Zaurus the uclibc might be a better choice.
This howto makes use of the uclibc-profiles of Gentoo.
Zaurus specific distributions only have a very low amount of developers, Gentoo is a greatly maintained distribution.
Perhaps the question whether to put Gentoo on the Zaurus instead of the distributions made for the Zaurus is the same, whether to put Gentoo on you PC or Debian, Suse or RedHat.
If you want to play around and you have the time, you might enjoy having the same Linux on your handheld as on your Desktop-PC.
What you need:
a network connection between the Zaurus and your PC. There might be various ways (IR, serial, WLAN) but you really want the fastest connection available. That would be USB and you should habe a USB 2.0 port on the PC side.
You need a 256 MB (better bigger) SD-card that should be as fast as possible.
Booting a gentoo from a CF card is not described in this howto and I don't know whether it is possible.
(but when I look how a SD-card is booted, I think it is doable)
A hell lot of time
an understanding and patient girlfriend (if you don't have one, this is one of the very few points you can feel lucky)
You may think, why do I need crosscompiling? My PDA may be slow, but I can wait until it finishs.
The problem is, that an uclibc based system must be build in an uclibc environment.
That is possible with the embedded/uclibc stages, that are provided on the Gentoo Mirrors BUT they only work together with Kernel 2.6.
So, as you probably have an 2.4 kernel running on your Zaurus, you cannot use them.
The only possibility is to build all the necessary stuff in an uclibc environment on your PC.
Necessary it is to compile uclibc for your Zaurus. Sadly you cannot build a fullyfunctional toolchain, as several important ebuilds fails when they are crosscompiled.
Don't be afraid, you won't have to reinstall your system with uclibc, it's enough to take an uclibc stage3, unpack it and chroot in it.
You have to emerge crossdev for creating the arm toolchain.
You may upgrade your gcc to 3.4.3, instead of using the default 3.3.5 one.
But all this is your choice of doing a minimal gentoo installation and so it is up to you how you do that. (you should be very used to gentoo if you want to perform an installation on the PDA)
So, for creating a crosscompiler you have to merge crossdev.
After that, enter the following:
|crossdev --target armv5tel-pc-linux-uclibc --gcc 3.4.3-r1 --kernel 2.4.26-r1 --binutils 188.8.131.52.2-r8 |
For me the build fails when you use another compiler or other kernel-headers.
Create an dir /zaurus and then you can build uclibc with kernel-2.4.
|ROOT="/zaurus" CFLAGS="-Os -pipe -march=armv5te -mtune=xscale -fomit-frame-pointer" CXXFLAGS="-Os -pipe -march=armv5te -mtune=xscale -fomit-frame-pointer -ffast-math -fvisibility-inlines-hidden" CHOST="armv5tel-pc-linux-uclibc" ARCH="arm" UCLIBC_CPU="ARM_XSCALE" emerge sys-libs/uclibc |
This installs a fitting uclibc into /zaurus, with which you have to work soon.
But first, or during waiting for the compiles to finish, we start to configure the zaurus.
I don't want to explain all the steps that are needed for getting started in detail.
To be specific, I don't want to put them here at the moment. Perhaps I'll write more about that if it's requested or other people are witing the stuff that could be placed here.
You should follow this instructions exactly. Of course there are other ways doing it and you are free to do so. But the results may differ and in the end you are on your own.
1.Install openzaurus 3.5.3 on your handheld and start it. Set your root-password and conigure your network. You need to be able to get a SSH connection to the Zaurus and the Zaurus needs to be able to mount a NFS-directory provided by your Linux-PC.
Generally you can choose any ROM that you want, it just needs to support SSH and NFS (and it should be able to do USB networking).
2.Go to www.gentoo.org and choose one of the download mirrors. Download the following file <mirror>/experimental/arm/embedded/stages/stage1-arm-uclibc-2004.3.tar.bz2.
If a newer release exists, you can use that.
3.Copy the stage-archiv into /zaurus. Cd into /zaurus and unpack the archive by typing tar -xjpf stage* . (name the archive as you like, this archive must not be the same in which you copied the crosscompiled uclibc).
4.Put /zaurus into your /etc/exports and start the nfs-server.
The line in /etc/exports should look like this:
all_squash etc. is need for being accepted as root by your PC. Async should improve performance.
5.Now it's time to ssh on the zaurus. Create the directory /mnt/gentoo and mount the NFS-directory into it:
|mount -o nolock 192.168.?.?:/zaurus /mnt/gentoo |
You need the option nolock, or you will experience uncomfortable problems with portage.
6.If everything worked, you now can chroot into /mnt/gentoo:
7.We refer a little bit on the handbook. In an other SSH-console do the following:
|mount -t proc none /mnt/gentoo/proc |
|mount -o bind /dev /mnt/gentoo/dev |
Shutting down unneeded services:
Depending on the openzaurus-ROM you have put on your zaurus you really want to shutdown all running graphical environments.
With the gpe images you can do
|/etc/init.d/gpe-dm stop |
You can use top to find other services that consume memory and shut them down.
You may want to have some swap, because the handheld's memory is very limited. That's not very easy to achive, because you have no harddrive in your handheld. You can use a flashcard as swapspace, but because of the limited write-cycles on flashchips that will shorten down the lifetime of the flashcard.
I used a not anymore used 64 MB SD-card as swap and it died after some days. If your emerges are locking without any obvious reason, it may be because of that.
It's your choice, mkswap is available in the chrooting environment.
If you don't want to kill your hardware, the only alternative is to create a swapfile into the NFS directory.
Create a 100 MB big swapfile in the NFS directory. Do the following on your PC:
|dd if=/dev/null of=/zaurus/swap.swp bs=1024k count=100 |
Make a swapfile out of the emtpy file:
|mkswap /zaurus/swap.swp |
Now on your handeld do:
|losetup /dev/loop0 /mnt/gentoo/swap.swp |
You can see the using of the swap via the command free.
Using swap, even if it is a swapfile mounted over NFS, is recommend and a speedup on lowmem systems.
You really should consider using swap. I had some hangups when I hadn't activated it.
The developers say, that you should have at least as much swap as the source-tarballs are big.
Thinking of distcc:
distcc would be a great thing to shorten down compile times.
We already have a working cross-compiler in your chrooting environment of your PC.
Problematic might be the fact, that this is gcc-3.4 and in the stage1 environment there is a gcc-3.3.
However, I never got distcc to use the crosscompiler. If you find a way, let me know how.
(it should be doable)
After chrooting into your installation-directory you may start with doing the sync.
That will take really some time, so you should start with it at the beginning and configure the rest of your installtion later.
But before syncing, put an working DNS server into your /etc/resolv.conf.
184.108.40.206 is the one, I can always recognize.
You shouldn't do an emerge sync, for me the connections always broke after some time because of an rsync bug. You may try it and if you do, you should adjust your rsync_exludes file.
For syncing I prefer emerge-webrsync because it doesn't fail all the time.
It'll take a long time, but at least it works.
When you have started the sync, you should open an other SSH-console to your Zaurus and chroot again into /mnt/gentoo.
It's time for configuring.
At first we should configure the make.conf.
This part is really SL5600 specific and may be true for the SL6000, too. It's not right for the SL5500, because it has an StrongARM-CPU and no Xscale like the SL5600 and SL6000.
The xscale is an armv5te.
So we can use this:
Some thoughts about CFLAGS:
I'm completly new to the arm-world, so I'm new to its Cflags.
However, this are the Cflags I used and that worked for me:
|CFLAGS="-Os -march=armv5te -mtune=xscale -fomit-frame-pointer" |
march=xscale is not available, is think these march and mtune settings are the most optimized ones available for the xscale. I use -Os because with 32 MB of RAM you really want the binarys as small as possible (normally I am a -O3 guy).
So we leave out any flags that may increase codesize.
If you have not much RAM you should not put -pipe into your CFLAGS.
I learned that you really should use -msoft-float, as you need software floatingpoint-emulation. I did not use this option and the result was a very slow system.
I know you need it, I just don't know you whether it works.
You should add a line like the following for optimizing your uclibc for the xscale:
I believe you don't want to have parallel compiling turned on.
You have only 32 MB of RAM and even with working distcc you may want just one make running.
So add this:
Setting to the profile
We want to use the uclibc-profile for 2.4 kernels.
So do the following:
ln -s ../usr/portage/profiles/uclibc/arm/2.4/ make.profile
You are lucky, gcc-3.4.4 ist stable for arm now.
Making Portage working
There is one big problem with the uclibc-stage1 environment. It's uclibc is compiled against kernel 2.6 headers and it doesn't work good together with kernel 2.4 (which normally runs on the zaurus).
You will notice then when you try to run something like emerge -p portage after syncing.
Using a normal stage1 for the arm with glibc is no really solution, if you want to have the ulibc on your zaurus. Building a uclibc system in a running glibc environment is damned to fail in many cases.
The solution is to use a uclibc compiled for kernel 2.4 and copy it over the uclibc which is installed in the stage1.
We built this uclibc previously, you can copy it over in the stage1 by doing the following (you might have to adjust to your directorys)
|cp -R /uclibc/zaurus/* /zaurus/ |
After doing this, your chrooting environment will not work properly anymore. Even a simple 'ls' will fail. You have to do the following for reparing this:
|ldconfig /usr/lib/gcc-lib/arm-pc-linux-uclibc/3.3.4/ |
We end with cleaning up:
Now we can...
Now we come to a point, where we are near to something like a normal install.
But before you bootstrap, you need to update your gnuconfig (the provided one has no support for our CHOST).
|emerge -Ou gnuconfig |
After this we can finally bootstrap. We want to use the option resume to build binary packages. So it does not need to compile packages again after a failed build.
This will take a long time, but you should supervise this.
It can happen that compiles just stops, that there are mysterious bus errors or that it just returns to the shell when unpacking linux-headers or gcc.
When this is finished you can run emerge -e system.
This will take a while, too.
There are some packages that failed to me, I'll attach a list at the end where you can find a list of possible failing packages and how to work around that.
Merging the system is long process in which everyone will have his own problems that cannot be predicted easily.
This part of the howto will be extended when it appears necessary.
Copying on the zaurus
Okay, you finished emerge system and here we are now.
You have a working gentoo system for your zaurus in a directory of you PC.
Congratulations, it took me two weeks to get here.
But having the gentoo mounted over NFS has not much practical use.
We want to have it on the zaurus.
You may want to compile some applications for the later use now, like a minimal X-Server and so on.
If you follow my instructions you can do that later, too, but it will be difficult if you strip down you gentoo and remove the compiler stuff.
Make sure that /sbin/init exists and if it does not, you need to merge baselayout again.
You will need e2fsprogs merged.
When you are ready for transfering the gentoo on your zaurus, you need a SD-card.
With a 512 MB big one you are on the save side, you have to keep an eye on the free space when you use a 256 MB big one.
Before copying the gentoo on the SD-card, you should move /usr/portage out.
The portage-tree is too big for a SD-card and you won't need it on it. You can mount it later over NFS.
Now you can look how big you're gentoo is and whether it fits on your SD-card.
Put the SD-card into your zaurus and create an ext2 filesystem on it.
Your zaurus will probably won't have an mkext2, but your gentoo have if you have merged e2fsprogs.
Make sure that you did this outside the chroot on your zaurus:
mount -o bind /dev /mnt/gentoo/dev
If you have done this, make sure that /dev/mmcda1 is not mounted.
Then you can simply do the following in your chroot:
Just unused Microsoft-Software is good Microsoft-Software
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum