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

来自明远智睿的wiki
跳转至: 导航搜索
(创建页面,内容为“[^_^]: MY-IMX8M-EK300 Linux-4.14.98 编译参考手册 ## **安装交叉编译工具链** * 创建安装目录 <pre> =====> Input: mkdir ~/my-work/03_toolchain -p...”)
 
 
(未显示同一用户的8个中间版本)
第1行: 第1行:
[^_^]: MY-IMX8M-EK300 Linux-4.14.98 编译参考手册
 
  
## **安装交叉编译工具链**
+
#### 安装交叉编译工具
* 创建安装目录
+
 
<pre>
+
* 创建安装目录
=====> Input:
+
 
mkdir ~/my-work/03_toolchain -p
+
=====> 输入指令:
cd ~/my-work/03_toolchain
+
    mkdir ~/my-work/03_toolchain -p
</pre>
+
 
 +
=====> 输入指令:
 +
  cd ~/my-work/03_toolchain
 +
 
 +
 
 
* 下载交叉编译工具
 
* 下载交叉编译工具
<pre>
 
=====> Input:
 
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>
 
=====> Input:
 
tar xf gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz -C ~/my-work/03_toolchain 
 
</pre>
 
* 创建交叉编译工具配置脚本 
 
<pre>
 
=====> Input:
 
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
 
  
=====> Input:  
+
=====> 输入指令:
chmod +x ~/my-work/03_toolchain/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
</pre>
+
 
* 配置交叉编译环境变量
+
 
<pre>
+
* 解压交叉编译工具
=====> Input:
+
 
source ~/my-work/03_toolchain/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.env
+
 
</pre>
+
=====> 输入指令:
* 检查安装
+
    tar xf gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz -C ~/my-work/03_toolchain
<pre>
+
 
=====> Input:
+
 
${CROSS_COMPILE}gcc -v  
+
* 创建交叉编译工具配置脚本
 +
 
 +
=====> 输入指令:
 +
    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
  
=====> Output:
 
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)
 
</pre>
 
  
<br>
+
### 5.2 编译内核文件
## **编译内核文件**
 
### 编译前的准备
 
* 创建编译工作目录
 
<pre>
 
=====> Input:
 
mkdir ~/my-work/02_source/ -p
 
</pre>
 
* 下载内核源码
 
打开网盘到 “2.1_OS_Linux-4.14.98 -> 02_Source”,下载 “linux-4.14.98.*.tar.bz2”。 
 
把源码包复制到虚拟机的 “~/my-work/02_source/”,并解压(解压命令如下): 
 
<pre>
 
=====> Input:
 
cd ~/my-work/02_source
 
tar xf linux-4.14.98.*.tar.bz2
 
</pre>
 
* 进入内核源码目录 
 
<pre>
 
=====> Input:
 
cd ~/my-work/02_source/linux-4.14.98
 
</pre>
 
* 配置交叉编译环境变量 
 
<pre>
 
=====> Input:
 
source ~/my-work/03_toolchain/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.env 
 
</pre>
 
  
### 编译内核目标文件
+
#### 5.2.1 编译前的准备
* 生成目标 .config 文件
 
<pre>
 
=====> Input:
 
make myimx8mq_defconfig 
 
  
=====> Output:
+
* 创建工作目录
  HOSTCC  scripts/basic/fixdep
 
  HOSTCC  scripts/kconfig/conf.o
 
  SHIPPED scripts/kconfig/zconf.tab.c
 
  SHIPPED scripts/kconfig/zconf.lex.c
 
  HOSTCC  scripts/kconfig/zconf.tab.o
 
  HOSTLD  scripts/kconfig/conf
 
#
 
# configuration written to .config
 
#
 
</pre>
 
  
* 编译内核目标文件
+
=====> 输入指令:
<pre>
+
    mkdir ~/my-work/02_source/ -p
