Line 2: Line 2:
 
=== Building a minimal RootFS with Busybox ===
 
=== Building a minimal RootFS with Busybox ===
  
BusyBox is a collection of cut down versions of common UNIX utilities compiled into a single small executable. This makes for an ideal base for resource constrained systems.
+
[http://www.busybox.net/ BusyBox] is a collection of cut down versions of common UNIX utilities compiled into a single small executable. This makes BusyBox an ideal foundation for resource constrained systems.
  
 
== BusyBox ==
 
== BusyBox ==
  
BusyBox can be built either as a single static executable requiring no external libraries, or built requiring GLIBC. I generally choose to build BusyBox to require GLIBC as it is likely you will want to run additional applications that will require GLIBC.  
+
BusyBox can be built either as a single static binary requiring no external libraries, or built requiring shared libraries such as GLIBC (default). This setting can be found under BusyBox Settings -> Build Options -> Build BusyBox as a static binary (no shared libs).  
 +
 
 +
I generally choose to build BusyBox to require GLIBC as it is highly likely you will want to run additional applications that will require GLIBC.  
  
 
<PRE>
 
<PRE>
Line 14: Line 16:
 
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- defconfig
 
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- defconfig
 
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- menuconfig
 
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- menuconfig
 +
</PRE>
 +
 +
At the menu, you can configure BusyBox options. Once configured, you can build BusyBox:
 +
 +
<PRE>
 
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-  
 
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-  
 
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- install CONFIG_PREFIX=/home/export/rootfs
 
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- install CONFIG_PREFIX=/home/export/rootfs
Line 20: Line 27:
 
== GLIBC ==
 
== GLIBC ==
  
Now build and install GLIBC:
+
GLIBC is the [http://www.gnu.org/software/libc/libc.html GNU C Library] and includes common system calls required by executables running on your system.
 +
 
 +
Download, build and install GLIBC:
  
 
<PRE>
 
<PRE>
Line 30: Line 39:
 
make
 
make
 
make install install_root=/home/export/rootfs  
 
make install install_root=/home/export/rootfs  
 +
</PRE>
 +
 +
If you get an error similar to that below with cross-rpcgen, then it would appear cross-rpcgen was built for arm, but is trying to run on your x86 based build system. To alleviate the problem I pre-build a copy for x86 and place it in /glibc-build/sunrpc/cross-rpcgen and then restart the arm build.
 +
 +
<PRE>
 +
CPP='arm-linux-gnueabi-gcc -E -x c-header' /.../glibc-build/sunrpc/cross-rpcgen -Y ../scripts -c rpcsvc/bootparam_prot.x -o /.../glibc-build/sunrpc/xbootparam_prot.T
 +
/lib/ld-linux.so.3: No such file or directory
 +
make[2]: *** [/.../glibc-build/sunrpc/xbootparam_prot.stmp] Error 255
 
</PRE>
 
</PRE>
  
 
== Preparing RootFS ==
 
== Preparing RootFS ==
  
Once BusyBox and GLIBC has been cross compiled, you will want to create the remainder of the root file system. Start by creating the necessary directory structure:
+
Once BusyBox and GLIBC has been cross-compiled, you will want to create the remainder of the root file system. Start by creating the necessary directory structure:
  
 
<PRE>
 
<PRE>
Line 40: Line 57:
 
</PRE>
 
</PRE>
  
Create a file called etc/init.d/rcS and add:
+
Now we must mount the /proc & /sys filesystem and populate the /dev nodes. This can be done at runtime by creating a file called /etc/init.d/rcS and adding:
  
 
<PRE>
 
<PRE>
Line 52: Line 69:
  
 
<PRE>
 
<PRE>
chmod +x etc/init.d/rcS  
+
chmod +x /etc/init.d/rcS  
 
</PRE>
 
</PRE>
  
 
You should now have a basic, yet functional, BusyBox root file system.
 
You should now have a basic, yet functional, BusyBox root file system.

Revision as of 07:01, 21 April 2014

Building a minimal RootFS with Busybox

BusyBox is a collection of cut down versions of common UNIX utilities compiled into a single small executable. This makes BusyBox an ideal foundation for resource constrained systems.

BusyBox

BusyBox can be built either as a single static binary requiring no external libraries, or built requiring shared libraries such as GLIBC (default). This setting can be found under BusyBox Settings -> Build Options -> Build BusyBox as a static binary (no shared libs).

I generally choose to build BusyBox to require GLIBC as it is highly likely you will want to run additional applications that will require GLIBC.

wget http://busybox.net/downloads/busybox-1.22.1.tar.bz2
tar -xjf busybox-1.22.1.tar.bz2
cd busybox-1.22.1/
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- menuconfig

At the menu, you can configure BusyBox options. Once configured, you can build BusyBox:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- 
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- install CONFIG_PREFIX=/home/export/rootfs

GLIBC

GLIBC is the GNU C Library and includes common system calls required by executables running on your system.

Download, build and install GLIBC:

wget http://ftp.gnu.org/gnu/libc/glibc-2.19.tar.gz
tar -xzf glibc-2.19.tar.gz
mkdir glibc-build
cd glibc-build/
../glibc-2.19/configure arm-linux-gnueabi --target=arm-linux-gnueabi --prefix= --enable-add-ons
make
make install install_root=/home/export/rootfs 

If you get an error similar to that below with cross-rpcgen, then it would appear cross-rpcgen was built for arm, but is trying to run on your x86 based build system. To alleviate the problem I pre-build a copy for x86 and place it in /glibc-build/sunrpc/cross-rpcgen and then restart the arm build.

CPP='arm-linux-gnueabi-gcc -E -x c-header' /.../glibc-build/sunrpc/cross-rpcgen -Y ../scripts -c rpcsvc/bootparam_prot.x -o /.../glibc-build/sunrpc/xbootparam_prot.T
/lib/ld-linux.so.3: No such file or directory
make[2]: *** [/.../glibc-build/sunrpc/xbootparam_prot.stmp] Error 255

Preparing RootFS

Once BusyBox and GLIBC has been cross-compiled, you will want to create the remainder of the root file system. Start by creating the necessary directory structure:

mkdir proc sys dev etc etc/init.d

Now we must mount the /proc & /sys filesystem and populate the /dev nodes. This can be done at runtime by creating a file called /etc/init.d/rcS and adding:

#!bin/sh
mount -t proc none /proc
mount -t sysfs none /sys
/sbin/mdev -s

and make executable:

chmod +x /etc/init.d/rcS 

You should now have a basic, yet functional, BusyBox root file system.