“MYZR-IMX8M-EK300 Linux-4.14.98 编译参考手册”的版本间的差异

来自明远智睿的wiki
跳转至: 导航搜索
第1行: 第1行:
## MY-i.MX8M Linux 编译手册
 
  
### 1. 安装交叉编译工具
+
#### 安装交叉编译工具
  
- 创建目录
+
* 创建安装目录
  
<pre>
+
=====> 输入指令:
=> mkdir ~/myimx8m/gcc-tool -p
+
    mkdir ~/my-work/03_toolchain -p
=> cd ~/myimx8m/gcc-tool
 
</pre>
 
  
- 下载交叉编译工具
+
=====> 输入指令:
 +
  cd ~/my-work/03_toolchain
  
<pre>
 
=> wget https://releases.linaro.org/components/toolchain/binaries/7.3-2018.05/aarch64-linux-gnu/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz
 
</pre>
 
  
- 解压交叉编译工具
+
* 下载交叉编译工具
<pre>
 
=> tar -xvf gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz -C ~/myimx8m/gcc-tool
 
</pre>
 
  
- 创建交叉编译工具配置脚本
 
  
<pre>
+
=====> 输入指令:
=> vim gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.env
+
    wget https://releases.linaro.org/components/toolchain/binaries/7.3-2018.05/aarch64-linux-gnu/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz
  
# 输入如下内容
 
#!/bin/sh
 
export PATH=${HOME}/gcc-tool/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin:${PATH}
 
export ARCH=arm64
 
export CROSS_COMPILE=aarch64-linux-gnu-
 
</pre>
 
  
<pre>
+
* 解压交叉编译工具
# 赋予脚本执行权限
 
=> chmod +x gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.env
 
</pre>
 
  
- 配置交叉编译环境变量
 
  
<pre>
+
=====> 输入指令:
=> source ~/myimx8m/gcc-tool/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.env
+
    tar xf gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz -C ~/my-work/03_toolchain
</pre>
 
  
- 验证安装
 
  
<pre>
+
* 创建交叉编译工具配置脚本
=> ${CROSS_COMPILE}gcc -v
 
  
Using built-in specs.
+
=====> 输入指令:
COLLECT_GCC=aarch64-linux-gnu-gcc
+
    cat << EOF > ~/my-work/03_toolchain/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.env
COLLECT_LTO_WRAPPER=/home/myzr/my-work/03_toolchain/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/../libexec/gcc/aarch64-linux-gnu/7.3.1/lto-wrapper
+
    #!/bin/sh
Target: aarch64-linux-gnu
+
    export PATH=${HOME}/my-work/03_toolchain/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin:${PATH}
Configured with: '/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/snapshots/gcc.git~linaro-7.3-2018.05/configure' SHELL=/bin/bash --with-mpc=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu --with-mpfr=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu --with-gmp=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu --with-gnu-as --with-gnu-ld --disable-libmudflap --enable-lto --enable-shared --without-included-gettext --enable-nls --with-system-zlib --disable-sjlj-exceptions --enable-gnu-unique-object --enable-linker-build-id --disable-libstdcxx-pch --enable-c99 --enable-clocale=gnu --enable-libstdcxx-debug --enable-long-long --with-cloog=no --with-ppl=no --with-isl=no --disable-multilib --enable-fix-cortex-a53-835769 --enable-fix-cortex-a53-843419 --with-arch=armv8-a --enable-threads=posix --enable-multiarch --enable-libstdcxx-time=yes --enable-gnu-indirect-function --with-build-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/sysroots/aarch64-linux-gnu --with-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu/aarch64-linux-gnu/libc --enable-checking=release --disable-bootstrap --enable-languages=c,c++,fortran,lto --build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu --target=aarch64-linux-gnu --prefix=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu
+
    export ARCH=arm64
Thread model: posix
+
    export CROSS_COMPILE=aarch64-linux-gnu-
gcc version 7.3.1 20180425 [linaro-7.3-2018.05 revision d29120a424ecfbc167ef90065c0eeb7f91977701] (Linaro GCC 7.3-2018.05)
+
    EOF
