What is Firmware Linux?

Firmware Linux (FWL) is an embedded Linux build system designed to eliminate the need for cross compiling, replacing it with native compiling under emulation instead.

FWL consists of a series of shell scripts which create a complete bootable linux system for a given target hardware platform. This provides a minimal native Linux build environment for the target, loosely based on Linux From Scratch (stripped down to an embedded variant built from busybox, uClibc, gcc, binutils, make, bash, and the Linux kernel). Running this native build environment under an emulator such as QEMU (or on real target hardware if applicable) allows fully native builds for arbitrary target platforms to be performed on cheap and powerful commodity PC hardware.

The currently supported target hardware platforms include arm, mips, powerpc, x86, and x86-64, with partial support for sh4, mips, and sparc.

Firmware Linux is loosely based on Linux From Scratch, stripped down and rebased on busybox and uClibc.

Intermediate stages of the build (such as the cross compiler and the unpackaged root filesystem directory) may also be useful to Linux developers, and are also packaged up in the build subdirectory.

The default build provides a native development environment for each target platform, eliminating the need for cross compiling in favor of native compiling under emulation.

Using the prebuilt binaries

system-image-*.tar.bz2

Each system-image tarball contains an ext2 root filesystem image, a kernel configured to run under qemu, and shell scripts to run the system (in various modes) under the emulator qemu.

To test boot an FWL target system under qemu 0.9.1, download the appropriate prebuilt binary tarball for the target you're interested in, extract it, cd into it, and execute one of the following shell scripts:

The FWL boot script for qemu (/tools/bin/qemu-setup.sh) populates /dev from sysfs, sets up an emulated (masquerading) network (so you can wget source packages or talk to distcc), and creates a few symlinks needed to test build normal software packages (such as making /lib point to /tools/lib). It also mounts /dev/hdb (or /dev/sdb) on /home if a second emulated drive is present.

For most platforms, exiting the command shell will exit the emulator. (Some, such as powerpc, don't support this yet. For those you have to kill qemu from another window, or exit the xterm. I'm working on it.)

To use this emulated system as a native build environment, see native compiling.

cross-compiler-*.tar.bz2

The cross compiler created during the FWL build is a relocatable C compiler for the target platform. To use it on its own, download the appropraite cross compiler tarball for the host you're running on and the target you'd like to compile for. Extract the compiler tarball and add the cross-compiler-$TARGET/bin directory to your $PATH, then use $TARGET-gcc as your cross compiler and "$TARGET-" as your CROSS prefix for packages with cross compiling support.

For example, if you download cross-compiler-armv4l and extract it into your home directory, set "PATH=~/cross-compiler-armv4l/bin:$PATH", use armv4l-gcc to build code, and use "CROSS=armv4l-" to set your cross compiler prefix.

Note that this cross compiler does not support C++. If you need C++ support, use the native compiling environment.

mini-native-*.tar.bz2

If you want to run this system on real hardware, you'll generally have to tweak and repackage the root filesystem. To make this easier, tarballs of each target's prebuilt root filesystem are available.

This root filesystem is a minimal native build environment for the target platform. This means it contains a compiler and associated build tools capable of building a complete new Linux system under itself, although you may have to bootstrap your way up (I.E. building things like zlib or perl before building momre complicated packages).

The vast majority of the space taken up by this filesystem is the development toolchain and associated support files (mostly header files and libraries).

If you're doing anything fancy, you'll probably want to rebuild it from source.

Building from source

To build FWL, download the most recent source tarball, extract it, cd into it, and run "./build.sh". This script takes one argument, which is the target to build for. Run it with no arguments to see available targets. The resulting files are created in the "build" directory, including all the downloadable tarballs. (To perform a clean build, "rm -rf build" and re-run build.sh.)

By default, this Linux system is a minimal native build environment for the target platform. It contains a compiler and associated build tools capable of building a complete new Linux system under itself. This is is to support native compiling, which allows you to build a new (possibly smaller) root filesystem for your target.

If you don't want to bother with that, set the environment variable "BUILD_SHORT=1" before running the build to skip building the native toolchain. This results in a much, much smaller root filesystem, and also moves it up out of the /tools directory, but makes adding additional software to the resulting system much more difficult (as it must be done via cross compiling).

See native compiling under emulation and customizing mini-native for more information.

How building from source works

build.sh and forkbomb.sh

The build.sh script is a simple wrapper which calls the other scripts in sequence:

  1. download.sh
  2. host-tools.sh
  3. cross-compiler.sh $TARGET
  4. mini-native.sh $TARGET
  5. package-mini-native.sh $TARGET

Another script, forkbomb.sh, performs a similar function but builds all supported targets at once.

The other scripts