=====> Input:
+
* 下载内核源码 
make Image
+
  打开网盘到 “2.1\_OS\_Linux-4.14.98 -> 02_Source”,下载 “linux-4.14.98.*.tar.bz2”与"build.sh"。 
 +
  复制到虚拟机的 “~/my-work/02\_source/”,并解压(解压命令如下):
  
=====> Output:
+
=====> 输入指令:
scripts/kconfig/conf  --silentoldconfig Kconfig
+
    cd ~/my-work/02_source
  CHK    include/config/kernel.release
+
     tar jxf linux-4.14.98.*.tar.bz2
  UPD     include/config/kernel.release
+
* 进入内核源码目录
  WRAP    arch/arm/include/generated/asm/bitsperlong.h
+
=====> 输入指令:
  ......
+
    cd ~/my-work/02_source/
  AR      built-in.o
+
* 配置交叉编译环境变量
  LD      vmlinux.o
+
=====> 输入指令:
  MODPOST vmlinux.o
+
    source ~/my-work/03_toolchain/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.env
  KSYM    .tmp_kallsyms1.o
 
  KSYM    .tmp_kallsyms2.o
 
  LD      vmlinux
 
  SORTEX  vmlinux
 
  SYSMAP  System.map
 
  OBJCOPY arch/arm64/boot/Image
 
</pre>
 
  
* 复制内核目标文件
+
#### 5.2.2 编译内核目标文件
<pre>
+
=====> 输入指令:
=====> Input:
+
    ./build.sh 8mek300 2g kernel
cp arch/arm64/boot/Image .
 
</pre>
 
  
### 编译设备树目标文件
+
**EVK_MODE:支持的设置为 8mevk、8mek300、8mmek240;**
* 设置 TARGETEVKMODE
 
<pre>
 
=====> Input:
 
TARGET_EVK_MODE=myimx8mevk-8mq
 
</pre>
 
**【说明】:TARGET_EVK_MODE 是根据开发板型号设置,可设置为 myimx8mevk-8mq, myimx8mek300-8mq*
 
  
* 执行编译命令 
+
**EVK_MEM:支持的设置为 2g、1g、3g、4g。**
<pre>
 
=====> Input:
 
make myzr/${TARGET_EVK_MODE}.dtb   
 
  
=====> Output:
+
#### 5.2.3 编译设备树目标文件
  CHK     scripts/mod/devicetable-offsets.h
+
=====> 输入指令:
  DTC     arch/arm64/boot/dts/myzr/${TARGET_EVK_MODE}.dtb
+
     ./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>
 
=====> Input:
 
cp arch/arm64/boot/dts/myzr/${TARGET_EVK_MODE}.dtb ./
 
</pre>
 
  
### 编译内核模块包 
 
* 执行编译
 
<pre>
 
=====> Input:
 
make modules 
 
  
=====> Output:
+
### 5.3 编译u-boot文件
  CHK    include/config/kernel.release
 
  CHK    include/generated/uapi/linux/version.h
 
  ......
 
  LD [M]  sound/usb/snd-usb-audio.ko
 
  LD [M]  sound/usb/snd-usbmidi-lib.ko
 
</pre>
 
  
* 创建内核模块的保存目录
+
#### 5.3.1 编译前的准备
<pre>
 
=====> Input:
 
mkdir modules 
 
</pre>
 
  
* 安装内核模块到指定目录
+
* 下载u-boot源码 
<pre>
+
  打开网盘到 “2.1\_OS\_Linux-4.14.98 -> 02_Source”,下载 “u-boot-2018.03.*.tar.bz2”、"build.sh"和“mkimage-imx_4.14.98.*.tar.bz2”。 
=====> Input:
+
  复制到虚拟机的 “~/my-work/02\_source/”,并解压(解压命令如下):
make modules_install headers_install INSTALL_MOD_PATH=./modules 
 
  
=====> Output:
 
  INSTALL arch/arm64/crypto/aes-neon-blk.ko
 
  INSTALL arch/arm64/crypto/aes-neon-bs.ko
 
  ......
 
  INSTALL sound/usb/snd-usbmidi-lib.ko
 
  DEPMOD  4.14.98-g2ff648b
 
  CHK    include/generated/uapi/linux/version.h
 