</pre>
 
  
  
  
### 2. 内核编译
 
  
#### 2.1 准备源码
+
=====> 输入指令:
 +
    chmod +x ~/my-work/03_toolchain/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.env
  
- 创建目录
 
  
<pre>
+
* 配置交叉编译环境变量
=> mkdir ~/myimx8m/source -p
 
</pre>
 
  
- 下载源码
+
=====> 输入指令:
 +
    source ~/my-work/03_toolchain/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.env
  
  打开网盘到 “2.1\_OS\_Linux-4.14.98 -> 02_Source”,下载 “linux-4.14.98.*.tar.bz2”。 
 
  把源码包复制到虚拟机的 “~/myimx8m/source”,并解压(解压命令如下):
 
  
<pre>
+
* 检查安装
=> cd ~/myimx8m/source
 
=> tar -xvf linux-4.14.98.*.tar.bz2
 
</pre>
 
  
- 进入内核源码目录
+
=====> 输入指令:
 +
    ${CROSS_COMPILE}gcc -v
  
<pre>
+
=====> 输出信息:
=> cd ~/myimx8m/source/linux-4.14.98
+
    Using built-in specs.
</pre>
+
    COLLECT_GCC=aarch64-linux-gnu-gcc
 +
    COLLECT_LTO_WRAPPER=/home/myzr/my-work/03_toolchain/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/../libexec/gcc/aarch64-linux-gnu/7.3.1/lto-wrapper
 +
    Target: aarch64-linux-gnu
 +
    Configured with: '/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/snapshots/gcc.git~linaro-7.3-2018.05/configure' SHELL=/bin/bash --with-mpc=/home/tcwg-
 +
    buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu --with-mpfr=/home/tcwg-buildslave/workspace/tcwg-make-
 +
    release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu --with-gmp=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-
 +
    build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu --with-gnu-as --with-gnu-ld --disable-libmudflap --enable-lto --enable-shared --without-included-gettext --enable-nls --with-system-zlib --disable-sjlj-
 +
    exceptions --enable-gnu-unique-object --enable-linker-build-id --disable-libstdcxx-pch --enable-c99 --enable-clocale=gnu --enable-libstdcxx-debug --enable-long-long --with-cloog=no --with-ppl=no --with-isl=no --disable-multilib --
 +
    enable-fix-cortex-a53-835769 --enable-fix-cortex-a53-843419 --with-arch=armv8-a --enable-threads=posix --enable-multiarch --enable-libstdcxx-time=yes --enable-gnu-indirect-function --with-build-sysroot=/home/tcwg-
 +
    buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/sysroots/aarch64-linux-gnu --with-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-
 +
    release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu/aarch64-linux-gnu/libc --enable-checking=release --disable-bootstrap --enable-languages=c,c++,fortran,lto --
 +
    build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu --target=aarch64-linux-gnu --prefix=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-
 +
    gnu/_build/builds/destdir/x86_64-unknown-linux-gnu
 +
    Thread model: posix
 +
    gcc version 7.3.1 20180425 [linaro-7.3-2018.05 revision d29120a424ecfbc167ef90065c0eeb7f91977701] (Linaro GCC 7.3-2018.05)
  
- 配置交叉编译环境
 
  
<pre>
+
#### 安装库
=> source ~/myimx8m/gcc-tool/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.env
+
=====> 输入指令:
</pre>
+
    sudo apt install zlib1g
 +
    sudo apt install zlib1g-dev
 +
    apt-get install device-tree-compiler
  
#### 2.2 编译内核目标文件
 
  
- 生成目标.config文件
+
### 5.2 编译内核文件
  
<pre>
+
#### 5.2.1 编译前的准备
=> make myimx8mq_defconfig
 
</pre>
 
  
- 编译内核目标文件
+
* 创建工作目录
  
<pre>
+
=====> 输入指令:
=> make Image
+
    mkdir ~/my-work/02_source/ -p
