How To Build LibreWRT
What do I need to get started?
You will need the following resources to successfully build a LibreWRT image.
- 7 GB of free disk space for one target (+6 GB for each additional target).
- A GNU/Linux distribution. See gnu.org/distros for our recommended list of GNU/Linux distributions. LibreWRT should work with any GNU/Linux distribution, but has been specifically tested in the fully free distribution Trisquel GNU/Linux.
- gcc GNU Compiler Collection
- GNU awk or gawk
- qemu (if you want to run the x86 build)
- some time to kill
It is also highly recommended to have:
There are two ways to build LibreWrt "Creative Craftsman" 2.0:
- Build it manually from the source tarball. This way involves a lot of typing but it may appear more flexible.
- Use the Builder. It will automate most of the job but you'll probably have to deal with Builder's bugs ;-)
Build manually from the source tarball
Get the source code
The first step is to download and unzip the source code of the latest stable version 2, codenamed "Creative Craftsman":
Unzip it and look inside.
tar -jxvf librewrt-src.tar.bz2 cd librewrt
The supported feeds are inside the Creative Craftsman's source tree already (only a small fraction of packages is included currently), so you don't have to do anything.
Get the default LibreWrt configuration file
You need to get the appropriate .config file for your target. For example, the Ben NanoNote users should get this one:
For the Buffalo router get this one:
wget http://download.librewrt.org/creative-craftsman/2.0-release/source/wzr-hp-g300nh-config -O .config
Configure the initial build
According to bug #34, you'll probably need to do this first:
rm scripts/config/*.o scripts/config/conf
if you build LibreWRT 2.
We then need to configure LibreWRT for our needs. We also need to make sure that we have met all of the requirements that are needed for LibreWRT to build.
Select the target architecture and any additional packages that you would like to include in your image.
Many GNU packages are available for use: LibreWRT uses a kernel called GNU Linux-libre, which became an official GNU package in March 2012. Also available are things like BASH, Emacs, GDB, gblic, etc. However: There is a great deal of flexibility in compiling the firmware image and almost any package can be included or left out or replaced (glibc can be substituted for a different C library for example.) The only one that can't really be left out though is the kernel called GNU Linux-libre.
If you are building for the Ben Nanonote, please make sure to select / enable u-boot under the Boot Loader menu. Once all configuration settings have been set, exit menuconfig.
The Ben NanoNote users have one more thing to do. Create the following symbolic link to make the default Ben configuration files available to a build process:
ln -s feeds/qipackages/nanonote-files/data/qi_lb60/files
You may want to change the default kernel configuration for your target hardware. Creative Craftsman contains kernel config files for each target. You can copy one into the LibreWrt source tree like this:
wget http://download.librewrt.org/creative-craftsman/2.0-release/source/qi_lb60-kernel-config kver=`grep '^CONFIG_LINUX_.\+=y$' .config | sed 's/^CONFIG_LINUX_\(.\+\)=y$/\1/' | sed 's/_/./g'` mv qi_lb60-kernel-config target/linux/xburst/config-$kver
After this you can tweak the kernel configuration using
Build the image
You can then begin compiling the LibreWRT image by issuing:
The speed of the build can be increased by using more than 1 concurrent job process. With the -j-option, the most common suggestion is to use
<your number of CPUs + 1>, so on a dual core CPU, do:
make -j 3
If you happen to run into any issues during the compiling process, run make with V=99 to see any errors that are generated during the compiling process.
This is going to take a while, depending on the speed of your machine, network connection, and how much software was selected in menuconfig.
Build using the Builder
Get the builder:
bzr branch http://bzr.librewrt.org/builder/creative-craftsman cd creative-craftsman
To build the LibreWrt 2 for Ben NanoNote:
./build.sh -i -t qi_lb60 -u -r 2.0-release
or to build it for Buffalo WZR-HP-G300NH:
./build.sh -i -t wzr-hp-g300nh -u -r 2.0-release
or to build it for some other platform:
mkdir targets/my-target ./build.sh -i -t my-target -u -r 2.0-release
You'll get two menuconfigs sequentially: for the LibreWrt and for the Linux. Select your platform (in case of "my-target") and/or tweak other options, then save each config and say 'yes' when asked to overwrite. After that the build will start.
Next time you run the build, you can omit the "-u -r 2.0-release" part of command line; likewise, if you don't want to tune options anymore, just don't use "-i".
You can find more info about the Builder in its README file and by using the command
Please note that the Builder is not rock stable, so if you think you've found some bug, please ask at IRC or at the mailing list.
Bright Ben (obsolete)
"Bright Ben" is the codename of the first LibreWrt version which is not supported anymore. This text describes how to build it.
If you have any questions, comments or bug-reports, please use the mailing lists.