Introduction
In this howto I will walk you through the process of creating a ramdisk with busybox and uclibc for the Casio Cassiopeia BE-300 pda. We are using uClibc because it is much smaller than Glibc and targeted at embedded devices like the BE-300. Busybox is being used because it provides us with all the most common Unix utilities and a shell and takes up a minimal amount of space. This is intended to be a simple tutorial and is targeted at anybody who wants to experiment with linux on the BE-300. Please visit http://www.linux4.be for more information on linux for the BE. Suggestions and questions can be directed to me at jroark@linux4.be.
Things you will need before starting
  • A host machine with a mips little endian cross compiler (try jal0's tutorial or timesys)
  • The Mips Linux kernel source with the appropiate BE-300 patches (2.4.18)
  • The uClibc source (0.9.15)
  • The BusyBox source (0.60.4)
  • A Casio Cassiopeia BE-300 (although nothing here is that specific that this couldn't be built for any other embedded machine)
  • The hacked CyaCE bootloader from Filip here.
First preparation

Create a working directory. I chose ~/be300. I will use this name throughout the document. Type the following in your home directory.

mkdir be300 

Now create several sub directories by typing the following in your home directory.

cd be300; mkdir src rootfs ramdisk mipsel-uclibc-dev

Note: mipsel-uclibc-dev is the directory that contains everything you need to compile programs with uClibc. It contains the include files for the uClibc library and special versions of gcc and similar programs. It is a kind of cross-compiler wrapper.
rootfs is the directory where everything goes that will be on the final ramdisk

Obtain the following source packages, uClibc-0.9.15.tar.bz2 & busybox-0.60.4.tar.gz and save them in your ~/be300/src directory.

Unpack the packages by typing the following.

cd src; tar xjvf uClibc-0.9.15.tar.bz2; tar xzvf busybox-0.60.4.tar.gz

After you have downloaded all the sources and extracted them, your ~/be300/src directory may look like this:

8.0k drwxr-xr-x      9 johnbot  johnbot      8.0k Oct 22 21:57 busybox-0.60.4/
776k -rw-------      1 johnbot  johnbot      769k Oct 22 20:36 busybox-0.60.4.tar.gz
4.0k drwxr-xr-x     16 johnbot  johnbot      4.0k Nov  3 16:10 uClibc-0.9.15/
1.2M -rw-rw-r--      1 johnbot  johnbot      1.1M Oct 22 20:36 uClibc-0.9.15.tar.bz2
Building uClibc

First change into uClibc source directory (~/be300/src/uClibc-0.9.15) and run the following command.

ln -s extra/Configs/Config.mipsel Config

Next edit the Config file as follows: (here is mine, Config)

  • Change the line KERNEL_SOURCE to where ever you have the be300 kernel source unpacked
  • KERNEL_SOURCE=/home/johnbot/be300/kernel/linux
  • Check the configuration options. Most of them should be fine. However, you might want to change LFS to true as some programs complain without it.
  • Find the line Below # BIG FAT WARNING: and change the line to
  • SHARED_LIB_LOADER_PATH=/lib
  • Change the line with DEVEL_PREFIX to your mipsel-uclibc-dev directory
  • DEVEL_PREFIX=/home/johnbot/be300/mipsel-uclibc-dev

Run the following commands to make and install the library. Note that we do not install the library as root as we do not install it in a system-wide directory.

make
make install
make PREFIX=/home/johnbot/be300/rootfs install_target

The first command compiles the libraries, the second command installs the development code into the mipsel-uclibc-dev directory and the last command installs the shared libraries into the rootfs directory. These will end up on the root file system of the ramdisk.

Note: As of uClibc 0.9.16 the configuration has changed significantly. It is now very similar to the kernel's make menuconfig ncurses based configuration. To use uClibc 0.9.16 or higher do the following instead of the previous steps.

First in the file Rules.mak update the line CROSS=mipsel-linux- . Then run make menuconfig and change the kernel source directory and the uClibc devel directory to ~/be300/$(TARGET_ARCH)-linux-uclibc. Finally build and install.

make
make install
make PREFIX=~/be300/rootfs install_target
Building BusyBox

First change into the Busybox directory (~/be300/src/busybox-0.60.4) and edit the file Config.h as follows. (here is mine, Config.h)

  • Add or remove support for whatever commands you want or don't want. (make sure you have at least a basic shell 'BB_ASH' and init 'BB_INIT')
  • If you plan on following the PicoGUI tutorial make sure to uncomment 'BB_IFCONFIG' and build TCP/IP Networking into your kernel.

Next edit the Makefile and change the following. (here is mine, Makefile)

  • Make sure the line CROSS= is uncommented and set to the name of your mipsel uclibc cross compiler prefix.
  • CROSS=mipsel-uclibc-
  • Add mipsel-uclibc-dev/bin to your PATH environment variable.
  • export PATH=$PATH:/home/johnbot/be300/mipsel-uclibc-dev/bin
  • You could enable LFS support, as you already have selected it in the uClibc library as well.

Now build Busybox and instal it in your rootfs directory with the following commands.

make
make PREFIX=/home/johnbot/be300/rootfs install

The first command builds busybox and the second installs the cross compiled version into the root of the ramdisk filesytem.

Note: The process of building newer versions of busybox should be similar. BusyBox 0.60.5 is out as of 10/26/2002.
The latest development versions of busybox in CVS use the make menuconfig; make dep; make clean; make; make PREFIX=~/be300/distro/rootfs install approach.

Creating the ramdisk

Now that we have all of the necessary dynamic libraries and applications we need for a simple test Linux system we need to create the actual ramdisk that will be linked with the kernel.

First we need to create a ram image by typing the following in the root of your development directory (i.e. ~/be300)

dd if=/dev/zero of=initrd bs=1k count=4096

Next we need to format the new ram image and mount it by typing the following (you may need to be root in order to mount the ramdisk).

mke2fs -F -m 0 -i 1024 initrd
mount -t ext2 -o loop initrd ramdisk
cd ramdisk

Now that we have created and mounted the ramdisk we need to copy all the files in rootfs on to the ramdisk and create the dev and etc dirs and files by typing the following from within the ramdisk directory. Here is a shell script I wrote for creating the device file entries.

cp -Rdp ../rootfs/* .
mkdir dev etc tmp var proc mnt home root
cd dev
mknod console c 5 1
mknod ttyS0 c 4 64
mknod tty c 5 0
mknod ram0 b 1 0
mknod ram1 b 1 1
mknod mem c 1 1
mknod kmem c 1 2
mknod null c 1 3
mknod zero c 1 5
mknod fb0 c 29 0
ln -s fb0 fb
ln -s ram1 ram
ln -s ram0 ramdisk
ln -s ../proc/kcore kcore
ln -s ../proc/self/fd/0 stdin
ln -s ../proc/self/fd/1 stdout
ln -s ../proc/self/fd/2 stderr
cd ..

You may also wish to add the file etc/init.d/rcS as busybox's init will look for it at startup. rcS is a shell script that is called when init starts up. Below is a simple example that mounts the proc filesystem, brings up the loopback device, and then prints out "Welcome to Linux4BE":

mkdir etc/init.d
cat > etc/init.d/rcS << "EOF"
> #!/bin/sh
>
> /bin/mount -t proc none /proc
> /sbin/ifconfig lo 127.0.0.1 up
> echo "Welcome to Linux4BE"
> EOF
chmod 755 etc/init.d/rcS

Now cd to the root development directory, make everything owned by root, unmount the ramdisk, and gzip it.

cd ..
chown -R 0:0 ramdisk
umount ramdisk
gzip -9 initrd
Kernel compilation and setup

Now we have an initial ramdisk that can be directly linked with our kernel. I am not going to go into great detail here on how to build a kernel for the BE (there is plenty of information on this elsewhere). First cd into the root of your kernel sources and copy the gzipped ramdisk, initrd.gz, to arch/mips/ramdisk/ramdisk.gz.

cp ../initrd.gz arch/mips/ramdisk/ramdisk.gz

Now build the kernel as you would normally and make sure you include the options ramdisk, initial ramdisk, and embed root filesystem ramdisk into the kernel. If you plan on following the PicoGUI tutorial you will also need to add TCP/IP Networking support. You should also make sure that the default ramdisk size is equal to the size of your ramdisk in 1k blocks (4096).

Once you have built the kernel copy the kernel to your BE or compact flash card with the bootloader and bootloader config (cyacecfg.txt) , and make sure your bootloader config has the proper append line (append=console=tty0 console=ttyS0,9600 root=/dev/ram). At this point you may want to hook your BE up to your serial port (if you have the serial cable) and start up minicom or some other terminal program. Start up the bootloader and be amazed!

Post install notes
If you have your serial cable hooked up you should see output along the lines of this. This tutorial is only intended to get you up and running with a very basic Linux system on the BE. Now that you have a simple ramdisk and everything you need to build apps linked against uclibc it should be relatively simple to add new apps to your ramdisk. Here is a follow up tutorial that shows how to build PicoGUI for your ramdisk.
Last modified on 12/01/2002 20:53:14