User Tools

Site Tools


Differences

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

Link to this comparison view

Both sides previous revision Previous revision
en:howto:turris_os_build [2017/05/18 10:07]
nkoranova
en:howto:turris_os_build [2018/06/07 11:27] (current)
kkoci [Compiling Turris OS]
Line 67: Line 67:
 ===== Compiling Turris OS ===== ===== Compiling Turris OS =====
  
-Buildroot (a compilation tool) Turris OS, or OpenWRT, consist of big amount of scripts, that cross compile (compile for the target platform) software using the tool //GNU Make//The primary command used in buildroot is therefore ''​make''​. +Turris OS, or OpenWRT, consist of big amount of scripts. ​Multiple steps are required ​to build Turris OS such as configuration generation, feeds fetching ​(those contain ​additional packages ​outside of OpenWRT)feeds patching ​and moreBecause ​of complexity of such task a ''​compile_fw'' ​script was implemented ​in Turris OS. It automates all tasks required for Turris OS build.
-In addition ​to the key system components contained in the repository ​ //​openwrt// ​(//​turris-os//​) ​additional packages ​are compiledwhich are managed from the repository //​turris-os-packages// ​and other third party repositoriesTheir inclusion in the system is handled by the script which also manages feeds. So let's look at commands, which can be useful when using buildroot. All commands should be run in the root directory ​of the repository (folder ​''​/ openwrt''​ in the Vagrant environment)They are listed in the order in which they should be run after initialization of the clean development environment:​+
  
- * ''​./​scripts/​feeds update -a''​ -- Updates all feeds from their location. This step also downloads content from other repositories like //​turris-os-packages//​ into separate folders. +Depending on target board board of your build you should use either ​''​compile_omnia_fw'' ​(for Turris Omnia) or ''​compile_turris_fw'' ​(for Turris 1.x).
- * ''​./​scripts/​feeds install -a''​ -- Installs packages from all feeds into buildroot. This creates symbolic links to the definition ​of packages in the ''​package/'' ​and it is possible to select and compile packages. +
- * ''​cp configs/​omnia .config''​-- Copies the configuration file for Turris Omnia (alternatively ​''​configs/​Turris''​ for Turris 1.x) +
- * ''​make menuconfig''​ - Displays the configuration menuWithin it you can control what kinds of packages should be be compiled and possibly other parameters of the compiled system can be adjusted. After saving, information on the current configuration is also generated (which can as well be achieved by running the command ''​make defconfig''​). +
-After you run these commands, you can start compiling all the tools and the system itself. Because if done by single strain, this operation would last very long, the example shows the use of the symptom ''​-j NUMBER''​ where ''​NUMBER''​ represents the number of jobs that can run simultaneously. It is recommended to select the number that corresponds to the number of CPU kernels or one unit higher. Parameters ''​LOGFILE=1 BUILD_LOG=1 IS_TTY=1''​ ensure that the output of the compilation is recorded in the file and the console displays only basic information about the compilation:​+
  
- make -j 4 LOGFILE=1 BUILD_LOG=1 IS_TTY=1+You can pass additional arguments to ''​compile_fw''​ script derivate and those are passed to ''​make''​ call of OpenWRT build. Suggested argument is ''​-j$(nproc)''​ to run build in parallel for faster builds.
  
-<WRAP tip> +In defaultonly minimal set of packages is build. ​This is not complete Turris OS but should be enough for example ​for new packages creation. This kind of build is used for development for faster build timesthat is around half a hour or hour depending on hardware.
-Sometimes the operation ends with an error. ​In that caseuse either the parameters form the examples, and then look for the error in the file ''​logs/​build.log''​ or add the parameter ''​V=s''​ to the command to receive an extended output on the console. +
-</​WRAP>​ +
- +
-Sometimes it is desirable to compile only one package. If you already have the compiled toolchain (For example, you ran the command ''​make''​ as in the example above), fetch source codes using the following command. This will also start their compilation ​for the target system and the creation of the ''​.ipk''​ package installation on the router. In additionit is sometime necessary to first assemble dependency packages for the required package. +
- +
- +
- make package/​package-name/​install+
  
 +To build complete Turris OS and to generate medkit you have to set environment variable ''​BUILD_ALL=y''​ when you run ''​compile_fw''​ script derivate. You can do that by ''​BUILD_ALL=y ./​compile_omnia_fw''​ (with ''​compile_turris_fw''​ for Turris 1.x). You have to use this build when you want to create your own medkit (archive with root file-system to be flashed to router). This build can take more than eight hours to complete depending on used hardware and it is prune to failure (caused by race conditions).
  
 <WRAP info> <WRAP info>
-As package name you should enter the name of the folder, in which the file ''​Makefile'' ​for the given package is located, not the package name specified in the variable ​''​PKG_NAME''​. +If you encounter problems with build then you can try to change ​''​-j'' ​value or you can just use ''​-j1'' ​to disable build in parallelThese problems are caused by race conditions ​in build and by hard to discover missing dependencies.
-If the file ''​Makefile''​ contains more packages, all of the packages will be created, which have been selected ​in the configuration.+
 </​WRAP>​ </​WRAP>​
- 
-Compiled packages (and any additional output compilations,​ such as SDK, and other files) can be found in the ''​bin/''​. Created ''​.ipk''​ files can then be copied onto the router and installed. 
- 
-To facilitate the compilation there are shell scripts ''​compile_turris_fw''​ and ''​compile_omnia_fw''​ in the repository, which when run delete old files, initialize feeds and run compilation of the system. It is appropriate to run them with the parameter ''​USE_CCACHE = 1''​ and in a number of tasks (for instance ''​USE_CCACHE=1 ./​compile_turris_fw -j4''​) it is necessary to install the package ''​ccache''​ onto the system, which runs compilation. You can also use the  parameter ''​ BUILD_ALL ''​ -- this runs the installation of completely all packages that are included in the Turris OS. This operation takes considerably longer (in terms of hours). To start compiling the complete Turris OS, with the use of cache during compilation and with four roles and error output being recorded in the file, run the following: 
- 
- USE_CCACHE=1 BUILD_ALL=1 ./​compile_turris_fw -j 4 LOGFILE=1 BUILD_LOG=1 IS_TTY=1 
- 
 ===== Troubleshooting ===== ===== Troubleshooting =====