Differences

This shows you the differences between two versions of the page.

doc:howto:build [2013/07/14 09:04]
lorema
doc:howto:build [2014/03/05 22:21] (current)
guraltsev swapped position of two paragraphs that were in the wrong order
Line 23: Line 23:
==== Updating Sources ==== ==== Updating Sources ====
You can check the currently installed revision with You can check the currently installed revision with
-<code bash>+<WRAP prewrap 1000px><code>
svn info svn info
-</code>+</code></WRAP>
Update sources: Update sources:
-<code bash>+<WRAP prewrap 1000px><code>
svn update svn update
-</code>+</code></WRAP>
//OpenWrt sources change frequently. It is recommended that you work with the latest sources.// //OpenWrt sources change frequently. It is recommended that you work with the latest sources.//
==== Updating Feeds ==== ==== Updating Feeds ====
-  - Update feeds: <code bash>./scripts/feeds update -a</code>+  - Update feeds: <WRAP prewrap 1000px><code>./scripts/feeds update -a</code></WRAP>
  - Make downloaded package/packages available in ''make menuconfig'':   - Make downloaded package/packages available in ''make menuconfig'':
-    * single package:<code bash>./scripts/feeds install <PACKAGENAME></code> +    * single package:<WRAP prewrap 1000px><code>./scripts/feeds install <PACKAGENAME></code></WRAP
-    * all packages:<code bash>./scripts/feeds install -a</code>+    * all packages:<WRAP prewrap 1000px><code>./scripts/feeds install -a</code></WRAP>
Please note that //installing// in context of ''./scripts/feeds'' script means "making package available in ''make menuconfig''" rather than really installing or compiling package. Please note that //installing// in context of ''./scripts/feeds'' script means "making package available in ''make menuconfig''" rather than really installing or compiling package.
Line 45: Line 45:
===== Image Configuration ===== ===== Image Configuration =====
==== Make menuconfig ==== ==== Make menuconfig ====
-The **OpenWrt Buildroot configuration interface** handles the selection of the target platform, packages to be compiled, packages to be included in the firmware file, some kernel options, etc. Start the OpenWrt Buildroot configuration interface by entering:\\ +The **OpenWrt Buildroot configuration interface** handles the selection of the target platform, packages to be compiled, packages to be included in the firmware file, some kernel options, etc. \\ Start the OpenWrt Buildroot configuration interface by issuing the following command:\\ 
-<code bash>+<WRAP prewrap 1000px><code>
make menuconfig make menuconfig
-</code>+</code></WRAP>
-This will update the dependencies of your existing configuration automatically and you can now proceed to build your updated images. +This will update the dependencies of your existing configuration automatically, and you can now proceed to build your updated images.
{{ OpenWrt Buildroot TUI.gif}} {{ OpenWrt Buildroot TUI.gif}}
-You have three options at most+You have three options: 
-**y**, **m**, **n** which are represented as follows: +''y'', ''m'', ''n'' which are represented as follows: 
-  * pressing <html><strong><kbd>y</kbd></strong></html> yields to ''**<*>**'' label \\ This package will be compiled and included in the firmware image file. +  * pressing ''**y**'' sets the ''**<*>**'' built-in label\\ This package will be compiled and included in the firmware image file. 
-  * pressing <html><strong><kbd>m</kbd></strong></html> yields to ''**<M>**'' label \\ This package will be compiled, but **not** included in the firmware image file. (E.g. to be installed with ''[[doc:techref:opkg]]'' after [[doc:howto:generic.flashing|flashing]] the firmware image file to the device.) +  * pressing ''**m**'' sets the ''**<M>**'' package label\\ This package will be compiled, but **not** included in the firmware image file. (E.g. to be installed with ''[[doc:techref:opkg]]'' after [[doc:howto:generic.flashing|flashing]] the firmware image file to the device.) 
-  * pressing <html><strong><kbd>n</kbd></strong></html> yields to ''**< >**'' label \\ The source code will not be processed.+  * pressing ''**n**'' sets the ''**< >**'' excluded label\\ The source code will not be processed.
When you save your configuration, the file **''<buildroot dir>/.config''** will be created according to your configuration. When you save your configuration, the file **''<buildroot dir>/.config''** will be created according to your configuration.
=== Explanations === === Explanations ===
-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:+It has been the intention from the beginning, with the development of ''menuconfig'', to create a simple, yet powerful, environment for the configuration of individual OpenWrt builds. ''menuconfig'' is more or less self-explanatory, and even the most specialized configuration requirements can be met by using it. Depending on the the particular target platform, package requirements and kernel module needs, the standard configuration process will include modifying:
  - Target system   - Target system
