How To Build LibreWRT
From LibreWRT
Contents |
What do I need to get started?
You will need the following resources to successfully build a LibreWRT image.
- 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 4.5.1.
- gcc GNU Compiler Collection
- gcc-multilib
- patch
- perl
- flex
- GNU awk or gawk
- ncurses-dev
- subversion
- bzr
- git-core
- libghc6-zlib-dev
- quilt
- qemu (if you want to run the x86 build)
- some time to kill
Build LibreWrt
There are two ways to build LibreWrt:
- Use the builder (recommended). It will automate most of the job. Using the builder you'll get the latest state of the development version of LibreWrt.
- Build it from the source tarball. This is the older way that involves a lot of typing. You'll get either stable release or the recent intermediate development release.
Build using the builder
About the LibreWrt builder
The LibreWrt builder is the program that automates LibreWrt build process. It pulls OpenWrt using git, modifies it to comply with FSDG, thus turning it into the LibreWrt, and compiles it. The builder helps both users and developers of LibreWrt.
Get the builder
Get the builder out of the Bazaar repository:
bzr branch http://bzr.librewrt.org/builder
Prepare for building
The builder is controlled by the configuration file and command line arguments. Type:
./builder.sh -h
to list the available command line options. This command also displays the targets currently supported (you can use "-t" to specify the target you want to build).
At first, do:
cp builder.conf.default builder.conf
and edit "builder.conf" in your editor of choice. All options are described in comments in the file. It is usually enough to tweak WORKDIR, OUTPUTDIR, DOWNLOADDIR and probably PARALLEL_BUILDS.
Build it
When your configuration file is ready, start the build process. Say, if you want to build the firmware for your Buffalo WZR-HP-G300NH router, type:
./builder.sh -t wzr-hp-g300nh
If you want to tweak the LibreWrt and/or kernel configuration before building, use the -i option:
./builder.sh -i -t wzr-hp-g300nh
"make menuconfig" and "make kernel_menuconfig" will be run. WARNING: You will be asked if you want to put the modified configuration files back into the "targets/<target-name>" directory of the builder. If you'd want to restore the former configs after that, type:
bzr revert targets/<target-name>/librewrt.config bzr revert targets/<target-name>/kernel.config
Rebuild LibreWrt
To rebuild LibreWrt it is enough to run builder.sh again (see above section). Using ccache should improve recompilation times. It is recommended to update the builder before build:
bzr pull
Build custom target
It is also possible to build a custom target: just create a "targets/<your-target>" directory and optionally put there the LibreWrt and kernel configuration files (if you omit some of them, "make menuconfig" and/or "make kernel_menuconfig" will be run for you).
Still in development
Please note that the builder is of alpha quality yet, so if you found some bug, please describe it in our mailing list or report it in the bug tracker.
Build from the source tarball
Get the source code
The first step is to download and unzip the source code.
Option 1. Current Stable. This release is LibreWRT version 1, codenamed "Bright Ben":
http://bzr.librewrt.org/bright-ben/?download=tgz
Option 2. Current Development Release. The upcoming version 2, codenamed "Creative Craftsman" (Note: this is just a development snapshot, so it may contain bugs):
wget http://download.librewrt.org/creative-craftsman/cc-ben-201206190654/source/librewrt-src.tar.bz2
or
wget http://download.librewrt.org/creative-craftsman/cc-buffalo-201206190033/source/librewrt-src.tar.bz2
Unzip it and look inside.
tar -jxvf librewrt-src.tar.bz2 cd librewrt
Setup feeds
The Current Development Release have no feeds yet, so in this case you can skip this section. The Current Stable Release users can optionally enable additional packages not included in the base system:
./scripts/feeds update -a make package/symlinks
Get the default LibreWrt configuration file
cd (SOURCE_ROOT)
Option 1. In case of the Current Stable, just type the following to use the default distro configuration:
make defconfig
Option 2. If you're trying the Current Development Release, get the appropriate .config file for your target. For example, the Ben NanoNote users should get this one:
wget http://download.librewrt.org/creative-craftsman/cc-ben-201206190654/ben/librewrt.config -O .config
For the Buffalo router get this one:
wget http://download.librewrt.org/creative-craftsman/cc-buffalo-201206190033/buffalo/librewrt.config -O .config
Configure the initial build
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.
make menuconfig
Select the target architecture and any additional packages that you would like to include in your image. 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 package/nanonote-files/data/qi_lb60/files
Setup Linux
You may want to change the default kernel configuration for your target hardware.
Option 1. For Current Stable Release type:
make kernel_menuconfig
Option 2. The Current Development Release contains the kernel.config file (currently for Ben Nanonote only). You can copy it into the LibreWrt source tree like this:
wget http://download.librewrt.org/creative-craftsman/cc-201204042306/ben/kernel.config mv kernel.config target/linux/xburst/config-3.0
(It is implied here that your Linux version is 3.0 -- the default kernel version of the latest development release for Ben NanoNote.) After that you can tweak the configuration using
make kernel_menuconfig
Build the image
You can then begin compiling the LibreWRT image by issuing:
make
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.
make V=99
This is going to take a while, depending on the speed of your machine, network connection , and how much software was selected in menuconfig.
Closing thoughts
If you have any questions, comments or bug-reports, please use the mailing lists.