</pre>
 
  
* 打包内核模块文件
+
=====> 输入指令:
<pre>
+
    tar jxf u-boot-2018.03.*.tar.bz2
=====> Input:
+
    tar jxf mkimage-imx_4.14.98.*.tar.bz2
tar cjvf kernel-modules.tar.bz2 -C modules lib   
+
* 进入内核源码目录
</pre>
 
  
### 目标文件 
 
**Image、*.dtb 和 kernel-modules.tar.bz2 即编译得到的目标文件,保存这三个文件**
 
  
 +
=====> 输入指令:
 +
    cd ~/my-work/02_source/
 +
* 配置交叉编译环境变量
  
## **编译u-boot文件**
 
### 编译前的准备
 
* 下载u-boot源码
 
打开网盘到 “2.1_OS_Linux-4.14.98 -> 02_Source”,下载 “u-boot-2018.03.*.tar.bz2”。
 
把源码包复制到虚拟机的 “~/my-work/02_source/”,并解压(解压命令如下):
 
<pre>
 
=====> Input:
 
tar xf u-boot-2018.03.*.tar.bz2
 
</pre>
 
* 进入内核源码目录 
 
<pre>
 
=====> Input:
 
cd ~/my-work/02_source/u-boot-2018.03 
 
</pre>
 
* 配置交叉编译环境变量 
 
<pre>
 
=====> Input:
 
source ~/my-work/03_toolchain/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.env 
 
</pre>
 
  
### 编译u-boot目标文件 
+
=====> 输入指令:
* 设置 TARGETEVKMODE 
+
    source ~/my-work/03_toolchain/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.env
<pre>
+
#### 5.3.2 编译u-boot目标文件
=====> Input:
+
=====> 输入指令:
TARGET_EVK_MODE=myimx8mevk-8mq 
+
    ./build.sh 8mek300 2g uboot
</pre>
+
**EVK_MODE:支持的设置为 8mevk、8mek300、8mmek240;**
**【说明】:TARGET_EVK_MODE 是根据开发板型号设置,可设置为 myimx8mevk-8mq, myimx8mek300-8mq**
 
* 生成目标 .config 文件 
 
<pre>
 
=====> Input:
 
make ${TARGET_EVK_MODE}_defconfig
 
  
=====> Output:
+
**EVK_MEM:支持的设置为 2g、1g、3g、4g。**
  HOSTCC  scripts/basic/fixdep
 
  HOSTCC  scripts/kconfig/conf.o
 
  SHIPPED scripts/kconfig/zconf.tab.c
 
  SHIPPED scripts/kconfig/zconf.lex.c
 
  SHIPPED scripts/kconfig/zconf.hash.c
 
  HOSTCC  scripts/kconfig/zconf.tab.o
 
  HOSTLD  scripts/kconfig/conf
 
#
 
# configuration written to .config
 
#
 
</pre>
 
* 编译u-boot目标文件   
 
<pre>
 
=====> Input:
 
make
 
  
=====> Output:
+
#### 5.3.3 目标文件
scripts/kconfig/conf  --silentoldconfig Kconfig
 
  CHK    include/config.h
 
  UPD    include/config.h
 
  CFG    u-boot.cfg
 
  GEN    include/autoconf.mk
 
  ......
 
  LD      spl/u-boot-spl
 
  OBJCOPY spl/u-boot-spl-nodtb.bin
 
  COPY    spl/u-boot-spl.bin
 
  CFGS    arch/arm/mach-imx/spl_sd.cfg.cfgtmp
 
  MKIMAGE SPL
 
  CFGCHK  u-boot.cfg
 
</pre>
 
* 复制u-boot目标文件     
 
<pre>
 
=====> Input:
 