</pre>
+
* 下载内核源码 
 +
  打开网盘到 “2.1\_OS\_Linux-4.14.98 -> 02_Source”,下载 “linux-4.14.98.*.tar.bz2”与"build.sh"。 
 +
  复制到虚拟机的 “~/my-work/02\_source/”,并解压(解压命令如下):
  
- 复制内核目标文件
+
=====> 输入指令:
 +
    cd ~/my-work/02_source
 +
    tar xf linux-4.14.98.*.tar.bz2
 +
* 进入内核源码目录
 +
=====> 输入指令:
 +
    cd ~/my-work/02_source/
 +
* 配置交叉编译环境变量
 +
=====> 输入指令:
 +
    source ~/my-work/03_toolchain/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.env
  
<pre>
+
#### 5.2.2 编译内核目标文件
=> cp arch/arm64/boot/Image ./
+
=====> 输入指令:
</pre>
+
    ./build.sh 8mek300 2g kernel
  
#### 2.3 编译设备树目标文件
+
**EVK_MODE:支持的设置为 8mevk、8mek300、8mmek240;**
  
- 根据开发板型号规格配置编译环境变量
+
**EVK_MEM:支持的设置为 2g、1g、3g、4g。**
  
<pre>
+
#### 5.2.3 编译设备树目标文件
=> EVK_MODE=myimx8mek300
+
=====> 输入指令:
=> EVK_MPU=8mq
+
    ./build.sh 8mek300 2g dts
</pre>
+
#### 5.2.4 编译内核模块包
 +
=====> 输入指令:
 +
    ./build.sh 8mek300 2g modules
 +
#### 5.2.5 目标文件
  
- 执行编译命令
+
**out 目录中 Image、\*.dtb 和 kernel-modules.tar.bz2 即编译得到的目标文件**
  
<pre>
 
# MIPI输出
 
=> make myzr/${EVK_MODE}-${EVK_MPU}.dtb
 
# HDMI输出
 
=> make myzr/${EVK_MODE}-${EVK_MPU}-hdmi.dtb
 
</pre>
 
  
- 复制设备树目标文件
+
### 5.3 编译u-boot文件
  
<pre>
+
#### 5.3.1 编译前的准备
=> cp arch/arm64/boot/dts/myzr/${EVK_MODE}-${EVK_MPU}.dtb ./
 
=> cp arch/arm64/boot/dts/myzr/${EVK_MODE}-${EVK_MPU}-hdmi.dtb ./
 
</pre>
 
  
#### 2.4 编译内核模块包
+
* 下载u-boot源码 
 +
  打开网盘到 “2.1\_OS\_Linux-4.14.98 -> 02_Source”,下载 “u-boot-2018.03.*.tar.bz2”、"build.sh"和“mkimage-imx_4.14.98.*.tar.bz2”。 
 +
  复制到虚拟机的 “~/my-work/02\_source/”,并解压(解压命令如下):
  
- 执行编译
 
  
<pre>
+
=====> 输入指令:
=> make modules
+
    tar xf u-boot-2018.03.*.tar.bz2
</pre>
+
    tar xf mkimage-imx_4.14.98.*.tar.bz2
 +
* 进入内核源码目录
  
- 创建内核模块的保存目录
 
  
<pre>
+
=====> 输入指令:
=> mkdir modules
+
    cd ~/my-work/02_source/
</pre>
+
* 配置交叉编译环境变量
  
- 安装内核模块到指定目录
 
  
<pre>
+
=====> 输入指令:
=> make modules_install headers_install INSTALL_MOD_PATH=./modules
+
    source ~/my-work/03_toolchain/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.env
</pre>
+
#### 5.3.2 编译u-boot目标文件
 +
=====> 输入指令:
 +
    ./build.sh 8mek300 2g uboot
 +
**EVK_MODE:支持的设置为 8mevk、8mek300、8mmek240;**
  
- 打包内核模块文件
+
**EVK_MEM:支持的设置为 2g、1g、3g、4g。**
 
 
<pre>
 
=> tar -cjf kernel-modules.tar.bz2 -C modules lib
 
