- 在你的电脑上安装OpenWrt Buildroot和它的先决条件。
- 更新feeds的package 包.
./scripts/feeds update -a
./scripts/feeds install -a (或者 'install <PACKAGENAME>' )
|同配置Linux内核类似，几乎每一个设置都有三个选项:y / m / n，分别代表如下含义：
* `` (按下`y`)这个包会被包含进固件镜像
* `` (按下`m`)这个包会在生成刷新OpenWrt的镜像文件以后被编译，但是不会被包含进镜像文件
* `` (按下`n`)这个包不会被编译
\\编译环境会提供一个这样的配置文件给OpenWrt 'Backfire' 10.03.1-RC5。 例如，for ar71xx.
It has from the beginning on been the intention, with the development of 'menuconfig', to create a simple yet powerful environment for the configuration of individual OpenWrt images. Menuconfig is more or less self-explanatory, and even the most specialized configuration needs can be solved with its help. Depending on the the particular target platform, package requirements and kernel module needs, the standard process of configuration will include modifying:
- Package selection
- Build system settings
Target system is selected from the extensive list of supported platforms, with the numerous target profiles – ranging from specific devices to generic profiles, all depending on the particular device at hand. Package selection has the option of either 'selecting all package', which might be un-practical in certain situation, or relying on the default set of packages will be adequate or make an individual selection. It is here needed to mention that some package combinations might break the build process, so it can take some experimentation before the expected result is reached. Added to this, the OpenWrt developers are themselves only maintaining a smaller set of packages – which includes all default packages – but, the feeds-script makes it very simple to handle a locally maintained set of packages and integrate them in the build-process.
- < > the source code will not be processed
- <M> the source code of the package will be crosscompiled into binaries and a opkg package will be built and placed in
/buildsystem/bla/bla/bla, but the ImageGenerator will not put it onto the Firmware-Image!
- <*> that the package will built into the firmware (on the SqashFS partition)
The final step before the process of compiling the intended image(s) is to exit 'menuconfig' – this also includes the option to save a specific configuration or load an already existing, and pre-configured, version.
Exit the TUI, and choose to
save your settings.
While you won't typically need to do this, you can do it:
The 'Build system settings' include some efficient options for changing package locations which makes it easy to handle a local package set:
- Local mirror for source packages
- Download folder
In the case of the first option, you simply enter a full URL to the web or ftp server on which the package sources are hosted. Download folder would in the same way be the path to a local folder on the build system (or network). If you have a web/ftp-server hosting the tarballs, the OpenWrt build system will try this one before trying to download from the location(s) mentioned in the Makefiles . Similar if a local 'download folder', residing on the build system, has been specified.
The 'Kernel modules' option is required if you need specific (non-standard) drivers and so forth – this would typically be things like modules for USB or particular network interface drivers etc.
In many cases, you may want to have a custom image that has been pre-configured to your link. If so, place your custom files in
For example, let's say that you want an image with a pre-configured
/etc/config/firewall, then place your modified firewall config in here:
Everything is now ready for building the image(s), which is done with one single command:
This simple command will trigger a cascade of activity. As already stated, it will
- compile the toolchain
- then crosscompile the sources with this toolchain
- create opkg-packages
- create a firmware image file ready to be flashed.
The build process can be accelerated by running multiple concurrent job processes using the
make -j 3
- Use the standard formula
<your number of CPUs + 1>
- If this produces random build errors try compiling again without the
If you intend to use your system while building, you can have the build process use only idle I/O and CPU capacity like this (dualcore CPU):
ionice -c 3 nice -n 20 make -j 2
When developing or packaging software for OpenWrt, it is convenient to be able to build only the package in question (e.g. with package
make package/cups/compile V=99
For the package
mc (midnight commander), which is contained the feed packages it looks like this:
make package/feeds/packages/mc/compile v=99
If for some reason the build fails, the easiest way to spot the error is to do:
make V=99 2>&1 | tee build.log | grep -i error
The above saves a full verbose copy of the build output (with stdout piped to stderr) in
/openwrt/trunk/build.log and only shows errors on the screen.
ionice -c 3 nice -n 20 make -j 2 V=99 CONFIG_DEBUG_SECTION_MISMATCH=y 2>&1 | tee build.log | egrep -i '(warn|error)'
yet another one:
somthing something screen
The above saves a full verbose copy of the build output (with stdout piped to stderr) in build.log and outputs only warnings and errors while building using only background resources on a dual core CPU.
Depending on your CPU, the process will take a while, or while longer. If you want an acoustic notification, you could use
echo -e '\a':
make V=99 ; echo -e '\a'
cd ~/openwrt/trunk/bin ls */
You might need to clean your build environment every now and then. The following
make-targets are useful for that job:
deletes contents of
deletes contents of
/build_dir directories and additionally
/toolchain (=the cross-compile tools). 'Dirclean' is your basic "Full clean" operation.
nukes everything you have compiled or configured and also deletes all downloaded feeds contents and package sources.
CAUTION: In addition to all else, this will erase your build configuration (.config), your toolchain and all other sources. Use with care!
There are numerous other functionalities in the OpenWrt build system, but the above should have covered some of the fundamentals.
First get more information on the problem using the make option "make V=99".
- Missing source code file, due to download problems.
First check if the URL path in the make file contains a trailing slash, then try with it removed (helped several times). Otherwise try to download the source code manually and put it into "dl" directory
- Compilation errors.
Try to update the main source and all the feeds (Warning! May result in other problems). Check for a related bug in (TRAC), use the filters to find it. Otherwise report the problem there, by mentioning the package, the target data (CPU, image, etc.) and the code revisions (main & package). Compiling with make -j … sometimes gives random errors. Try compiling without -j first before reporting the problem.
zh-cn/doc/howto/build.txt · Last modified: 2013/12/26 04:07 by leangjia