OpenWrt Buildroot – Installation

OpenWrt Buildroot is the preferred toolchain to build OpenWrt. It is recommended that you use a GNU/Linux Distribution, either a standalone installation or a separate system running in a virtual environment (VMware or Qemu). Cygwin will probably not work correctly, and while it is possible to build OpenWrt images on a ~BSD or on MacOSX systems, success is not guaranteed. Feel free to try and then report back with your results. Don't forget to read Troubleshooting.

Prerequisites

  • 350 MB of hard disk space for downloaded source files.
  • 3-4 GB of available hard disk space to build OpenWrt.

Procedure

1. Do everything as non-root user!
2. Issue all OpenWrt Buildroot commands in the <buildsystem root> directory, e.g. ~/openwrt/trunk/
3. Do not build in a directory that has spaces in its full path
  1. Install subversion (short: svn), to conveniently download the OpenWrt source code, and build tools to assist with the compilation process:
    sudo apt-get install subversion build-essential
  2. Download the OpenWrt sources with svn.
    mkdir ~/openwrt
    cd openwrt
    svn co svn://svn.openwrt.org/openwrt/trunk/
    cd trunk
    • this will create a directory 'trunk', which is the main OpenWrt source code dir
    • for trunk rev R27988, there will be 14,382 files with an overall size of 150 MiB
    • includes the OpenWrt Buildroot system.
    • for more information about Downloading Sources.
  3. Download and install feeds using feeds script. (optional)
    ./scripts/feeds update -a
    ./scripts/feeds install -a
    • after this, Revision 7367, the trunk-dir contained 26,650 files with an overall size of 302 MiB (to install individual packages: ./scripts/feeds install PACKAGENAME)
  4. Use one of the following commands to check for missing packages on the system you want to build OpenWrt on:
    make defconfig
    make prereq
    make menuconfig
    • this will list missing system packages needed to successfully build OpenWrt using buildroot.
  5. Install the missing packages using package management commands. See the examples and table below for more details.

:!: After configuring and running make (as described here), trunk-dir contained 244,451 files with a total size of 3.2GiB!

Examples

Debian 5.0 Lenny:

# aptitude install gawk ncurses-dev unzip zlib1g-dev

Debian 6.0 Squeeze:

# aptitude install libncurses5-dev zlib1g-dev gawk flex

Fedora 11:

# yum install binutils bzip2 gawk gcc gcc-c++ gettext make ncurses-devel patch unzip wget zlib-devel flex git-core

openSuSE 11.1

# zypper install binutils bzip2 gawk gcc gcc-c++ gettext make ncurses-devel patch unzip wget zlib-devel flex git-core

Ubuntu:

$ sudo apt-get install build-essential subversion libncurses5-dev zlib1g-dev gawk flex

Ubuntu 9.10, I needed also these (30-03-2011):

$ sudo apt-get install gcc-multilib bison autoconf screen gcc g++ binutils patch bzip2 flex make gettext unzip libc6 git-core

Ubuntu 11.10:

$ sudo apt-get install build-essential subversion git-core libncurses5-dev zlib1g-dev gawk flex quilt

Ubuntu 64bit:

$ sudo apt-get install build-essential subversion libncurses5-dev zlib1g-dev gawk gcc-multilib flex git-core gettext

Mac OS X (tested on 64-bit Lion):

  1. Download MacPorts .pkg Installer, and install (horizontal scroll for entire second command):
  2. sudo port -v selfupdate
  3. sudo port install coreutils asciidoc bzip2 fastjar flex getopt gtk2 intltool jikes zlib openssl p5-extutils-makemaker python26 rsync ruby sdcc unzip gettext libxslt bison gawk autoconf wget gmake ncurses e2fsprogs osso-uuid
  4. Required for 64-bit OS X: After checking out the source tree via svn above, we need to edit trunk/tools/Makefile
  • On line 17, erase the instance of "e2fsprogs" but leave the rest of the line
  • Comment out line 22, line 50, line 52, line 58 with the hash symbol, by putting # at the beginning of each line. They are the lines that issue qemu to be built, followed by the build dependancies for mtd-utils (dep: e2fsprogs), qemu (dep: e2fsprogs), and e2fsprogs respectively.
  • Then copy the required headers and libraries to compile tools/mtd-utils
    cd trunk;
    mkdir -p staging_dir/host/include/e2fsprogs;
    cp -R /opt/local/include/ossp staging_dir/host/include/e2fsprogs/;
    cp /opt/local/lib/libuuid* staging_dir/host/lib 

See thread: [HOWTO] Build OpenWRT Trunk from svn on Mac OS X 10.7 Lion for more details