</pre>
 
 
 
####  2.5 目标文件
 
 
 
**Image、\*.dtb 和 kernel-modules.tar.bz2 即编译得到的目标文件,保存这些文件**
 
 
 
 
 
 
 
### 3. 编译u-boot文件
 
 
 
#### 3.1  编译前的准备
 
 
 
- 下载u-boot源码
 
 
 
  打开网盘到 “2.1\_OS\_Linux-4.14.98 -> 02_Source”,下载 “u-boot-2018.03.*.tar.bz2”。
 
 
 
  把源码包复制到虚拟机的 “~/myimx8m/source”,并解压(解压命令如下):
 
 
 
<pre>
 
=> cd ~/myimx8m/source
 
=> tar -xvf u-boot-2018.03.*.tar.bz2
 
</pre>
 
 
 
- 进入uboot源码目录
 
 
 
<pre>
 
=> cd ~/myimx8m/source/u-boot-2018.03
 
</pre>
 
  
- 配置交叉编译环境变量
+
#### 5.3.3 目标文件
  
<pre>
+
**out目录中 *.bin 即编译得到的目标文件**
=> source ~/myimx8m/gcc-tool/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.env
 
</pre>
 
  
#### 3.2 编译u-boot目标文件
 
  
- 根据开发板型号规格配置编译环境变量
 
  
<pre>
+
###5.4 编译所有目标文件
=> EVK_MODE=myimx8mek300
+
=====> 输入指令:
=> EVK_MPU=8mq
+
    source ~/my-work/03_toolchain/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.env
=> EVK_MEM=2g
+
    ./build.sh 8mek300 2g all
</pre>
+
**EVK_MODE:支持的设置为 8mevk、8mek300、8mmek240;**
  
 
**EVK_MEM:支持的设置为 2g、1g、3g、4g。**
 
**EVK_MEM:支持的设置为 2g、1g、3g、4g。**
 
- 生成目标 .config 文件
 
 
<pre>
 
=> make ${EVK_MODE}-${EVK_MPU}-${EVK_MEM}_defconfig
 
</pre>
 
 
- 编译u-boot目标文件
 
 
<pre>
 
=> make
 
</pre>
 
 
- 复制u-boot目标文件
 
 
<pre>
 
=> cp arch/arm/dts/${EVK_MODE}-${EVK_MPU}.dtb ./
 
</pre>
 
 
#### 3.3 目标文件
 
 
​ **${EVK_MODE}-${EVK_MPU}.dtb、u-boot-nodtb.bin 和 u-boot-spl.bin 即编译得到的目标文件,保存这三个文件,在下一步的 bootloader 编译需要用到**
 
 
#### 3.4 编译BootLoader
 
 
##### 3.4.1 编译前的准备
 
 
- 下载BootLoader编译工具
 
  打开网盘到 “2.1\_OS\_Linux-4.14.98 -> 02_Source”,下载 “mkimage-4.14.98.*.tar.bz2”。
 
  把源码包复制到虚拟机的 “~/myimx8m/source/”,并解压(解压命令如下):
 
 
<pre>
 
=> cd ~/myimx8m/source
 
=> tar -xvf mkimage-4.14.98.*.tar.bz2
 
</pre>
 
 
- 进入工具目录
 
 
<pre>
 
=> cd ~/myimx8m/source/mkimage-4.14.98
 
</pre>
 
 
- 根据开发板型号规格配置编译环境变量
 
 
<pre>
 
=> EVK_MODE=myimx8mek300
 
=> EVK_MPU=8mq
 
=> EVK_MEM=2g
 
=> EVK_SOC=iMX8M
 
</pre>
 
 
**EVK_MEM:支持的设置为 2g、1g、3g、4g;**
 
 
- 复制依赖文件
 
 
  把u-boot编译得到的三个文件复制过来。
 
 
<pre>
 
=> cp ../u-boot-2018.03/u-boot-nodtb.bin \
 
./iMX8M/${EVK_MODE}-${EVK_MPU}-${EVK_MEM}-nodtb.bin
 
