To install the toolchain on your host machine, unpack the tar.xz file:
tar xvf gcc-linaro-5.2-2015.11-2-x86_64_arm-linux-gnueabihf.tar.xz
ln -s gcc-linaro-5.2-2015.11-2-x86_64_arm-linux-gnueabihf gcc-linaro
The U-Boot and Linux makefiles use the environment variables ARCH/CROSS_COMPILE to configure and call the compiler correctly. Therefore, these environment variables must be exported in any shell instance that will run configure/compile commands to build U-Boot or Linux for the target module.
export ARCH=arm
export PATH=~/gcc-linaro/bin/:$PATH
export CROSS_COMPILE=arm-linux-gnueabihf-
U-Boot compilation for some modules needs a device tree compiler (DTC) of version 1.3 or higher to be installed and executable. Ubuntu 12.04 LTS (Precise Pangolin) and later provide a version which is recent enough:
sudo apt install device-tree-compiler
To check the version:
dtc -v
Version: DTC 1.3.0
The uImage target of the Linux kernel compilation needs a recent mkimage tool which is actually built during U-Boot compilation as explained further below. Ensure that one is included in PATH:
sudo apt install u-boot-tools
You need some basic build tools to compile the kernel. Most are likely part of your distro's standard install.
sudo apt install bc git libncurses5-dev lzop make
For detailed information about which branch, configuration or binary to use, please consult the image version tables provided at the top of the article.
Obtain the U-Boot source code using Git:
git clone -b 2016.11-toradex git://git.toradex.com/u-boot-toradex.git
cd u-boot-toradex
Note:The 2016.11-toradex branch is used as an example. For detailed information about which branch to use, please consult the image version tables provided at the top of the article.
Our latest board configurations are called as follows:
For detailed information about which configuration to use, please consult the image version tables provided at the top of the article.
Ensure the environment is configured for cross compilation as explained in the toolchain chapter. Then choose one of those configurations and load it:
make apalis_imx6_defconfig
The following is the procedure to compile the boot loader.
make -j3 2>&1 | tee build.log
在编译Android的时候,经常用到命令:
make -j8 2>&1 | tee build.log
其中 make 是编译命令,
-j8 这里的 8 指的是线程数量,就是要用几个线程去编译这个工程,一般会是 CPU核心数的2 倍。
2是标准错误,&1是标准输出,2>&1意思就是将标准错误输出到标准输出中。
如果没有2>&1,只会有标准输出,没有错误;
tee的作用同时输出到控制台和文件
make > build.log 是将所有标准输出到这个文件中,并没有定义标准错误应该是定义到了标准输出,也就是说如果make执行出现错误,那么就不会写到 build.log中,而是输出到屏幕上,
2>&1是错误和结果都重定向到build.log中!
可以到根目录看到 build.log
For detailed information about which branch, configuration or binary to use, please consult the image version tables provided at the top of the article.
Obtain the kernel source code using Git:
git clone -b tegra git://git.toradex.com/linux-toradex.git
cd linux-toradex
Note: The tegra branch is used as an example. For detailed information about which branch to use, please consult the image version tables provided at the top of the article.
Our kernel tree provides default kernel configurations for our modules:
For detailed information about which configuration to use, please consult the image version tables provided at the top of the article.
Ensure the environment is configured for cross compilation as explained in the toolchain chapter.
Set the default configuration:
make apalis_imx6_defconfig
Depending on the module, different kernel image types are used. Furthermore, some kernels require a device tree to describe the system's hardware (see Device Tree Customization for details).
Our kernel configurations build some drivers as kernel modules.
To assure module compatibility the kernel refuses to load modules with a 'vermagic' string which does not match its own, on top of that the modules are stored under a directory named after the version string.
Thus one usually needs to compile and deploy the kernel modules together with the kernel in order to use them.
Starting with Apalis iMX6 Image V2.3 Beta 1 and for all Colibri iMX6 kernels some additional parameters are required to compile the kernel plus a device tree is built from the kernel sources.
Valid device trees:
~/.../arch/arm/boot/dts/
imx6q-apalis-ixora.dtb
imx6q-apalis_v1_0-eval.dtb
imx6q-apalis_v1_0-ixora.dtb
imx6dl-colibri-eval-v3.dtb
imx6dl-colibri-cam-eval-v3.dtb
To compile the kernel & device tree:
make -j3 uImage LOADADDR=10008000 2>&1 | tee build.log
>> Image arch/arm/boot/uImage is ready
make imx6q-apalis-eval.dtb
>> DTC arch/arm/boot/dts/imx6q-apalis-ixora.dtb
https://developer.toradex.com/knowledge-base/build-u-boot-and-linux-kernel-from-source-code#UBoot