Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| docs:guide-developer:toolchain:use-buildsystem [2021/10/15 08:26] – ↷ Page moved from docs:guide-developer:build-system:use-buildsystem to docs:guide-developer:toolchain:use-buildsystem bobafetthotmail | docs:guide-developer:toolchain:use-buildsystem [2024/10/16 18:12] (current) – [Build system usage] jannoke | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Build system usage ====== | ====== Build system usage ====== | ||
| <WRAP important> | <WRAP important> | ||
| - | * Do everything as a normal | + | * Do everything as an unprivileged |
| - | * Do not build in a directory that has spaces in its full path. | + | * Make sure there are no spaces in the full path to the build directory. |
| </ | </ | ||
| - | Typical build steps in a [[docs: | + | <WRAP important> |
| + | There is an issue affecting the current OpenWrt source tree (from at least 21.02 onwards): OpenWrt images built in certain setups will succeed, but they will hang on boot if installed on a device. To work around this issue, please follow the instructions posted [[https:// | ||
| + | </ | ||
| + | |||
| + | After [[docs: | ||
| <code bash> | <code bash> | ||
| # Download and update the sources | # Download and update the sources | ||
| - | git clone https:// | + | git clone https:// |
| cd openwrt | cd openwrt | ||
| git pull | git pull | ||
| Line 16: | Line 20: | ||
| git branch -a | git branch -a | ||
| git tag | git tag | ||
| - | git checkout | + | git checkout |
| # Update the feeds | # Update the feeds | ||
| Line 22: | Line 26: | ||
| ./ | ./ | ||
| - | # Configure the firmware image and the kernel | + | # Configure the firmware image |
| make menuconfig | make menuconfig | ||
| - | make kernel_menuconfig | + | |
| + | # Optional: configure the kernel (usually not required) | ||
| + | # Don't, unless have a strong reason to | ||
| + | make -j$(nproc) | ||
| # Build the firmware image | # Build the firmware image | ||
| - | make -j $(nproc) defconfig download clean world | + | make -j$(nproc) defconfig download clean world |
| </ | </ | ||
| Line 93: | Line 100: | ||
| - Create a dir: '' | - Create a dir: '' | ||
| - Write a Makefile or download one '' | - Write a Makefile or download one '' | ||
| - | - Append a line with your custom feed to '' | + | - Append a line with your custom feed to '' |
| - Now run: '' | - Now run: '' | ||
| - | - Build your package.\\ Select it in the menu of '' | + | - Build your package.\\ Select it in the menu of '' |
| ===== Selecting code revision ===== | ===== Selecting code revision ===== | ||
| Line 128: | Line 135: | ||
| git tag | git tag | ||
| - | # Use OpenWrt 21.02.0 release | + | # Use OpenWrt 21.02.1 release |
| - | git checkout v21.02.0 | + | git checkout v21.02.1 |
| </ | </ | ||
| Line 139: | Line 146: | ||
| git checkout ${REV_HASH} | git checkout ${REV_HASH} | ||
| REV_BRANCH=" | REV_BRANCH=" | ||
| + | |||
| + | # Replace all src-git with src-git-full: | ||
| sed -e "/ | sed -e "/ | ||
| + | |||
| ./ | ./ | ||
| + | |||
| + | # Edit every line of feeds.conf in a loop to set the chosen revision hash | ||
| sed -n -e "/ | sed -n -e "/ | ||
| | while read -r FEED_ID | | while read -r FEED_ID | ||
| Line 148: | Line 160: | ||
| sed -i -e "/ | sed -i -e "/ | ||
| done | done | ||
| + | |||
| ./ | ./ | ||
| ./ | ./ | ||
| Line 155: | Line 168: | ||
| Compile OpenWrt in a way that it gets [[https:// | Compile OpenWrt in a way that it gets [[https:// | ||
| + | For example if you are flashing for the [[toh: | ||
| + | |||
| + | ' | ||
| + | |||
| + | Download the config by removing everything up to the subtarget ' | ||
| <code bash> | <code bash> | ||
| # OpenWrt 19.07 and later | # OpenWrt 19.07 and later | ||
| - | wget https:// | + | wget https:// |
| # OpenWrt 18.06 and before | # OpenWrt 18.06 and before | ||
| wget https:// | wget https:// | ||
| </ | </ | ||
| + | |||
| + | When using this configuration the correct defaults will be already selected for the Target and Subtarget but **not** for the Target profile so you will have to tailor it for the specific device if you want to build only that one. | ||
| ===== Image configuration ===== | ===== Image configuration ===== | ||
| Line 273: | Line 293: | ||
| :!: Also you won't be able to install kernel packages from the official repositories when you make changes here. | :!: Also you won't be able to install kernel packages from the official repositories when you make changes here. | ||
| - | While you won't typically need to do this, you can do it: | + | While you won't typically need to do this, first define the target, subtarget, and device in a '' |
| + | <code bash> | ||
| + | CONFIG_TARGET_x86=y | ||
| + | CONFIG_TARGET_x86_64=y | ||
| + | CONFIG_TARGET_x86_64_DEVICE_generic=y | ||
| + | </ | ||
| + | Now run the following where subtarget is not a variable, it is a literal and it references the '' | ||
| <code bash> | <code bash> | ||
| make kernel_menuconfig CONFIG_TARGET=subtarget | make kernel_menuconfig CONFIG_TARGET=subtarget | ||
| Line 288: | Line 314: | ||
| </ | </ | ||
| - | === Source mirrors === | + | ==== Source mirrors |
| The 'Build system settings' | The 'Build system settings' | ||
| - Local mirror for source packages | - Local mirror for source packages | ||
| Line 347: | Line 373: | ||
| <code bash> | <code bash> | ||
| make download | make download | ||
| - | ionice -c 3 nice -n19 make -j9 | + | ionice -c 3 chrt --idle 0 nice -n19 make -j9 |
| </ | </ | ||
| Line 363: | Line 389: | ||
| It doesn' | It doesn' | ||
| + | |||
| + | Note: you must have done a full tree build (make, or make world) beforehand for this to work reliably. | ||
| === Spotting build errors === | === Spotting build errors === | ||
| Line 407: | Line 435: | ||
| make -i ... | make -i ... | ||
| </ | </ | ||
| + | |||
| + | |||
| + | === Make a summary information of generated image === | ||
| + | <code bash> | ||
| + | make json_overview_image_info | ||
| + | </ | ||
| + | Generate a summary of the image (including default packages, type of target, etc... ) in JSON format. The output is available in ''< | ||
| + | |||
| + | |||
| + | === Calculate checksum for generated files === | ||
| + | <code bash> | ||
| + | make checksum | ||
| + | </ | ||
| + | The following action will take place: a checksum will be computed and saved for the output files. This checksum will then be stored in the '< | ||
| ===== Locating images ===== | ===== Locating images ===== | ||
| Line 414: | Line 456: | ||
| E.g. if your ''< | E.g. if your ''< | ||
| - | See also: [[docs: | + | See also: [[docs: |
| ===== Cleaning up ===== | ===== Cleaning up ===== | ||
| You might need to clean your //build environment// | You might need to clean your //build environment// | ||
| - | The following '' | ||
| + | The build artefacts, toolchain, build tools and downloaded feeds & sources files can be cleaned selectively.\\ | ||
| + | The following '' | ||
| + | |||
| + | ^ > Cleaned components > \\ v make argument v^ Compiled binaries:\\ firmware, kernel, packages ^ Toolchain\\ (target-specific) | ||
| + | | clean | x | | | | | | | ||
| + | | targetclean | ||
| + | | dirclean | ||
| + | | config-clean | | | | x | | | | ||
| + | | distclean | ||
| ==== Clean ==== | ==== Clean ==== | ||
| <code bash> | <code bash> | ||
| Line 425: | Line 475: | ||
| </ | </ | ||
| - | Delete | + | Deletes |
| This doesn' | This doesn' | ||
| It is a good practice to do '' | It is a good practice to do '' | ||
| That may not be necessary always, but as a general rule it helps to ensure quality builds. | That may not be necessary always, but as a general rule it helps to ensure quality builds. | ||
| + | |||
| + | ==== Targetclean ==== | ||
| + | <code bash> | ||
| + | make targetclean | ||
| + | </ | ||
| + | |||
| + | This cleans also the target-specific toolchain in addition of doing '' | ||
| + | Does a '' | ||
| + | Note: '' | ||
| ==== Dirclean ==== | ==== Dirclean ==== | ||
| Line 435: | Line 494: | ||
| </ | </ | ||
| - | This is your basic "full clean" operation. | + | This is your basic "full clean" operation. |
| - | Delete | + | Deletes |
| ==== Distclean ==== | ==== Distclean ==== | ||
| Line 443: | Line 503: | ||
| </ | </ | ||
| - | Nuke 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. |
| :!: In addition to all else, this will **erase your build configuration ''< | :!: In addition to all else, this will **erase your build configuration ''< | ||
| Use only if you need a " | Use only if you need a " | ||
| + | |||
| ==== Selective cleanup ==== | ==== Selective cleanup ==== | ||
| Line 467: | Line 528: | ||
| ===== Troubleshooting ===== | ===== Troubleshooting ===== | ||
| - | * Beware of [[docs: | + | * Beware of [[docs: |
| * First get more information on the problem using the make option '' | * First get more information on the problem using the make option '' | ||
| * Read more about make options: [[docs: | * Read more about make options: [[docs: | ||
| ==== Missing source code file, due to download problems ==== | ==== 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). | + | First check if the URL path in the make file contains a trailing slash, then if it does, try with it removed (helped several times). |
| Otherwise try to download the source code manually and put it into '' | Otherwise try to download the source code manually and put it into '' | ||
| Line 501: | Line 562: | ||
| If running '' | If running '' | ||
| - | |||