Introduction


IMPORTANT NOTE : users of current version of OpenZaurus don't need this. Oz now comes with a boot loader which has already a rescue mode.

Also, this document is outdated. Oz has changed from its buildroot model to the openembedded framework, so the building part won't work.

I wrote this page hoping this could be useful to others, after messing up totally my zaurus during bash installation. Opie did not show up after next reboot, and I could not log in anymore : /bin/sh : not such file or directory was all I could get.

Here is the solution I've found.
I use OpenZaurus 3.3.5, but this should work with any version of OZ.

WARNING : I do not guarantee that this will not wipe off you zaurus entirely ! If something goes wrong during flashing, you could end up loosing everything, including the boot loader ! That would mean your Z will become a very expensive and not useful at all plastic brick ! I don't think this will happen, as it worked fine for me, after several build/flash/rebuild/reflash etc... BUT YOU'VE BEEN WARNED !


Copyright


This paper is © 2004-2006 Clément Hermann.
Feel free to reproduce and/or modify this doc, but please retain the above copyright, as well as this notice. Also, if you modify it, you should specify were you made changes, and I would be glad to know it.

last modified : Thu Jan  5 23:06:47 CET 2006

The day I lost everything...

Here is my little story :

Problem description : bash installation messed up /bin/sh link.  No way to log in. No boot scripts. Hence, no network. All data is there, inside, in this nice little box that you used to love but you begin to hate... There is no way to get it back. Oh my, why did I need to reboot ? I need that data back !

No way ? well... All you need is a shell, in fact. A single kernel parameters would do the trick : init="/bin/busybox sh".  Then you would be dropped into a shell, and could repair.

But how would you pass this parameter to the kernel ? Well, you can't. In Oz, all parameters are hard coded. However, you can build you own kernel, boot on it (using the normal flashing procedure, except that you only flash the kernel), and there you are.

This is possible, because (as opposed to the sharp rom), Oz does not arbitrarily wipe the partition used for the kernel. unless it fails to mount it. But you know your data is there and not corrupt (it boots to the "login:" prompt). So let's go for a little cross-compilation time.


Getting Oz kernel source

Of course, you need the kernel source used by Oz. You can get the buildroot using bitkeeper (as described here), or, if you don't have it,
get a snapshot image of the buildroot tree.

You'll also need a cross-compilation environment. You should use the one provided by OZ, which will be recognised by the buildroot if you just extract it to /usr/local/arm.


Building

Now, you want to build that thing.

First, you need a .config. As I use a SL-5500, I copied  def-configs/collie-2.4.18-opie to .config. You should choose the configuration according to you needs.

then run
make menuconfig.
you can unselect everything that is not kernel or host-related, as we only want a kernel image and no initrd.bin (that is, everything under "Host build tools", "Base file systems", "Libraries", and "Programs"). That will lighten the build process.

Make sure you selected correct parameters for the "Build parameters" part of make menuconfig.

Select the right kernel (kernel selection), Model (Model(s) to build kernels for) and image (Ramdisk size(s) to build kernel for). You should select one which match the memory layout of your current kernel. Openzaurus documentation recommends 40mb memory and 24mb storage for new users, and I selected just that.

Be sure to keep "common kernel 2.4 headers" selected, everything depends on it. Everything else can be unselected. You can then exit, answering yes to the "save your configuration" question.

Now, we want to change kernel parameters. That's the CONFIG_CMDLINE variable. For me it's in packages/kernel-collie-2.4.18/Makefile
just add the init parameter to the variable, and change console=null to console=tty :

CONFIG_CMDLINE="root=/dev/mtdblock4 rootfstype=jffs2 jffs2_orphaned_inodes=delete console=null mem=16M"
becomes
CONFIG_CMDLINE="init=/bin/busybox sh root=/dev/mtdblock4 rootfstype=jffs2 jffs2_orphaned_inodes=delete console=tty mem=16M"

We need to specify a console, as, by default, Openzaurus doesn't show it (
console=null) (that's how kernel boot message are hided). If you can't use the console, having a shell won't be very useful.

note : I was told on #openzaurus@freenode that the right way to do this is to put that ligne in .config.

then you can simply run 'make'.

As community.zaurus.com is down for ages, downloading the image for 2.4.18 will fail.  Instead, you should download the image somewhere else (like here) and put the tarball under the source directory. Do not untar it. The build process will take care of that.

I was told by Victoriano Giralt (vic AT gssi.es) that dropping the tarball in the appropriate directory didn't work for him.
But he worked around the problem by setting up a local web server to serve the files, and modifying the url in the packages Makefiles.

Wait. Get you favorite cafeinated beverage, go take a breath of fresh air, whatever. It can be long. Especially hte first time, as you need to download a lot of source code. After a (hopefully) successful build, you'll have your kernel image under the output/ directory.

Now go for the flashing process...


Flashing, Repair, Flashing again

Copy the image on your cf, and make sure it is named 'zImage'. Beware, you should not have any initrd.bin on your cf ! You don't want the root filesystem to be created (or, in this particular case, erased).
Follow the instruction from the install  guide on openzaurus.org to flash your zaurus (except for the initrd thing. You only need to do the "4. Flash" part).

When booting, you should see the standard kernel boot sequence, and get a shell at the end of the process.

Repair
You need to mount root rw, it is read-only right now. Do it that way :
mount /dev/mtdblock4 -t jffs2 -o remount, rw /

Now you can repair. My problem was that /bin/sh pointed on /bin/bash and /bin/bash did not exist. All I had to do was to fail back on busybox. I could do more elaborate investigation later, when my zaurus was fonctional :

rm /bin/sh
ln -s /bin/busybox /bin/sh

Now reboot and flash again with your standard kernel image. If you don't have it anymore you should be able to get it from OpenZaurus.


Conclusion

That's it ! Now you Z should be back on his feet.
Of course, My problem was very specific but this should be easy to adapt on yours.
You can find the image I built and used here. This is a 2.4.18 openzaurus image with 40mb memory and 24mb storage. Feel free to use it if you use the same memory layout and if you use a SL-5500 Zaurus. If this is not the case, you'll have to build one yourself. If you do so, and if you got a working kernel image, please tell me, and send it to me, I'll include a link so other people can use it.

Victoriano Giralt sent me his 64-0 SL-5500 kernel image. Get it here. Many thanks to him for this and his comments.

Feel also free to contact me about typos, gotchas, flames, etc.


Thanks

Many thanks to the people in #openzaurus who made this possible and helped me a lot, especially kergoth and df001z. I'd also like to thank the people from #zaurusfr@freenode who were able to bear my whining, frustration or rage cries... Without even kicking me. In fact, they were pretty supportive and showed interest in my solution. This doc is for them ;)