MYZR-IMX8MM-EK200-Linux-4.14.98.编译手册
来自明远智睿的wiki
目录
MYZR-IMX8MM-CB200-Linux-4.14.98.编译手册
下载源码
- 打开网盘下载linux-4.14.98源码
- 打开网盘下载imkimage-4.14.98 和uboot-2018.03源码
交叉编译工具
1.创建文件夹
#输入 mkdir toolchain mkdir toolchain/gcc-linaro cd toolchain/gcc-linaro
2.下载交叉编译工具
#输入 wget https://releases.linaro.org/components/toolchain/binaries/7.5-2019.12/aarch64-linux-gnu/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu.tar.xz
3.解压
#输入 tar -xf gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu.tar.xz
4.创建交叉编译工具配置脚本
#输入 cat << EOF > ~/toolchain/gcc-linaro/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu.sh #!/bin/sh export PATH=${HOME}/toolchain/gcc-linaro/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin:${PATH} export ARCH=arm64 export CROSS_COMPILE=aarch64-linux-gnu- EOF
5.添加可执行权限
#输入 chmod +x gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu.sh
6.配置交叉编译环境
#输入 source ~/toolchain/gcc-linaro/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu.sh
7.检查安装
#输入 ${CROSS_COMPILE}gcc -v #输出 Using built-in specs. COLLECT_GCC=aarch64-linux-gnu-gcc COLLECT_LTO_WRAPPER=/home/zhongjy/toolchain/gcc-linaro/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/../libexec/gcc/aarch64-linux-gnu/7.5.0/lto-wrapper Target: aarch64-linux-gnu Configured with: '/home/tcwg-buildslave/workspace/tcwg-make-release_0/snapshots/gcc.git~linaro-7.5-2019.12/configure' SHELL=/bin/bash --with-mpc=/home/tcwg-buildslave/workspace/tcwg-make-release_0/_build/builds/destdir/x86_64-unknown-linux-gnu --with-mpfr=/home/tcwg-buildslave/workspace/tcwg-make-release_0/_build/builds/destdir/x86_64-unknown-linux-gnu --with-gmp=/home/tcwg-buildslave/workspace/tcwg-make-release_0/_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_0/_build/sysroots/aarch64-linux-gnu --with-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release_0/_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_0/_build/builds/destdir/x86_64-unknown-linux-gnu Thread model: posix gcc version 7.5.0 (Linaro GCC 7.5-2019.12)
编译image-boot
编译uboot
- 提示: 编译 boot 文件也可以通过执行 ./make_uboot.sh 并根据提示进行编译。
- 进入到uboot-2018.03目录
#输入 cd uboot-2018.03
- 生成.config文件
#输入 make myimx8mmek200-2g_defconfig O=build-myimx8mmek240-2g
- 进入目录编译生成u-boot-spl.bin,u-boot-nodtb.bin,myimx8mmek240.dtb 文件
#输入 cd build-myimx8mmek240-2g make
- 把相关文件放进文件夹
#输入 cd .. mkdir image-uboot cp build-myimx8mmek240-2g/spl/u-boot-spl.bin image-uboot cp build-myimx8mmek240-2g/u-boot-nodtb.bin image-uboot cp build-myimx8mmek240-2g/arch/arm/dts/myimx8mmek240.dtb image-uboot
编译boot文件
- 提示: 编译imkimage 文件也可以通过执行 ./make_boot.sh 并根据提示进行编译。
- 进入到imkimage-4.14.98目录
#输入 cd imkimage-4.14.98
- 编译生成myimx8mmek200-2g.bin 文件
#输入 cp ../uboot-2018.03/image-uboot/u-boot-nodtb.bin ./iMX8M/myimx8mmek200-2g-nodtb.bin cp ../uboot-2018.03/image-uboot/u-boot-spl.bin ./iMX8M/myimx8mmek200-2g-spl.bin cp ../uboot-2018.03/image-uboot/myimx8mmek200.dtb ./iMX8M/myimx8mmek200.dtb make myimx8mm SOC=iMX8MM DTB=myimx8mmek200.dtb OUTIMG=myimx8mmek200-2g.bin
- 输出相关文件
#输入 cp iMX8M/myimx8mmek200-2g.bin ./
编译内核
提示: 编译kernel 文件也可以通过执行 make_kern.sh 并根据提示进行编译。
编译.config
- 进入源码目录
#输入 cd linux-4.14.98 make O=build_myimx8mm myimx8mm_defconfig
- 生成.config文件
#输出 ................. GEN ./Makefile 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 # .................
编译内核目标文件
- 输入指令运行交叉编译工具
#输入 source ~/toolchain/gcc-linaro/gcc-linaro-7.5.0-2019.12- x86_64_aarch64-linux-gnu.sh
- 进入.config目录
#输入 cd build_myimx8mm
- 输入指令
#输入 make Image
- 输出信息
#输出 ......... MODPOST vmlinux.o KSYM .tmp_kallsyms1.o KSYM .tmp_kallsyms2.o LD vmlinux SORTEX vmlinux SYSMAP System.map OBJCOPY arch/arm64/boot/Image
编译内核模块包
- 输入指令运行交叉编译工具
#输入 source ~/toolchain/gcc-linaro/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu.sh
- 进入.config目录
#输入 cd build_myimx8mm
- 输入指令
#输入 make modules
- 输出信息
#输出 ......... LD [M] net/netfilter/x_tables.ko LD [M] net/netfilter/xt_CHECKSUM.ko LD [M] net/netfilter/xt_LOG.ko LD [M] net/netfilter/xt_addrtype.ko LD [M] net/netfilter/xt_conntrack.ko LD [M] net/netfilter/xt_nat.ko LD [M] net/netfilter/xt_tcpudp.ko LD [M] sound/core/snd-hwdep.ko LD [M] sound/soc/bcm/snd-soc-bcm2835-i2s.ko LD [M] sound/usb/snd-usb-audio.ko LD [M] sound/usb/snd-usbmidi-lib.ko
- 创建文件夹
#输入 mkdir modules make modules_install INSTALL_MOD_PATH=./modules #输出信息 ......... INSTALL net/netfilter/xt_nat.ko INSTALL net/netfilter/xt_tcpudp.ko INSTALL sound/core/snd-hwdep.ko INSTALL sound/soc/bcm/snd-soc-bcm2835-i2s.ko INSTALL sound/usb/snd-usb-audio.ko INSTALL sound/usb/snd-usbmidi-lib.ko DEPMOD 4.14.98-gda548b57eb4f #输入压缩文件 tar cjf kernel-modules.tar.bz2 -C modules lib
编译设备树文件
- 输入指令运行交叉编译工具
#输入 source ~/toolchain/gcc-linaro/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu.sh
- 进入.config目录
#输入 cd build_myimx8mm
- 输入指令
#输入 make myzr/myimx8mmek200.dtb
- 输出信息
#输出 CHK scripts/mod/devicetable-offsets.h DTC arch/arm64/boot/dts/myzr/myimx8mmek200.dtb
-------------------------------------------------------------------------------- * 珠海明远智睿科技有限公司 * ZhuHai MYZR Technology CO.,LTD. * Latest Update: 2023/4/4 * Supporter: Zhong JiaYi --------------------------------------------------------------------------------