|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 firstname.lastname@example.org.|
|Things you will need before starting|
Create a working directory. I chose ~/be300. I will use this name throughout the document. Type the following in your home directory.
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.
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
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)
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
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)
Next edit the Makefile and change the following. (here is mine, Makefile)
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.
|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|