Line 72: Line 72:
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. 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 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.+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. Exit the TUI, and choose to ''save'' your settings.
Line 79: Line 79:
Note that ''make kernel_menuconfig'' modifies the Kernel configuration templates of the build tree and clearing the build_dir will not revert them: Note that ''make kernel_menuconfig'' modifies the Kernel configuration templates of the build tree and clearing the build_dir will not revert them:
-While you won't typically need to do this, you can do it:<code bash>+While you won't typically need to do this, you can do it: 
 +<WRAP prewrap 1000px><code>
make kernel_menuconfig make kernel_menuconfig
-</code> +</code></WRAP
-The changes can be reviewed with <code bash>svn diff target/linux/</code> and reverted with <code bash>svn revert -R target/linux/</code>.+The changes can be reviewed with 
 +<WRAP prewrap 1000px><code> 
 +svn diff target/linux/ 
 +</code></WRAP> 
 +and reverted with  
 +<WRAP prewrap 1000px><code> 
 +svn revert -R target/linux/ 
 +</code></WRAP>
Line 109: Line 117:
  * ''**<buildroot dir>/files/**etc/config/firewall''   * ''**<buildroot dir>/files/**etc/config/firewall''
  * ''**<buildroot dir>/files/**etc/sysctl.conf''   * ''**<buildroot dir>/files/**etc/sysctl.conf''
 +
 +E.g. if your <buildroot dir> is /openwrt/trunk and you want some files to be copied into firmware image's /etc/config directory, the correct place to put them is /openwrt/trunk/files/etc/config.
==== Defconfig ==== ==== Defconfig ====
[[https://forum.openwrt.org/viewtopic.php?pid=140470#p140470|select your target before issuing defconfig]] [[https://forum.openwrt.org/viewtopic.php?pid=140470#p140470|select your target before issuing defconfig]]
-<code bash>+<WRAP prewrap 1000px><code>
make defconfig make defconfig
-</code>+</code></WRAP>
will produce a general purpose configuration of the build system including a check of dependencies and prerequisites for the build environment etc will produce a general purpose configuration of the build system including a check of dependencies and prerequisites for the build environment etc
Line 122: Line 132:
Everything is now ready for building the image(s), which is done with one single command: Everything is now ready for building the image(s), which is done with one single command:
-<code bash>+<WRAP prewrap 1000px><code>
make make
-</code>+</code></WRAP>
This simple command will trigger a cascade of activity. As already stated, it will This simple command will trigger a cascade of activity. As already stated, it will
Line 130: Line 140:
  - then crosscompile the sources with this toolchain   - then crosscompile the sources with this toolchain
  - create opkg-packages   - create opkg-packages
-  - genrate a firmware image file ready to be [[generic.flashing|flashed]].+  - generate a firmware image file ready to be [[generic.flashing|flashed]].
==== Make options ==== ==== Make options ====
Line 137: Line 147:
The build process can be accelerated by running multiple concurrent job processes using the ''-j''-option: The build process can be accelerated by running multiple concurrent job processes using the ''-j''-option:
-<code bash>+<WRAP prewrap 1000px><code>
make -j 3 make -j 3
-</code>+</code></WRAP>
  * Use the standard formula ''<your number of CPU cores + 1>''   * Use the standard formula ''<your number of CPU cores + 1>''
  * If this produces random build errors try compiling again without the ''-j''-option   * If this produces random build errors try compiling again without the ''-j''-option
Line 146: Line 156:
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): 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):
-<code bash>+<WRAP prewrap 1000px><code>
ionice -c 3 nice -n19 make -j 2 ionice -c 3 nice -n19 make -j 2
-</code>+</code></WRAP>
=== Building single Packages === === Building single Packages ===
When developing or packaging software for OpenWrt, it is convenient to be able to build only the package in question (e.g. with package ''cups''): When developing or packaging software for OpenWrt, it is convenient to be able to build only the package in question (e.g. with package ''cups''):
-<code bash>+<WRAP prewrap 1000px><code>
make package/cups/compile V=s make package/cups/compile V=s
-</code>+</code></WRAP>
For the package ''mc (midnight commander)'', which is contained the feed //packages// it looks like this: For the package ''mc (midnight commander)'', which is contained the feed //packages// it looks like this:
-<code bash>+<WRAP prewrap 1000px><code>
make package/feeds/packages/mc/compile V=s make package/feeds/packages/mc/compile V=s
-</code>+</code></WRAP>
//Note that the path start in ''package'' directory and ''package/feeds'' may not have exactly the same structure as ''feeds''. For example package in ''~/openwrt/trunk/feeds/packages/**net**/snort'' will be compiled using ''make ~/openwrt/trunk/**package**/feeds/packages/snort/**compile** V=s''.// //Note that the path start in ''package'' directory and ''package/feeds'' may not have exactly the same structure as ''feeds''. For example package in ''~/openwrt/trunk/feeds/packages/**net**/snort'' will be compiled using ''make ~/openwrt/trunk/**package**/feeds/packages/snort/**compile** V=s''.//
Line 169: Line 179:
If for some reason the build fails, the easiest way to spot the error is to do: If for some reason the build fails, the easiest way to spot the error is to do:
-<code bash>+<WRAP prewrap 1000px><code>
make V=s 2>&1 | tee build.log | grep -i error make V=s 2>&1 | tee build.log | grep -i error
-</code>+</code></WRAP>
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. 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.
Line 177: Line 187:
Another example: Another example:
-<code bash>+<WRAP prewrap 1000px><code>
ionice -c 3 nice -n 20 make -j 2 V=s CONFIG_DEBUG_SECTION_MISMATCH=y 2>&1 | tee build.log | egrep -i '(warn|error)' ionice -c 3 nice -n 20 make -j 2 V=s CONFIG_DEBUG_SECTION_MISMATCH=y 2>&1 | tee build.log | egrep -i '(warn|error)'
-</code>+</code></WRAP> 
 + 
 +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.
Yet another way to focus on the problem without having to wade through tons of output from Make as described above is to check the corresponding log in 'logs' folder. Yet another way to focus on the problem without having to wade through tons of output from Make as described above is to check the corresponding log in 'logs' folder.
IE: if the build fails at "make[3] -C package/kernel/mac80211 compile", then you can go to <buildroot>/logs/package/kernel/mac80211 and view the compile.txt found there. IE: if the build fails at "make[3] -C package/kernel/mac80211 compile", then you can go to <buildroot>/logs/package/kernel/mac80211 and view the compile.txt found there.
- 
-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. 
=== Getting beep notification === === Getting beep notification ===
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''': 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''':
-<code bash>+<WRAP prewrap 1000px><code>
make V=s ; echo -e '\a' make V=s ; echo -e '\a'
-</code>+</code></WRAP>
===== Locating Images ===== ===== Locating Images =====
Line 202: Line 212:
==== Clean ==== ==== Clean ====
-<code bash>+<WRAP prewrap 1000px><code>
make clean make clean
-</code>+</code></WRAP>
deletes contents of the directories ''/bin'' and ''/build_dir''. deletes contents of the directories ''/bin'' and ''/build_dir''.
Line 210: Line 220:
==== Dirclean ==== ==== Dirclean ====
-<code bash>+<WRAP prewrap 1000px><code>
make dirclean make dirclean
-</code>+</code></WRAP>
deletes contents of the directories ''/bin'' and ''/build_dir'' and additionally ''/staging_dir'' and ''/toolchain'' (=the cross-compile tools) and ''/logs''. 'Dirclean' is your basic "Full clean" operation. deletes contents of the directories ''/bin'' and ''/build_dir'' and additionally ''/staging_dir'' and ''/toolchain'' (=the cross-compile tools) and ''/logs''. 'Dirclean' is your basic "Full clean" operation.
Line 218: Line 228:
==== Distclean ==== ==== Distclean ====
-<code bash>+<WRAP prewrap 1000px><code>
make distclean make distclean
-</code>+</code></WRAP>
nukes everything you have compiled or configured and also deletes all downloaded feeds contents and package sources. nukes everything you have compiled or configured and also deletes all downloaded feeds contents and package sources.
Line 229: Line 239:
There are numerous other functionalities in the OpenWrt build system, but the above should have covered some of the fundamentals. There are numerous other functionalities in the OpenWrt build system, but the above should have covered some of the fundamentals.
 +==== Clean small part ====
 +In more time, you may not want to clean so many objects, then you can use some of the commands below to do it.
 +
 +Clean linux objects.
 +<WRAP prewrap 1000px><code>
 +make target/linux/clean
 +</code></WRAP>
 +
 +Clean package base-files objects.
 +<WRAP prewrap 1000px><code>
 +make package/base-files/clean
 +</code></WRAP>
 +
 +Clean luci.
 +<WRAP prewrap 1000px><code>
 +make package/feeds/luci/luci/clean
 +</code></WRAP>
===== Examples ===== ===== Examples =====
Line 254: Line 281:
==== I can't find my <package> in menuconfig ==== ==== I can't find my <package> in menuconfig ====
-  - Have you run this command? [[doc:howto:build#updating.feeds|See this.]] <code bash>./scripts/feeds install <package></code> +  - Have you run this command? [[doc:howto:build#updating.feeds|See this.]] <WRAP prewrap 1000px><code>./scripts/feeds install <package></code></WRAP
-  - Maybe you are not looking for it in the right submenu. See the ''Makefile'' of the package to find out. <code bash>cat package/feeds/packages/<package>/Makefile</code> You are looking for this: \\ ''define Package/<package>/Default+  - Maybe you are not looking for it in the right submenu. See the ''Makefile'' of the package to find out. <WRAP prewrap 1000px><code>cat package/feeds/packages/<package>/Makefile</code></WRAP> You are looking for this: \\ ''define Package/<package>/Default
  SUBMENU:=**Firewall**   SUBMENU:=**Firewall**
  SECTION:=net   SECTION:=net
  CATEGORY:=**Network**''   CATEGORY:=**Network**''
-  - Menuconfig appears to cache package lists and (especially) profiles. Try deleting the ''<buildroot_dir>/tmp'' directory and then running ''make menuconfig'' again. <code bash>+  - Menuconfig appears to cache package lists and (especially) profiles. Try deleting the ''<buildroot_dir>/tmp'' directory and then running ''make menuconfig'' again. <WRAP prewrap 1000px><code>
cd ~/openwrt/trunk cd ~/openwrt/trunk
rm -rf tmp rm -rf tmp
-make menuconfig</code> Also try refreshing your package indexes: <code bash>./scripts/feeds update -i</code> The ''-i'' is important if you're not using the latest revisions of any packages, as this flag prevents updates from the feed sources.+make menuconfig</code></WRAP> Also try refreshing your package indexes: <WRAP prewrap 1000px><code>./scripts/feeds update -i</code></WRAP> The ''-i'' is important if you're not using the latest revisions of any packages, as this flag prevents updates from the feed sources.
====  Error: No rule to make target... ==== ====  Error: No rule to make target... ====

Back to top

doc/howto/build.1373785464.txt.bz2 · Last modified: 2013/07/14 09:04 by lorema