Openwrt missing documentation


I think this belongs in the Documentation found at under both user guide and developer guide. I found this document in a kamikaze source tarball I downloaded from Netgear for the WNDR4300v2 after compiling the documentation it referred to.

Search google for openwrt.pdf . One link that currently works is .

New driver configuration seems valuable
'Adding a new driver configuration Since we currently only support thread
different wireless drivers : Broadcom, Atheros and mac80211, you might be interested in adding support for another driver like Ralink RT2x00, Texas Instruments ACX100/111.
The driver specific script should be placed in /lib/wifi/.sh and has
to include several functions providing :
• detection of the driver presence
• enabling/disabling the wifi interface(s)
• configuration reading and setting
• third-party programs calling (nas, supplicant)
Each driver script should append the driver to a global DRIVERS variable :
append DRIVERS "driver name"
scan_ This function will parse the /etc/config/wireless and make
sure there are no configuration incompatibilities, like enabling hidden SSIDS
with ad-hoc mode for instance. This can be more complex if your driver supports
a lof of configuration options. It does not change the state of the interface.
scan_dummy() {
local device="$1"
config_get vifs "$device" vifs
for vif in $vifs; do

check config consistency for wifi-iface sections


check mode combination

enable_ This function will bring up the wifi device and optionally
create application specific configuration files, e.g. for the WPA authenticator or
enable_dummy() {
local device="$1"
config_get vifs "$device" vifs
for vif in $vifs; do

bring up virtual interface belonging to

the wifi-device "$device"

disable_ This function will bring down the wifi device and all its
virtual interfaces (if supported).
disable_dummy() {
local device="$1"

bring down virtual interfaces belonging to

"$device" regardless of whether they are

configured or not. Don’t rely on the vifs

variable at this point

detect_ This function looks for interfaces that are usable with the
driver. Template config sections for new devices should be written to stdout.
Must check for already existing config sections belonging to the interfaces before
creating new templates.
detect_dummy() {
[ wifi-device = "$(config_get dummydev type)" ] && return 0
cat <<EOF
config wifi-device dummydev
option type dummy


option disabled 1
config wifi-iface
option device dummydev
option mode ap
option ssid OpenWrt

Chapter 2 on build/compile issues is a great resource especially for a beginner like me. Here is a snippet.

Chapter 2
Development issues
2.1 The build system
One of the biggest challenges to getting started with embedded devices is that
you cannot just install a copy of Linux and expect to be able to compile a
firmware. Even if you did remember to install a compiler and every development
tool offered, you still would not have the basic set of tools needed to produce
a firmware image. The embedded device represents an entirely new hardware
platform, which is most of the time incompatible with the hardware on your
development machine, so in a process called cross compiling you need to produce
a new compiler capable of generating code for your embedded platform, and then
use it to compile a basic Linux distribution to run on your device.
The process of creating a cross compiler can be tricky, it is not something that is
regularly attempted and so there is a certain amount of mystery and black magic
associated with it. In many cases when you are dealing with embedded devices
you will be provided with a binary copy of a compiler and basic libraries rather
than instructions for creating your own – it is a time saving step but at the same
time often means you will be using a rather dated set of tools. Likewise, it is
also common to be provided with a patched copy of the Linux kernel from the
board or chip vendor, but this is also dated and it can be difficult to spot exactly
what has been modified to make the kernel run on the embedded platform.
2.1.1 Building an image
OpenWrt takes a different approach to building a firmware; downloading, patching and compiling everything from scratch, including the cross compiler. To put
it in simpler terms, OpenWrt does not contain any executables or even sources,
it is an automated system for downloading the sources, patching them to work
with the given platform and compiling them correctly for that platform. What
this means is that just by changing the template, you can change any step in
the process.
As an example, if a new kernel is released, a simple change to one of the Makefiles
will download the latest kernel, patch it to run on the embedded platform and
produce a new firmware image – there is no work to be done trying to track down
an unmodified copy of the existing kernel to see what changes had been made,
the patches are already provided and the process ends up almost completely
transparent. This does not just apply to the kernel, but to anything included
with OpenWrt – It is this one simple understated concept which is what allows
OpenWrt to stay on the bleeding edge with the latest compilers, latest kernels
and latest applications.
So let’s take a look at OpenWrt and see how this all works.
Download OpenWrt
This article refers to the ”Kamikaze” branch of OpenWrt, which can be downloaded via subversion using the following command:
$ svn checkout svn:// kamikaze
Additionally, there is a trac interface on which can be
used to monitor svn commits and browse the source repository.
The directory structure
There are four key directories in the base:
• tools
• toolchain
• package
• target
tools and toolchain refer to common tools which will be used to build the
firmware image, the compiler, and the C library. The result of this is three
new directories, build_dir/host, which is a temporary directory for building
the target independent tools, build_dir/toolchain- * which is used for
building the toolchain for a specific architecture, and staging_dir/toolchain-
* where the resulting toolchain is installed. You will not need to do
anything with the toolchain directory unless you intend to add a new version of
one of the components above.
• build_dir/host
• build_dir/toolchain- *
package is for exactly that – packages. In an OpenWrt firmware, almost everything is an .ipk, a software package which can be added to the firmware
to provide new features or removed to save space. Note that packages are also
maintained outside of the main trunk and can be obtained from subversion using
the package feeds system:
$ ./scripts/feeds update
Those packages can be used to extend the functionality of the build system and
need to be symlinked into the main trunk. Once you do that, the packages will
show up in the menu for configuration. From kamikaze you would do something
like this:
$ ./scripts/feeds search nmap
Search results in feed ’packages’:
nmap Network exploration and/or security auditing utility
$ ./scripts/feeds install nmap
To include all packages, issue the following command:
$ make package/symlinks
target refers to the embedded platform, this contains items which are specific to
a specific embedded platform. Of particular interest here is the ”target/linux”
directory which is broken down by platform and contains the patches to
the kernel, profile config, for a particular platform. There’s also the ”target/image”
directory which describes how to package a firmware for a specific platform.
Both the target and package steps will use the directory ”build_dir/ ”
as a temporary directory for compiling. Additionally, anything downloaded by
the toolchain, target or package steps will be placed in the ”dl” directory.
• build_dir/
• dl
Building OpenWrt
While the OpenWrt build environment was intended mostly for developers, it
also has to be simple enough that an inexperienced end user can easily build his
or her own customized firmware.
Running the command ”make menuconfig” will bring up OpenWrt’s configuration menu screen, through this menu you can select which platform you’re
targeting, which versions of the toolchain you want to use to build and what
packages you want to install into the firmware image. Note that it will also
check to make sure you have the basic dependencies for it to run correctly. If
that fails, you will need to install some more tools in your local environment
before you can begin.
Similar to the linux kernel config, almost every option has three choices, y/m/n
which are represented as follows:
• <> (pressing y)
This will be included in the firmware image
• (pressing m)
This will be compiled but not included (for later install)
• < > (pressing n)
This will not be compiled
After you’ve finished with the menu configuration, exit and when prompted,
save your configuration changes.
If you want, you can also modify the kernel config for the selected target system. simply run ”make kernel_menuconfig” and the build system will unpack
the kernel sources (if necessary), run menuconfig inside of the kernel tree, and
then copy the kernel config to target/linux/ /config so that it is
preserved over ”make clean” calls.
To begin compiling the firmware, type ”make”. By default OpenWrt will only
display a high level overview of the compile process and not each individual
make[2] toolchain/install
make[3] -C toolchain install
make[2] target/compile
make[3] -C target compile
make[4] -C target/utils prepare
This makes it easier to monitor which step it’s actually compiling and reduces
the amount of noise caused by the compile output. To see the full output, run
the command ”make V=99”.
During the build process, buildroot will download all sources to the ”dl” directory and will start patching and compiling them in the ”build_dir/ ”
directory. When finished, the resulting firmware will be in the ”bin” directory
and packages will be in the ”bin/packages” directory.
2.1.2 Creating packages
One of the things that we’ve attempted to do with OpenWrt’s template system
is make it incredibly easy to port software to OpenWrt. If you look at a typical
package directory in OpenWrt you’ll find two things:
• package/ /Makefile
• package/ /patches
• package/ /files
The patches directory is optional and typically contains bug fixes or optimizations to reduce the size of the executable. The package makefile is the important
item, provides the steps actually needed to download and compile the package.
The files directory is also optional and typicall contains package specific startup
scripts or default configuration files that can be used out of the box with OpenWrt.
Looking at one of the package makefiles, you’d hardly recognize it as a makefile.
Through what can only be described as blatant disregard and abuse of the traditional make format, the makefile has been transformed into an object oriented
template which simplifies the entire ordeal.
Here for example, is package/bridge/Makefile:
1 # $Id: Makefile 5624 2006-11-23 00:29:07Z nbd $
3 include $(TOPDIR)/
5 PKG_NAME:=bridge
6 PKG_VERSION:=1.0.6
9 PKG_SOURCE:=bridge-utils-$(PKG_VERSION).tar.gz
10 PKG_SOURCE_URL:=@SF/bridge
11 PKG_MD5SUM:=9b7dc52656f5cbec846a7ba3299f73bd
12 PKG_CAT:=zcat
14 PKG_BUILD_DIR:=$(BUILD_DIR)/bridge-utils-$(PKG_VERSION)
16 include $(INCLUDE_DIR)/
18 define Package/bridge
19 SECTION:=net
20 CATEGORY:=Base system
21 TITLE:=Ethernet bridging configuration utility
22 URL:=
23 endef
25 define Package/bridge/description
26 Manage ethernet bridging:
27 a way to connect networks together to form a larger network.
28 endef
30 define Build/Configure
31 $(call Build/Configure/Default,
32 --with-linux-headers="$(LINUX_DIR)"
33 )
34 endef
36 define Package/bridge/install
37 $(INSTALL_DIR) $(1)/usr/sbin
38 $(INSTALL_BIN) $(PKG_BUILD_DIR)/brctl/brctl $(1)/usr/sbin/
39 endef
41 $(eval $(call BuildPackage,bridge))
As you can see, there’s not much work to be done; everything is hidden in other
makefiles and abstracted to the point where you only need to specify a few
The name of the package, as seen via menuconfig and ipkg
The upstream version number that we are downloading
The version of this package Makefile
The filename of the original sources
Where to download the sources from (no trailing slash), you can add
multiple download sources by separating them with a
and a carriage return.
A checksum to validate the download
How to decompress the sources (zcat, bzcat, unzip)
Where to compile the package
The PKG_
variables define where to download the package from; @SF is a special
keyword for downloading packages from sourceforge. There is also another keyword of @GNU for grabbing GNU source releases. If any of the above mentionned
download source fails, the OpenWrt mirrors will be used as source.
The md5sum (if present) is used to verify the package was downloaded correctly
and PKG_BUILD_DIR defines where to find the package after the sources are
uncompressed into $(BUILD_DIR).
At the bottom of the file is where the real magic happens, ”BuildPackage” is a
macro set up by the earlier include statements. BuildPackage only takes one
argument directly – the name of the package to be built, in this case ”bridge”.
All other information is taken from the define blocks. This is a way of providing
a level of verbosity, it’s inherently clear what the contents of the description
template in Package/bridge is, which wouldn’t be the case if we passed this
information directly as the Nth argument to BuildPackage.

Peace and respect

(Moved to the Talk about Documentation section.)

Hopefully you noticed that Kamikaze and that document are from year 2008 and e.g. refers to fetching sources via SVN instead of git.

Ancient stuff, and more current docs about the same things are already in wiki.

Yes, I noticed. You seem to be right. This info does not seem to apply to the current generation builds.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.