Accueil > Uncategorized > A minimal linux system – Part 3

A minimal linux system – Part 3

We have managed, using only our bare hands, to :
– build a gcc-based cross-compiler
– build a linux kernel binary
– build a C standard library

Now we need some executables for our system. A minimum set would include a shell interpreter, some basic commands (cat, grep, ls, cp and so on) and an ssh server, because ssh is great.

The most current implementation of these tools on ‘desktop’ linux distributions are provided by GNU coreutils, GNU bash and openssh.

busybox

As more convenient way is to use the busybox project : busybox combines a shell interpreter all all the needed commonly used programs into a single binary, detecting how to behave depending on the name that was used to invoke it.

As usual it is simple to build, as long as you give the good configuration in the .config file (use mine or make menuconfig !)

BUSYBOX_VERSION=1.20.2
pushd $TOOLCHAIN_INSTALL_DIR/src
curl "http://www.busybox.net/downloads/busybox-$BUSYBOX_VERSION.tar.bz2" -o busybox-$BUSYBOX_VERSION.tar.bz2
tar -jxvf busybox-$BUSYBOX_VERSION.tar.bz2
ln -s busybox-$BUSYBOX_VERSION.tar.bz2 busybox
pushd busybox
    #edit .config
    make "ARCH=$ARCH" "CROSS_COMPILE=$TOOLCHAIN_TARGET-" "PREFIX=$TOOLCHAIN_INSTALL_DIR" CFLAGS="-I$TOOLCHAIN_INSTALL_DIR/include -Os -fPIC"
popd
popd

zlib

The zlib compression library is really common and offently used, so I decided to embed it as a shared library.

ZLIB_VERSION=1.2.7
pushd $TOOLCHAIN_INSTALL_DIR/src
curl "http://zlib.net/zlib-$ZLIB_VERSION.tar.gz" -o zlib-$ZLIB_VERSION.tar.gz
tar -zxvf zlib-$ZLIB_VERSION.tar.gz
ln -s zlib-$ZLIB_VERSION zlib
pushd zlib
	export CC=$TOOLCHAIN_TARGET-gcc
	export CFLAGS="-Os -I$TOOLCHAIN_INSTALL_DIR/include"
	export LDSHARED="$TOOLCHAIN_TARGET-gcc -shared -Wl,-soname,libz.so.1"
	./configure --shared --prefix=/usr/$TOOLCHAIN_TARGET
	make -B
	make install prefix=$TOOLCHAIN_INSTALL_DIR/usr/$TOOLCHAIN_TARGET
popd
popd

dropbear

dropbear is a super lightweight implementation of the ssh2 protocol, which make it the perfect alternative to openssh ! it compiles without any dependency and word pretty well – just like busybox, several executables are bundled in the same binary. I choosed to include the ssh server, the client, and scp.

DROPBEAR_VERSION=2012.55

pushd $TOOLCHAIN_INSTALL_DIR/src

curl "https://matt.ucc.asn.au/dropbear/dropbear-$DROPBEAR_VERSION.tar.bz2" -o dropbear-$DROPBEAR_VERSION.tar.bz2
tar -jxvf dropbear-$DROPBEAR_VERSION.tar.bz2
ln -s dropbear-$DROPBEAR_VERSION dropbear
pushd dropbear
	export CC=$TOOLCHAIN_TARGET-gcc
	export CFLAGS=-Os

	export C_INCLUDE_PATH=$TOOLCHAIN_INSTALL_DIR/include
	./configure --host=$TOOLCHAIN_TARGET \

		--with-zlib=$TOOLCHAIN_INSTALL_DIR/usr/$TOOLCHAIN_TARGET/lib
	make MULTI=1 PROGRAMS="dropbear scp dbclient"
popd
popd

Now we have all the ingredients : kernel, libraries, executables. on next episode I’ll try to explain how integrate all of these in order to get a functional system – A part that I found more more tricky than compiling the binaries themselves…

Publicités
Catégories :Uncategorized
  1. Aucun commentaire pour l’instant.
  1. No trackbacks yet.

Laisser un commentaire

Choisissez une méthode de connexion pour poster votre commentaire:

Logo WordPress.com

Vous commentez à l'aide de votre compte WordPress.com. Déconnexion /  Changer )

Photo Google+

Vous commentez à l'aide de votre compte Google+. Déconnexion /  Changer )

Image Twitter

Vous commentez à l'aide de votre compte Twitter. Déconnexion /  Changer )

Photo Facebook

Vous commentez à l'aide de votre compte Facebook. Déconnexion /  Changer )

w

Connexion à %s

%d blogueurs aiment cette page :