Easy Build

This will teach you how to build http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/generic/openwrt-ar71xx-generic-tl-wr741nd-v1-squashfs-factory.bin without generalizing or downloading unnecessary packages. You can adopt this process to build any OpenWRT .bin firmware.

Using Debian 6.0.7 Squeeze.

Install the dependencies

If you are building on MacOSX, please follow the instructions here to setup your environment.

You should use Debian Linux (currently 6.0.7 Squeeze).

Install the dependencies (as root):

apt-get install subversion build-essential libncurses5-dev zlib1g-dev gawk git ccache gettext libssl-dev xsltproc

Download OpenWRT source and feeds

mkdir ~/openwrt
cd ~/openwrt
svn co -r 36088 svn://svn.openwrt.org/openwrt/branches/attitude_adjustment
cd attitude_adjustment
./scripts/feeds update -a

Change the svn line (above) to download the version of OpenWRT you want to use. The above line downloads "attitude adjustment" revision 36088.

Get an OpenWRT .config file

The .config file is at the heart of OpenWRT. Let's use the one for the specific firmware I want to build: http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/generic/config.ar71xx_generic Download a different config if you are building for different hardware or a different version of OpenWRT.

So download it:

cd ~/openwrt/attitude_adjustment
rm .config
wget 'http://downloads.openwrt.org/attitude_adjustment/12.09-rc1/ar71xx/generic/config.ar71xx_generic'
ln -s config.ar71xx_generic .config

Now edit the .config: set the CONFIG_SDK=n and CONFIG_MAKE_TOOLCHAIN=n to not build the SDK or the TOOLCHAIN.

Install the feeds

Create a Perl script at ~/openwrt/attitude_adjustment/config_install_feeds.pl:

#!/usr/bin/perl

use warnings;
use strict;

open(CONFIG_FILE, '<', ".config");
while(<CONFIG_FILE>)
{
  if( $_ =~ /^CONFIG_PACKAGE_(.+?)=y/)
  {
    my $feed = $1;
    print("./scripts/feeds install $feed\n");
    system("./scripts/feeds install $feed");
  }
}

Now run the perl script:

cd ~/openwrt/attitude_adjustment
chmod 755 config_install_feeds.pl
./config_install_feeds.pl

Disable unnecessary packages

The default OpenWRT build says to build everything. This is unnecessary, so I've written a perl script to automatically disable the things we don't need for the .bin firmware.

Create a Perl script at ~/openwrt/attitude_adjustment/config_feeds_disable_packages.pl:

#!/usr/bin/perl

use warnings;
use strict;

open(CONFIG_FILE, '<', ".config");
while(<CONFIG_FILE>)
{
  chomp;
  if( $_ =~ /^CONFIG_PACKAGE_(.+?)=m$/)
  {
    print("CONFIG_PACKAGE_$1=n\n");
  }
  else
  {
    print("$_\n");
  }
}

Now run the perl script:

cd ~/openwrt/attitude_adjustment
chmod 755 config_feeds_disable_packages.pl
./config_feeds_disable_packages.pl > ./.config.new
mv ./.config.new ./.config

Configure OpenWRT

make oldconfig

It will ask questions, answer 63 (or whatever number corresponds to your device) to say we are building for e.g. a TP-Link WR741ND.

Answer n for all the rest of the questions, to not include any packages we didn't install.

Download the required packages

This step is optional.

Here we download most of the required packages and make a redistributable tarball.

cd ~/openwrt/attitude_adjustment
make download
make dirclean
cd ..
tar -czf tp-link-openwrt-firmware-source.tgz attitude_adjustment
rm -rf attitude_adjustment

You now have a source tarball so you don't need to be connected to the internet to compile OpenWRT! Except due to a bug in OpenWRT, some more packages are still required to be downloaded (see Optional Bugfix below).

To build the OpenWRT tarball

cd attitude_adjustment
make V=s

Optional Bugfix: Unpack the tp-link-openwrt-firmware-source.tgz you optionally made earlier. Copy over all files from attitude_adjustment/dl/ directory to your untarred tp-link-openwrt-firmware-source.tgz directory.

Done. You will find your firmware in the bin/ directory.

Back to top

doc/howto/easy.build.txt · Last modified: 2013/04/13 20:32 by mathieu