What is Firmware Linux?

Firmware Linux (FWL) is an embedded Linux build system implemented as a series of shell scripts. The full build produces a complete bootable linux system (based on uClibc and BusyBox/toybox) for various hardware platforms (including arm, mips, ppc, x86, and x86-64).

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.

License

Firmware Linux is licensed under GPL version 2. This means that the build scripts are licensed under GPL version 2, and each of the component packages of the default "mini-native" root filesystem may be redistributed under the terms of GPLv2 (and in the case of uClibc, LGPLv2).

Adding your own packages to the resulting system is generally "mere aggregation" (see the last paragraph of section 2), and thus not my problem. This license statement is not intended to apply to your packages as long as they are not derived works of existing GPLv2 code.

Using the prebuilt binaries

qemu-image-*.tar.bz2

Each qemu-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 the "./run-emulator.sh" script in that directory.

This boots the target Linux system under the emulator, with /dev/console hooked to the emulator's stdin and stdout. (I.E. the shell prompt the script gives you after the boot messages is running in the emulator.) Type "cat /proc/cpuinfo" to confirm you're running in the emulator, then play around and have fun.

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).

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