next up previous contents index
Next: Bundle the Linux kernel Up: Setting up an initial Previous: Building the Linux kernel   Contents   Index


Building a shell (and a little bit more...)

This section completes your work and glues everything together.

At first, we need a basic directory structure, containing the binaries. We orientate us to [FHS01], but at this point, we only use some of the proposed directories. This basic directory structure including the binaries will be called initrd or initial ramdisk because it'll be loaded by the Linux kernel itself directly during the boot process. So, we archive this directory in a later stage into one single file, which we glue with the Linux kernel:

$ mkdir INITRD
$ export INITRD=`pwd`/INITRD
$ cd INITRD
$ mkdir -p proc dev/pts etc
$ cd ..

The /proc - directory help us for gathering basic and extend system information. The /dev contains all necessary device nodes. Now, we're building the first application for the SEGA Dreamcast:

$ cd BUILD
$ tar -xvzf ../SRC/busybox-0.60.5.tar.gz -C .
$ cd busybox-0.60.5

For compiling busybox-0.60.5, you have to configure your needs in the file Config.h. Here's my proposal:

    #define BB_BASENAME
    #define BB_CAT
    #define BB_CHGRP
    #define BB_CHMOD
    #define BB_CHOWN
    #define BB_CLEAR
    #define BB_CP
    #define BB_DATE
    #define BB_DF
    #define BB_DIRNAME
    #define BB_DMESG
    #define BB_DU
    #define BB_ECHO
    #define BB_FREE
    #define BB_GREP
    #define BB_HALT
    #define BB_HEAD
    #define BB_HOSTID
    #define BB_HOSTNAME
    #define BB_IFCONFIG
    #define BB_INIT
    #define BB_INSMOD
    #define BB_KILL
    #define BB_KILLALL
    #define BB_KLOGD
    #define BB_LOADKMAP
    #define BB_LN
    #define BB_LOGGER
    #define BB_LS
    #define BB_LSMOD
    #define BB_MKDIR
    #define BB_MKFS_MINIX
    #define BB_MODPROBE
    #define BB_MORE
    #define BB_MOUNT
    #define BB_MSH
    #define BB_MV
    #define BB_PIDOF
    #define BB_PING
    #define BB_PS
    #define BB_PWD
    #define BB_REBOOT
    #define BB_RESET
    #define BB_RM
    #define BB_RMDIR
    #define BB_RMMOD
    #define BB_ROUTE
    #define BB_SED
    #define BB_SLEEP
    #define BB_SYNC
    #define BB_SYSLOGD
    #define BB_TAIL
    #define BB_TAR
    #define BB_TEST
    #define BB_TIME
    #define BB_TOUCH
    #define BB_TRACEROUTE
    #define BB_TRUE_FALSE
    #define BB_TTY
    #define BB_UMOUNT
    #define BB_UNAME
    #define BB_UPTIME
    #define BB_VI
    #define BB_WGET
    #define BB_WHICH
    #define BB_WHOAMI
    #define BB_YES

    #define BB_FEATURE_SH_IS_MSH
    #define BB_FEATURE_VERBOSE_USAGE
    #define BB_FEATURE_AUTOWIDTH
    #define BB_FEATURE_LS_USERNAME
    #define BB_FEATURE_LS_TIMESTAMPS
    #define BB_FEATURE_LS_FILETYPES
    #define BB_FEATURE_LS_SORTFILES
    #define BB_FEATURE_LS_RECURSIVE
    #define BB_FEATURE_LS_FOLLOWLINKS
    #define BB_FEATURE_LS_COLOR
    #define BB_FEATURE_FANCY_PING
    #define BB_FEATURE_USE_INITTAB
    #define BB_FEATURE_LINUXRC
    #define BB_FEATURE_REMOTE_LOG
    #define BB_FEATURE_FANCY_TAIL
    #define BB_FEATURE_MOUNT_FORCE
    #define BB_FEATURE_TAR_CREATE
    #define BB_FEATURE_TAR_EXCLUDE
    #define BB_FEATURE_SORT_REVERSE
    #define BB_FEATURE_SORT_UNIQUE
    #define BB_FEATURE_COMMAND_EDITING
    #define BB_FEATURE_COMMAND_TAB_COMPLETION
    #define BB_FEATURE_SH_FANCY_PROMPT
    #define BB_FEATURE_ASH_JOB_CONTROL
    #define BB_FEATURE_NEW_MODULE_INTERFACE
    #define BB_FEATURE_IFCONFIG_STATUS
    #define BB_FEATURE_IFCONFIG_SLIP
    #define BB_FEATURE_WGET_STATUSBAR
    #define BB_FEATURE_WGET_AUTHENTICATION
    #define BB_FEATURE_HUMAN_READABLE
    #define BB_FEATURE_FIND_TYPE
    #define BB_FEATURE_FIND_PERM
    #define BB_FEATURE_FIND_MTIME
    #define BB_FEATURE_FIND_NEWER
    #define BB_FEATURE_TFTP_PUT
    #define BB_FEATURE_TFTP_GET
    #define BB_FEATURE_VI_COLON
    #define BB_FEATURE_VI_YANKMARK
    #define BB_FEATURE_VI_SEARCH
    #define BB_FEATURE_VI_USE_SIGNALS
    #define BB_FEATURE_VI_DOT_CMD
    #define BB_FEATURE_VI_READONLY
    #define BB_FEATURE_VI_SETOPTS
    #define BB_FEATURE_VI_SET
    #define BB_FEATURE_VI_WIN_RESIZE
    #define BB_FEATURE_TELNET_TTYPE

Everything else found as options in this file might be disabled, using following commenting style:

    //#define BB_FEATURE_EXTRA_QUIET

Now, it's time for compiling:

$ make CROSS=sh4-linux- DOSTATIC=true \
  CFLAGS_EXTRA="-I $PREFIX/$TARGET/include" \
  PREFIX=$INITRD clean all install

With the command above, we force make into building a static program since we don't a dynamic linker let alone a shared C - library on our target platform.

Now, two things are absent: The device nodes and the kernel modules. So, we correct these points by:

$ cd ../..
$ cd KERNEL/linux
$ su -c "make ARCH=sh CROSS_COMPILE=sh4-linux- \
  INSTALL_MOD_PATH=/home/christian/Dreamcast/\
  INITRD modules_install"

Don't be disturbed by the error message at the end: We don't have a depmod utility that handles modules for foreign hardware architectures, so simply ignore it.

Now, change directory to the initial ramdisk and correct the libraries folder:

$ cd ../..
$ cd INITRD
$ cd lib/modules/2.4.18-sh-dc

Remove every file and directory except the directory kernel - it contains our kernel modules.

Following, we create the essential device nodes and the inittab:

$ cd ../../..
$ cd dev
$ su -c "mknod console c 5 1"
$ cd ..
$ cd etc

Edit the (not existing) file inittab:

# Starts an askfirst shell:

::askfirst:-/bin/sh

Finally, leave the initial ramdisk:

$ cd ../..


next up previous contents index
Next: Bundle the Linux kernel Up: Setting up an initial Previous: Building the Linux kernel   Contents   Index
Christian Berger 2004-10-19