=> cp ../u-boot-2018.03/spl/u-boot-spl.bin \
 
./iMX8M/${EVK_MODE}-${EVK_MPU}-${EVK_MEM}-spl.bin
 
=> cp ../u-boot-2018.03/${EVK_MODE}-${EVK_MPU}.dtb \
 
./iMX8M/${EVK_MODE}-${EVK_MPU}.dtb
 
</pre>
 
 
##### 3.4.2 编译BootLoader目标文件
 
 
- 输入编译指令
 
 
<pre>
 
=> make SOC=${EVK_SOC} ${EVK_MODE} OUTIMG=${EVK_MODE}-${EVK_MPU}-${EVK_MEM}.bin
 
</pre>
 
 
- 复制BootLoader目标文件
 
 
<pre>
 
=> cp ./iMX8M/${EVK_MODE}-${EVK_MPU}-${EVK_MEM}.bin ./${EVK_MODE}-${EVK_MPU}.bin
 
</pre>
 
 
##### 3.4.3 目标文件
 
 
**${EVK_MODE}-${EVK_MPU}.bin 即编译得到的目标文件,保存这个文件**
 
 
<pre>
 
Web:  http://www.myzr.com.cn/
 
Wiki: http://wiki.myzr.com.cn/
 
BBS:  http://bbs.myzr.com.cn/
 
 
Tel: 0756-3628023/3628021
 
E-mail: service@myzr.com.cn
 
</pre>
 
<br>
 
<br>
 
--------------------------------------------------------------------------------
 
<pre>
 
--------------------------------------------------------------------------------
 
* 珠海明远智睿科技有限公司 
 
* ZhuHai MYZR Technology CO.,LTD.
 
* Latest Update: 2019/11/08 
 
* Supporter: Tang Bin
 
--------------------------------------------------------------------------------
 
</pre>
 

2020年10月23日 (五) 11:17的版本

安装交叉编译工具

  • 创建安装目录

=====> 输入指令:

   mkdir ~/my-work/03_toolchain -p

=====> 输入指令:

  cd ~/my-work/03_toolchain
  • 下载交叉编译工具

=====> 输入指令:

   wget https://releases.linaro.org/components/toolchain/binaries/7.3-2018.05/aarch64-linux-gnu/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz
  • 解压交叉编译工具

=====> 输入指令:

   tar xf gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz -C ~/my-work/03_toolchain
  • 创建交叉编译工具配置脚本

=====> 输入指令:

   cat << EOF > ~/my-work/03_toolchain/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.env
   #!/bin/sh
   export PATH=${HOME}/my-work/03_toolchain/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin:${PATH}
   export ARCH=arm64
   export CROSS_COMPILE=aarch64-linux-gnu-
   EOF

=====> 输入指令:

   chmod +x ~/my-work/03_toolchain/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.env
  • 配置交叉编译环境变量

=====> 输入指令:

   source ~/my-work/03_toolchain/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.env
  • 检查安装

=====> 输入指令:

   ${CROSS_COMPILE}gcc -v

