MYZR-IMX8MP-EK314-Linux-5.10.72.编译手册
来自明远智睿的wiki
目录
[隐藏]MYZR-IMX8MP-EK314-Linux-5.10.72.编译手册
下载源码
- 打开网盘下载linux-5.10.72源码
- 打开网盘下载uboot-2021.04,mkimage-5.10.72源码
交叉编译工具
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
- 进入到uboot-2021.04目录
#输入 cd uboot-2021.04
- 生成.config文件
#输入 make O=build_myimx8mpek314 myimx8mpek314_defconfig
- 进入目录编译
#输入 cd build_myimx8mpek314 make
编译boot文件
- 进入到mkimage-5.10.72目录
#输入 cd mkimage-5.10.72
- 配置
#输入 DEPLOYDIR=iMX8M UBT_MAKE_DIR=${HOME}/work/linux/imx-linux-5.10.72/uboot-2021.04/build_myimx8mpek314 install -m 0775 ${UBT_MAKE_DIR}/tools/mkimage ${DEPLOYDIR}/mkimage_uboot install -m 0644 ${UBT_MAKE_DIR}/spl/u-boot-spl.bin ${DEPLOYDIR}/ install -m 0644 ${UBT_MAKE_DIR}/u-boot-nodtb.bin ${DEPLOYDIR}/ install -m 0644 ${UBT_MAKE_DIR}/arch/arm/dts/myimx8mpek314.dtb ${DEPLOYDIR}/
- 输入命令,生成boot-myimx8mpek314.bin文件
#输入 make SOC=iMX8MM dtbs=myimx8mpek314.dtb flash_ddr4_evk OUTIMG=boot-myimx8mpek314.bin
- 输出相关文件
#输入 cp iMX8M/boot-myimx8mpek314.bin ./
编译内核目标文件
- 进入源码目录
#输入 make O=build_imx imx_v8_defconfig
- 生成.config文件
#输出 make[1]: Entering directory '/home/zhongjy/work/linux/imx-linux- 5.10.72/linux-5.10.72/build_imx' GEN Makefile HOSTCC scripts/basic/fixdep HOSTCC scripts/kconfig/conf.o HOSTCC scripts/kconfig/confdata.o HOSTCC scripts/kconfig/expr.o LEX scripts/kconfig/lexer.lex.c YACC scripts/kconfig/parser.tab.[ch] HOSTCC scripts/kconfig/lexer.lex.o HOSTCC scripts/kconfig/parser.tab.o HOSTCC scripts/kconfig/preprocess.o HOSTCC scripts/kconfig/symbol.o HOSTCC scripts/kconfig/util.o HOSTLD scripts/kconfig/conf # # No change to .config # make[1]: Leaving directory '/home/zhongjy/work/linux/imx-linux- 5.10.72/linux-5.10.72/build_imx'
编译内核目标文件
- 输入指令运行交叉编译工具
#输入 source ~/toolchain/gcc-linaro/gcc-linaro-7.5.0-2019.12- x86_64_aarch64-linux-gnu.sh
- 进入.config目录
#输入 cd build_imx
- 输入指令
#输入 make Image
- 输出信息
#输出 ........ KSYMS .tmp_vmlinux.kallsyms2.S AS .tmp_vmlinux.kallsyms2.S LD vmlinux SORTTAB 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_imx
- 输入指令
#输入 make modules
- 输出信息
#输出 ......... LD [M] sound/soc/sof/imx/snd-sof-imx8m.ko LD [M] sound/soc/sof/imx/snd-sof-imx8ulp.ko LD [M] sound/soc/sof/snd-sof-of.ko LD [M] sound/soc/sof/snd-sof.ko LD [M] sound/soc/sof/xtensa/snd-sof-xtensa-dsp.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 sound/soc/sof/snd-sof-of.ko INSTALL sound/soc/sof/snd-sof.ko INSTALL sound/soc/sof/xtensa/snd-sof-xtensa-dsp.ko INSTALL sound/usb/snd-usb-audio.ko INSTALL sound/usb/snd-usbmidi-lib.ko DEPMOD 5.10.72-gdcb9071261a3 #输入压缩文件 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_imx
- 输入指令
#输入 make myzr/myimx8mpek314.dtb
- 输出信息
#输出 ......... DTC arch/arm64/boot/dts/myzr/myimx8mpek314.dtb
-------------------------------------------------------------------------------- * 珠海明远智睿科技有限公司 * ZhuHai MYZR Technology CO.,LTD. * Latest Update: 2023/4/07 * Supporter: Zhong JiaYi --------------------------------------------------------------------------------