How To Build LibreWRT

From LibreWRT

Revision as of 21:07, 18 November 2012 by Dmitry (Talk | contribs)
Jump to: navigation, search


What do I need to get started?

You will need the following resources to successfully build a LibreWRT image.

  • A GNU/Linux distribution. See 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

Prepare for building

The builder is controlled by the configuration file and command line arguments. Type:

 ./ -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:

 ./ -t wzr-hp-g300nh

If you want to tweak the LibreWrt and/or kernel configuration before building, use the -i option:

 ./ -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 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":

Option 2. Current Development Release. The upcoming version 2, codenamed "Creative Craftsman" (Note: this is just a development snapshot, so it may contain bugs):




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


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 -O .config

For the Buffalo router get this one:

wget -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:

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:


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.

Personal tools