#!/bin/sh # This script runs as a mortal user, and builds # the user-space programs for the root filesystem # for an embedded arm-linux machine. It is tuned # for my use of the SA1100 on a Bright Star Engineering # nanoEngine board. Only slight adjustments should # be needed for other StrongARM boards, and the basic # flow holds for building any other embedded # environment. # # This script only very weakly depends on the host # system, as long as it has a halfway-working gcc # and gmake. Tested on i686-unknown-linux-gnu, # kernel-2.0.36, gcc-2.7.2, gmake-3.79.1, glibc-2.0.7 # # Assumes you already have a working cross-development # toolchain: binutils, gcc, kernel, libc. # # usage: see the README that should accompany this file. # January 29, 2001 Larry Doolittle # # todo: # more initial sanity checks set -e ARCH=arm TARGET=$ARCH-linux KHOME=$BUILD/linux-2.4.18-rmk7-lrd1 if [ ! -d $KIT_DIR -o ! -d $PRISTINE -o ! -d $BUILD -o ! -d $PREFIX -o ! -d $EMBEDDED_ROOT ]; then echo "$0: configuration error" exit fi PATH=$PREFIX/bin:$PATH # ........................................................ # make a ramdisk template with libraries from devel system # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ echo "#### base libraries" (cd $EMBEDDED_ROOT mkdir -p bin sbin lib usr dev var tmp proc mnt mkdir -p usr/bin usr/lib mnt/flash etc/init.d mkdir -p home/mortal/.ssh cp -a $KIT_DIR/etc . # sorry, no man pages on target system. Squirrel them away on host. mkdir -p $BUILD/man cd usr; ln -s $BUILD/man man ) (cd $PREFIX/$TARGET/lib cp -a `ls | grep "\.so"` $EMBEDDED_ROOT/lib cd $EMBEDDED_ROOT/lib # glibc linker script not needed on target rm -f libc.so libc.so.orig $TARGET-strip * ) # ......................... # build and install busybox # ^^^^^^^^^^^^^^^^^^^^^^^^^ echo "#### busybox" mkdir $BUILD/busybox-0.60.5-$ARCH cd $BUILD/busybox-0.60.5-$ARCH sh $PRISTINE/busybox-0.60.5/pristine_setup.sh mv Config.h Config.h.orig # # We have space, turn on a bunch of features left off by default. # The sed commands turn your eyes inside out unless I define yes and no. yes='s/^\/\/#/#/' no='s/^#/\/\/#/' sed \ -e "/define BB_ADJTIMEX/$yes" \ -e "/define BB_AR/$yes" \ -e "/define BB_ASH/$yes" \ -e "/define BB_EXPR/$yes" \ -e "/define BB_FREERAMDISK/$yes" \ -e "/define BB_GETOPT/$yes" \ -e "/define BB_HOSTID/$yes" \ -e "/define BB_HOSTNAME/$yes" \ -e "/define BB_IFCONFIG/$yes" \ -e "/define BB_INSMOD/$yes" \ -e "/define BB_MD5SUM/$yes" \ -e "/define BB_MKFIFO/$yes" \ -e "/define BB_MKTEMP/$yes" \ -e "/define BB_MSH/$no" \ -e "/define BB_NC/$yes" \ -e "/define BB_NSLOOKUP/$yes" \ -e "/define BB_PING/$yes" \ -e "/define BB_PRINTF/$yes" \ -e "/define BB_RDATE/$yes" \ -e "/define BB_READLINK/$yes" \ -e "/define BB_RENICE/$yes" \ -e "/define BB_RMMOD/$yes" \ -e "/define BB_ROUTE/$yes" \ -e "/define BB_TEE/$yes" \ -e "/define BB_TEST/$yes" \ -e "/define BB_TELNET/$yes" \ -e "/define BB_TFTP/$yes" \ -e "/define BB_TIME/$yes" \ -e "/define BB_TR\$/$yes" \ -e "/define BB_UUENCODE/$yes" \ -e "/define BB_UUDECODE/$yes" \ -e "/define BB_UPDATE/$yes" \ -e "/define BB_USLEEP/$yes" \ -e "/define BB_VI/$yes" \ -e "/define BB_WGET/$yes" \ -e "/define BB_FEATURE_SH_IS_ASH/$yes" \ -e "/define BB_FEATURE_SH_IS_MSH/$no" \ -e "/define BB_FEATURE_BUFFERS_GO_IN_BSS/$yes" \ -e "/define BB_FEATURE_NFSMOUNT/$yes" \ -e "/define BB_FEATURE_SH_STANDALONE_SHELL/$no" \ -e "/define BB_FEATURE_NEW_MODULE_INTERFACE/$yes" \ -e "/define BB_FEATURE_IFCONFIG_STATUS/$yes" \ -e "/define BB_FEATURE_WGET_STATUSBAR/$no" \ -e "/define BB_FEATURE_WGET_AUTHENTICATION/$no" \ -e "/define BB_FEATURE_HUMAN_READABLE/$no" \ Config.h # make CROSS=$TARGET- USE_SYSTEM_PWD_GRP=true busybox busybox.links $PRISTINE/busybox-0.60.5/install.sh $EMBEDDED_ROOT # ............................... # build strace, but don't install # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ # (this better not be a production tool, and Flash is normally # tight; you can always copy this in via NFS when debugging) echo "#### strace" cd $BUILD mkdir strace-4.2-$ARCH cd strace-4.2-$ARCH CC=$TARGET-gcc $PRISTINE/strace-4.2/configure --prefix=$EMBEDDED_ROOT $TARGET make # ........................... # build and install ntpclient # ^^^^^^^^^^^^^^^^^^^^^^^^^^^ echo "#### ntpclient" mkdir $BUILD/ntpclient-$ARCH cd $BUILD/ntpclient-$ARCH make -f $PRISTINE/ntpclient/Makefile VPATH=$PRISTINE/ntpclient \ CC=$TARGET-gcc cp ntpclient $EMBEDDED_ROOT/bin/ $TARGET-strip $EMBEDDED_ROOT/bin/ntpclient # .......................... # build and install mtd-util # ^^^^^^^^^^^^^^^^^^^^^^^^^^ echo "#### mtd-util" # # You could get by without building the target mtd-utils, if you used # the nanoEngine boot monitor to erase the Flash before mounting the # partition as jffs2. # mkdir $BUILD/mtd-util-$ARCH cd $BUILD/mtd-util-$ARCH make -f $PRISTINE/mtd-util-20011008/Makefile VPATH=$PRISTINE/mtd-util-20011008 \ CC=$TARGET-gcc target # really crude install cp einfo erase eraseall fcp lock mtd_debug unlock $EMBEDDED_ROOT/bin/ (cd $EMBEDDED_ROOT/bin; $TARGET-strip einfo erase eraseall fcp lock mtd_debug unlock) # # The host mtd-utils would be interesting if you wanted to create # a directory tree on the host side, that was then used in the boot # process. For now, an empty filesystem is good enough, and that # is adequately prepared by erasing the Flash. This section is # ready to use, but the instructions don't tell you to use it. # If you want to try, first erase the Flash, then (from the Linux # prompt on the nanoEngine): # $ cp /etc/test.jffs2 /dev/mtd2 # If you tried, you could probably also convince the nanoEngine # boot monitor to put this file into Flash for you. # mkdir $BUILD/mtd-util-host cd $BUILD/mtd-util-host make -f $PRISTINE/mtd-util-20011008/Makefile VPATH=$PRISTINE/mtd-util-20011008 \ KERNEL=$KHOME host mkdir test cat <test/README This file is mounted as part of Linux's JFFS2, a Journalling filesystem designed for use with Flash memory. Files kept in this directory are persistent across reboots. Flash devices can only be written to a finite number of times, so use this device sparingly. Also, please check the main README file for an important warning about reboots and the Flash chip. EOF ./mkfs.jffs2 -r test -l -q -o test.jffs2 rm -f test/README cp test.jffs2 $EMBEDDED_ROOT/etc # ............................................. # build and install the (tiny) nanoEngine tools # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ echo "#### nanoengine-tools" cd $BUILD/nanoengine-tools CROSS=$TARGET- make CROSS=$TARGET- PREFIX=$EMBEDDED_ROOT make install # .................................. # build, but don't install, procinfo # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ echo "#### procinfo" cd $BUILD mkdir procinfo-18-$ARCH cd procinfo-18-$ARCH make -f $PRISTINE/procinfo-18/Makefile VPATH=$PRISTINE/procinfo-18 CC=$TARGET-gcc # remove a stray link cd $EMBEDDED_ROOT/usr rm man