MYZR-IMX8M-EK300 Linux-4.14.98 编译参考手册
来自明远智睿的wiki
Admin(讨论 | 贡献)2019年12月31日 (二) 11:57的版本 (创建页面,内容为“[^_^]: MY-IMX8M-EK300 Linux-4.14.98 编译参考手册 ## **安装交叉编译工具链** * 创建安装目录 <pre> =====> Input: mkdir ~/my-work/03_toolchain -p...”)
目录
安装交叉编译工具链
- 创建安装目录
=====> Input: mkdir ~/my-work/03_toolchain -p cd ~/my-work/03_toolchain
- 下载交叉编译工具
=====> 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
- 解压交叉编译工具
=====> Input: tar xf gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz -C ~/my-work/03_toolchain
- 创建交叉编译工具配置脚本
=====> 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
- 配置交叉编译环境变量
=====> Input: source ~/my-work/03_toolchain/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.env
- 检查安装
=====> Input: ${CROSS_COMPILE}gcc -v =====> 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)
编译内核文件
编译前的准备
- 创建编译工作目录
=====> Input: mkdir ~/my-work/02_source/ -p
- 下载内核源码
打开网盘到 “2.1_OS_Linux-4.14.98 -> 02_Source”,下载 “linux-4.14.98.*.tar.bz2”。
把源码包复制到虚拟机的 “~/my-work/02_source/”,并解压(解压命令如下):
=====> Input: cd ~/my-work/02_source tar xf linux-4.14.98.*.tar.bz2
- 进入内核源码目录
=====> Input: cd ~/my-work/02_source/linux-4.14.98
- 配置交叉编译环境变量
=====> Input: source ~/my-work/03_toolchain/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.env
编译内核目标文件
- 生成目标 .config 文件
=====> 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 #
- 编译内核目标文件
=====> Input: make Image =====> Output: scripts/kconfig/conf --silentoldconfig Kconfig CHK include/config/kernel.release UPD include/config/kernel.release WRAP arch/arm/include/generated/asm/bitsperlong.h ...... AR built-in.o LD vmlinux.o MODPOST vmlinux.o KSYM .tmp_kallsyms1.o KSYM .tmp_kallsyms2.o LD vmlinux SORTEX vmlinux SYSMAP System.map OBJCOPY arch/arm64/boot/Image
- 复制内核目标文件
=====> Input: cp arch/arm64/boot/Image ./
编译设备树目标文件
- 设置 TARGETEVKMODE
=====> Input: TARGET_EVK_MODE=myimx8mevk-8mq
【说明】:TARGET_EVK_MODE 是根据开发板型号设置,可设置为 myimx8mevk-8mq, myimx8mek300-8mq
- 执行编译命令
=====> Input: make myzr/${TARGET_EVK_MODE}.dtb =====> Output: CHK scripts/mod/devicetable-offsets.h DTC arch/arm64/boot/dts/myzr/${TARGET_EVK_MODE}.dtb
- 复制设备树目标文件
=====> Input: cp arch/arm64/boot/dts/myzr/${TARGET_EVK_MODE}.dtb ./
编译内核模块包
- 执行编译
=====> Input: make modules =====> Output: 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
- 创建内核模块的保存目录
=====> Input: mkdir modules
- 安装内核模块到指定目录
=====> Input: 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
- 打包内核模块文件
=====> Input: tar cjvf kernel-modules.tar.bz2 -C modules lib
目标文件
Image、*.dtb 和 kernel-modules.tar.bz2 即编译得到的目标文件,保存这三个文件
编译u-boot文件
编译前的准备
- 下载u-boot源码 打开网盘到 “2.1_OS_Linux-4.14.98 -> 02_Source”,下载 “u-boot-2018.03.*.tar.bz2”。 把源码包复制到虚拟机的 “~/my-work/02_source/”,并解压(解压命令如下):
=====> Input: tar xf u-boot-2018.03.*.tar.bz2
- 进入内核源码目录
=====> Input: cd ~/my-work/02_source/u-boot-2018.03
- 配置交叉编译环境变量
=====> Input: source ~/my-work/03_toolchain/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.env
编译u-boot目标文件
- 设置 TARGETEVKMODE
=====> Input: TARGET_EVK_MODE=myimx8mevk-8mq
【说明】:TARGET_EVK_MODE 是根据开发板型号设置,可设置为 myimx8mevk-8mq, myimx8mek300-8mq
- 生成目标 .config 文件
=====> Input: make ${TARGET_EVK_MODE}_defconfig =====> Output: 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 #
- 编译u-boot目标文件
=====> Input: make =====> Output: 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
- 复制u-boot目标文件
=====> Input: cp arch/arm/dts/${TARGET_EVK_MODE}.dtb ./
目标文件
${TARGETEVKMODE}.dtb、u-boot-nodtb.bin 和 u-boot-spl.bin 即编译得到的目标文件,保存这三个文件,在下一步的 bootloader 编译需要用到
编译BootLoader
编译前的准备
- 下载BootLoader编译工具 打开网盘到 “2.1_OS_Linux-4.14.98 -> 02Source”,下载 “mkimage-imx4.14.98.*.tar.bz2”。 把源码包复制到虚拟机的 “~/my-work/02_source/”,并解压(解压命令如下):
=====> Input: tar xf mkimage-imx_4.14.98.*.tar.bz2
- 进入工具目录
=====> Input: cd ~/my-work/02_source/mkimage-imx_4.14.98
- 设置 TARGETEVKMODE
=====> Input: TARGET_EVK_MODE=myimx8mevk-8mq
【说明】:TARGET_EVK_MODE 是根据开发板型号设置,可设置为 myimx8mevk-8mq, myimx8mek300-8mq
- 复制依赖文件 把u-boot编译得到的三个文件复制过来
=====> 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
编译BootLoader目标文件
- 输入编译指令
=====> 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
- 复制BootLoader目标文件
=====> Input: cp ./iMX8M/${TARGET_EVK_MODE}.bin ./
目标文件
${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 E-mail: service@myzr.com.cn </pre>
-------------------------------------------------------------------------------- * 珠海明远智睿科技有限公司 * ZhuHai MYZR Technology CO.,LTD. * Latest Update: 2019/11/08 * Supporter: Tang Bin --------------------------------------------------------------------------------