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/10/20 12:16] (current)
bastian.bittorf explain what 'clean' does not, see https://dev.openwrt.org/ticket/18171#comment:1
Line 9: Line 9:
    * ''SED'' should not be set.  If it is, run ''`unset SED`'' before compiling. (See [[https://dev.openwrt.org/ticket/10612|Ticket 10612]].)     * ''SED'' should not be set.  If it is, run ''`unset SED`'' before compiling. (See [[https://dev.openwrt.org/ticket/10612|Ticket 10612]].)
    * ''GREP_OPTIONS'' should not have ''--initial-tab'' or other options affecting its output     * ''GREP_OPTIONS'' should not have ''--initial-tab'' or other options affecting its output
 +    * Add ''<buildroot dir>/staging_dir/host/bin'' and ''<buildroot dir>/staging_dir/toolchain-<platform>-<gcc_ver>-<libc_ver>/bin'' in front of your ''PATH'' variable in ''~/.bashrc''. The staging directory is created shortly after starting the build and the toolchain directory is created when the toolchain build begins. The build spawns multiple shells, some of which expect the toolchain binaries to be present in the ''PATH''.
===== Procedure ===== ===== Procedure =====
Line 22: Line 23:
==== Updating Sources ==== ==== Updating Sources ====
-You can check the currently installed revision with +You can perform a new check out of trunk with (for instance) 
-<code bash>+<code> 
 +svn co svn://svn.openwrt.org/openwrt/trunk/ trunk 
 +</code> 
 + 
 +Instructions with Git repos can be found under https://dev.openwrt.org/wiki/GetSource 
 + 
 +You can check out a currently installed revision with  
 +<code>
svn info svn info
</code> </code>
Line 29: Line 37:
Update sources: Update sources:
-<code bash>+<code>
svn update svn update
</code> </code>
Line 36: Line 44:
==== Updating Feeds ==== ==== Updating Feeds ====
-  - Update feeds: <code bash>./scripts/feeds update -a</code>+  - Update feeds: <code>./scripts/feeds update -a</code>
  - 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:<code>./scripts/feeds install <PACKAGENAME></code> 
-    * all packages:<code bash>./scripts/feeds install -a</code>+    * all packages:<code>./scripts/feeds install -a</code>
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 53:
===== 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>+<code>
make menuconfig make menuconfig
</code> </code>
-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 80:
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 87:
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: 
 +<code>
make kernel_menuconfig make kernel_menuconfig
</code> </code>
-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 
 +<code> 
 +svn diff target/linux/ 
 +</code> 
 +and reverted with  
 +<code> 
 +svn revert -R target/linux/ 
 +</code>
Line 109: Line 125:
  * ''**<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>+<code>
make defconfig make defconfig
</code> </code>
Line 122: Line 140:
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>+<code>
make make
</code> </code>
Line 130: Line 148:
  - 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 ====
=== Building on multi-core CPU === === Building on multi-core CPU ===
-**Build may FAIL**+:!: **Build may FAIL**
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>+<code>
make -j 3 make -j 3
</code> </code>
Line 146: Line 164:
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>+<code>
ionice -c 3 nice -n19 make -j 2 ionice -c 3 nice -n19 make -j 2
</code> </code>
Line 153: Line 171:
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>+<code>
make package/cups/compile V=s make package/cups/compile V=s
</code> </code>
-For the package ''mc (midnight commander)'', which is contained the feed //packages// it looks like this+For a rebuild
-<code bash+<code> 
-make package/feeds/packages/mc/compile V=s+make package/cups/{clean,compile,install} V=s
</code> </code>
-//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''.// +It doesn't matter what feed the package is located in, this same syntax works for any installed package.
- +
=== Spotting build errors === === Spotting build errors ===
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>+<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>
Line 177: Line 193:
Another example: Another example:
-<code bash>+<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>
 +
 +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>+<code>
make V=s ; echo -e '\a' make V=s ; echo -e '\a'
</code> </code>
Line 202: Line 218:
==== Clean ==== ==== Clean ====
-<code bash>+<code>
make clean make clean
</code> </code>
deletes contents of the directories ''/bin'' and ''/build_dir''. deletes contents of the directories ''/bin'' and ''/build_dir''.
 +make clean does not remove the toolchain, 
 +it also avoids cleaning architectures/targets other than the one you have selected in your ''.config''
==== Dirclean ==== ==== Dirclean ====
-<code bash>+<code>
make dirclean make dirclean
</code> </code>
Line 218: Line 235:
==== Distclean ==== ==== Distclean ====
-<code bash>+<code>
make distclean make distclean
</code> </code>
Line 229: Line 246:
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.
 +<code>
 +make target/linux/clean
 +</code>
 +
 +Clean package base-files objects.
 +<code>
 +make package/base-files/clean
 +</code>
 +
 +Clean luci.
 +<code>
 +make package/luci/clean
 +</code>
===== Examples ===== ===== Examples =====
Line 237: Line 271:
===== Troubleshooting ===== ===== Troubleshooting =====
First get more information on the problem using the make option ''"make V=s"''. First get more information on the problem using the make option ''"make V=s"''.
 +
 +
 +==== Errors building gcc ====
 +If the build fails with errors that include "[s-attrib] Killed" and "[all-gcc] Error 2" while compiling gcc, this indicates you are out of disk space or RAM. This could be likely if you are building within a virtual machine with < 1 Gb RAM allocated and no swap.
==== Missing source code file, due to download problems ==== ==== Missing source code file, due to download problems ====
Line 248: Line 286:
Compiling with make -j ... sometimes gives random errors. Try compiling without -j first before reporting the problem. Compiling with make -j ... sometimes gives random errors. Try compiling without -j first before reporting the problem.
-====  Bad environment variables ==== +
-  * ''GREP_OPTIONS'' should not have ''--initial-tab'' or other options affecting its output +
-  * **''SED'' should not be set.  If it is, run `unset SED` before compiling.** (See [[https://dev.openwrt.org/ticket/10612|Ticket 10612]].) +
-  * others?+
==== 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.]] <code>./scripts/feeds install <package></code> 
-  - 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. <code>cat feeds/<feedname>/<package>/Makefile</code> 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. <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> Also try refreshing your package indexes: <code>./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.
- +
-====  Error: No rule to make target... ==== +
-Make sure the path starts with ''package'' directory and that the path actually exist. The structure of ''feeds'' and ''package/feeds'' directory is different. [[doc:howto:build#building.single.packages|See this.]] +
-  * Wrong: ''make feeds/packages/**utils**/screen/compile V=s'' +
-  * Correct: ''make **package**/feeds/packages/screen/compile V=s''+
==== WARNING: skipping <package> -- package not selected ==== ==== WARNING: skipping <package> -- package not selected ====

Back to top

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