Notes:

  • In Debian or Ubuntu use
    apt-cache search ""
    to find prerequisite packages. Naming is sometimes different
  • In openSuSE some packages require additional repositories. Search on http://packages.opensuse-community.org and add repositories like that:
    zypper ar "http://download.opensuse.org/repositories/devel:/languages:/perl/openSUSE_11.1/devel:languages:perl.repo"
  • To build your images on a Mac OS X Machine all you need is the package "fileutils" from the fink project. (Tested on Leopard 10.5.3)

Table of known prerequisites and their corresponding packages

Here's a table with the package name for each prerequisite separated for different Linux distributions.

Prerequisite Debian Suse Red Hat OS X (via MacPorts) Fedora NetBSD
asciidoc asciidoc asciidoc asciidoc asciidoc asciidoc ?
bash bash ? ? bash ? bash
binutils binutils binutils binutils binutils binutils ?
bzip2 bzip2 bzip2 bzip2 bzip2 bzip2 ?
fastjar fastjarfastjar libgcj fastjar libgcj ?
flex flex? ? flex flex ?
g++ g++ gcc-c++ gcc-c++ ? gcc-c++ ?
gcc gcc gcc gcc ? gcc ?
getopt util-linux ? ? getopt ? getopt
GNU awk gawk gawk gawk gawk gawk ?
gtk2.0-dev libgtk2.0-dev ? gtk2-devel gtk2 gtk2-devel ?
intltool-update intltool intltool intltool intltool intltool ?
jikes jikes ? jikes ?
libz, libz-dev zlib1g-dev zlib-devel zlib-devel zlib zlib-devel ?
make make make ? gmake make gmake
ncurses libncurses5-dev ncurses-devel ncurses-devel ncurses ncurses-devel ?
openssl/ssl.h libssl-dev libopenssl-devel openssl-devel openssl openssl-devel ?
patch patch patch ? patchutils patch ?
perl-ExtUtils-MakeMaker perl-modules perl-ExtUtils-MakeMaker perl-ExtUtils-MakeMaker p5-extutils-makemaker perl-ExtUtils-MakeMaker ?
python2.6-dev python2.6-dev ? ? python26 ? ?
rsync rsync rsync ? rsync rsync ?
ruby ruby ruby ? ruby ruby ?
sdcc sdcc sdcc ? sdcc sdcc ?
unzip unzip unzip ? unzip unzip ?
wget wget wget wget wget wget ?
working-sdcc ? ? ? ?
xgettext gettext ? ? gettext gettext ?
xsltproc xsltproc libxslt ? libxslt libxslt ?

Unfortunately not all dependencies are checked by make config:

Package Prerequisite Debian Suse Red Hat OS X Fedora NetBSD
intltool [Perl] XML::Parser libxml-parser-perl ? ? ? ? ?

Downloading Sources

Short version: https://dev.openwrt.org/wiki/GetSource
You have two choices:

  • Download the latest stable release, or
  • Download the bleeding edge development snapshot (currently named "Attitude Adjustment", but often called "trunk").

The official repository is in svn but you can also choose to use git if you're building trunk. Refer to the GetSource for the URL and amend the following commands appropriately.

Using Release Sources (stable)

As of this writing, the latest stable release is OpenWrt 10.03 "Backfire". There is a Backfire branch in SVN repository, which is still slowly being updated with verified patches. Using it will most likely produce a stable and working OpenWrt installation, but all the newest features and patches might not be there. As an example, this will check out the source code that the backfire release is built from (plus the latest backported fixes from trunk):

svn checkout svn://svn.openwrt.org/openwrt/branches/backfire

You could alternatively download a 'tagged' version of the backfire sources. For instance, if you insist on using the pristine release sources (no backported fixes applied after the last release), you could use:

svn checkout svn://svn.openwrt.org/openwrt/tags/backfire_10.03

You can check out a certain revision:

svn checkout --revision=24045 svn://svn.openwrt.org/openwrt/branches/backfire/ ./build_dir

As for the packages copy feeds.conf.default in ./build_dir to feeds.conf and add "@24045" at the end of the line that checks out the package feed:

src-svn packages svn://svn.openwrt.org/openwrt/packages@24045

Using Development Sources (bleeding edge)

The current development branch (trunk) contains everything from documentation to experimental patches. It has all the latest features, but they may not be well tested so using trunk is more adventurous.

svn checkout svn://svn.openwrt.org/openwrt/trunk/

Troubleshooting

  • Beware of unusual environment variables such as
    • GREP_OPTIONS which should not have –initial-tab or other options affecting its output

Back to top

doc/howto/buildroot.exigence.txt · Last modified: 2012/02/13 12:02 by orca