=====> 输出信息:

   Using built-in specs.
   COLLECT_GCC=aarch64-linux-gnu-gcc
   COLLECT_LTO_WRAPPER=/home/myzr/my-work/03_toolchain/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/../libexec/gcc/aarch64-linux-gnu/7.3.1/lto-wrapper
   Target: aarch64-linux-gnu
   Configured with: '/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/snapshots/gcc.git~linaro-7.3-2018.05/configure' SHELL=/bin/bash --with-mpc=/home/tcwg- 
   buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu --with-mpfr=/home/tcwg-buildslave/workspace/tcwg-make- 
   release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu --with-gmp=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64- 
   build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu --with-gnu-as --with-gnu-ld --disable-libmudflap --enable-lto --enable-shared --without-included-gettext --enable-nls --with-system-zlib --disable-sjlj- 
   exceptions --enable-gnu-unique-object --enable-linker-build-id --disable-libstdcxx-pch --enable-c99 --enable-clocale=gnu --enable-libstdcxx-debug --enable-long-long --with-cloog=no --with-ppl=no --with-isl=no --disable-multilib -- 
   enable-fix-cortex-a53-835769 --enable-fix-cortex-a53-843419 --with-arch=armv8-a --enable-threads=posix --enable-multiarch --enable-libstdcxx-time=yes --enable-gnu-indirect-function --with-build-sysroot=/home/tcwg- 
   buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/sysroots/aarch64-linux-gnu --with-sysroot=/home/tcwg-buildslave/workspace/tcwg-make- 
   release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu/aarch64-linux-gnu/libc --enable-checking=release --disable-bootstrap --enable-languages=c,c++,fortran,lto -- 
   build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu --target=aarch64-linux-gnu --prefix=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux- 
   gnu/_build/builds/destdir/x86_64-unknown-linux-gnu
   Thread model: posix
   gcc version 7.3.1 20180425 [linaro-7.3-2018.05 revision d29120a424ecfbc167ef90065c0eeb7f91977701] (Linaro GCC 7.3-2018.05)

安装库

=====> 输入指令:

   sudo apt install zlib1g 
   sudo apt install zlib1g-dev 
   apt-get install device-tree-compiler

5.2 编译内核文件

5.2.1 编译前的准备

  • 创建工作目录

=====> 输入指令:

   mkdir ~/my-work/02_source/ -p
  • 下载内核源码
 打开网盘到 “2.1_OS_Linux-4.14.98 -> 02_Source”,下载 “linux-4.14.98.*.tar.bz2”与"build.sh"。
复制到虚拟机的 “~/my-work/02_source/”,并解压(解压命令如下):

=====> 输入指令:

   cd ~/my-work/02_source
   tar xf linux-4.14.98.*.tar.bz2
  • 进入内核源码目录

=====> 输入指令:

   cd ~/my-work/02_source/
  • 配置交叉编译环境变量

=====> 输入指令:

   source ~/my-work/03_toolchain/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.env

5.2.2 编译内核目标文件

=====> 输入指令:

   ./build.sh 8mek300 2g kernel

EVK_MODE:支持的设置为 8mevk、8mek300、8mmek240;

EVK_MEM:支持的设置为 2g、1g、3g、4g。

5.2.3 编译设备树目标文件

=====> 输入指令:

   ./build.sh 8mek300 2g dts

5.2.4 编译内核模块包

=====> 输入指令:

   ./build.sh 8mek300 2g modules

5.2.5 目标文件

out 目录中 Image、*.dtb 和 kernel-modules.tar.bz2 即编译得到的目标文件

5.3 编译u-boot文件

5.3.1 编译前的准备

  • 下载u-boot源码
    打开网盘到 “2.1_OS_Linux-4.14.98 -> 02_Source”,下载 “u-boot-2018.03..tar.bz2”、"build.sh"和“mkimage-imx_4.14.98..tar.bz2”。
    复制到虚拟机的 “~/my-work/02_source/”,并解压(解压命令如下):

=====> 输入指令:

   tar xf u-boot-2018.03..tar.bz2
   tar xf mkimage-imx_4.14.98..tar.bz2
  • 进入内核源码目录

=====> 输入指令:

   cd ~/my-work/02_source/
  • 配置交叉编译环境变量

=====> 输入指令:

   source ~/my-work/03_toolchain/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.env

5.3.2 编译u-boot目标文件

=====> 输入指令:

   ./build.sh 8mek300 2g uboot

EVK_MODE:支持的设置为 8mevk、8mek300、8mmek240;

EVK_MEM:支持的设置为 2g、1g、3g、4g。

5.3.3 目标文件

out目录中 *.bin 即编译得到的目标文件

5.4 编译所有目标文件

=====> 输入指令:

   source ~/my-work/03_toolchain/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.env
   ./build.sh 8mek300 2g all

EVK_MODE:支持的设置为 8mevk、8mek300、8mmek240;

EVK_MEM:支持的设置为 2g、1g、3g、4g。