cp arch/arm/dts/${TARGET_EVK_MODE}.dtb ./ 
 
</pre>
 
### 目标文件 
 
**${TARGETEVKMODE}.dtb、u-boot-nodtb.bin 和 u-boot-spl.bin 即编译得到的目标文件,保存这三个文件,在下一步的 bootloader 编译需要用到**
 
  
## **编译BootLoader*
+
**out目录中 *.bin 即编译得到的目标文件**
### 编译前的准备 
 
* 下载BootLoader编译工具
 
打开网盘到 “2.1_OS_Linux-4.14.98 -> 02Source”,下载 “mkimage-imx4.14.98.*.tar.bz2”。
 
把源码包复制到虚拟机的 “~/my-work/02_source/”,并解压(解压命令如下): 
 
<pre>
 
=====> Input:
 
tar xf mkimage-imx_4.14.98.*.tar.bz2 
 
</pre>
 
* 进入工具目录
 
<pre>
 
=====> Input:
 
cd ~/my-work/02_source/mkimage-imx_4.14.98 
 
</pre>
 
* 设置 TARGETEVKMODE 
 
<pre>
 
=====> Input:
 
TARGET_EVK_MODE=myimx8mevk-8mq
 
</pre>
 
**【说明】:TARGET_EVK_MODE 是根据开发板型号设置,可设置为 myimx8mevk-8mq, myimx8mek300-8mq**
 
* 复制依赖文件 把u-boot编译得到的三个文件复制过来
 
<pre>
 
=====> Input:
 
cp ../u-boot-2018.03/u-boot-nodtb.bin ./iMX8M/${TARGET_EVK_MODE}-nodtb.bin
 
cp ../u-boot-2018.03/spl/u-boot-spl.bin ./iMX8M/${TARGET_EVK_MODE}-spl.bin
 
cp ../u-boot-2018.03/${TARGET_EVK_MODE}.dtb ./iMX8M/${TARGET_EVK_MODE}.dtb
 
</pre>
 
  
### 编译BootLoader目标文件
 
* 输入编译指令 
 
<pre>
 
=====> Input:
 
make SOC=iMX8M ${TARGET_EVK_MODE%-*} OUTIMG=${TARGET_EVK_MODE}.bin 
 
  
=====> Output:
 
Compiling mkimage_imx8
 
PLAT=imx8mq HDMI=yes
 
Compiling mkimage_imx8
 
......
 
Second Loader IMAGE:
 
sld_header_off 0x57c00
 
sld_csf_off 0x58c20
 
sld hab block: 0x401fcdc0 0x57c00 0x1020
 
</pre>
 
* 复制BootLoader目标文件 
 
<pre>
 
=====> Input:
 
cp ./iMX8M/${TARGET_EVK_MODE}.bin ./ 
 
</pre>
 
### 目标文件 
 
**${TARGET_EVK_MODE}.bin 即编译得到的目标文件,保存这个文件** 
 
 
Web:  http://www.myzr.com.cn/
 
Wiki: http://wiki.myzr.com.cn/
 
BBS:  http://bbs.myzr.com.cn/
 
  
Tel: 0756-3628023/3628021
+
###5.4 编译所有目标文件
E-mail: service@myzr.com.cn
+
=====> 输入指令:
</pre>
+
    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;**
  
<br>
+
**EVK_MEM:支持的设置为 2g、1g、3g、4g。**
<br>
 
--------------------------------------------------------------------------------
 
<pre>
 
--------------------------------------------------------------------------------
 
* 珠海明远智睿科技有限公司 
 
* ZhuHai MYZR Technology CO.,LTD.
 
* Latest Update: 2019/11/08 
 
* Supporter: Tang Bin
 
--------------------------------------------------------------------------------
 
</pre>
 

2022年3月14日 (一) 09:26的最新版本

安装交叉编译工具

  • 创建安装目录

=====> 输入指令:

   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 jxf 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 jxf u-boot-2018.03..tar.bz2
   tar jxf 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。