“MYZR-IMX Linux-4.9.88 编译参考手册”的版本间的差异
(创建页面,内容为“ [^_^]: MY-IMX Linux-4.9.88 编译参考手册 ## **下载相关的文件** ### 交叉编译工具链 **MY-IMX8M 交叉编译工具链** 网盘位置: 2.4_OS_Linu...”) |
|||
第1行: | 第1行: | ||
[^_^]: MY-IMX Linux-4.9.88 编译参考手册 | [^_^]: MY-IMX Linux-4.9.88 编译参考手册 | ||
+ | |||
+ | ## **必要的说明** | ||
+ | **A7系列** 包括 MY-IMX6-EK140、MY-IMX6-EK140P。 | ||
+ | **A9系列** 包括 MY-IMX6-EK200、MY-IMX6-EK314、MY-IMX6-EK336。 | ||
+ | |||
+ | <br/> | ||
## **下载相关的文件** | ## **下载相关的文件** | ||
− | ### 交叉编译工具链 | + | #### 交叉编译工具链 |
− | ** | + | **IMX8M**:打开网盘到 **2.4_OS_Linux-4.9.88 -> 03_toolchain**,下载 **MY-IMX8M** 目录。 |
− | + | **A7系列**:打开网盘到 **2.4_OS_Linux-4.9.88 -> 03_toolchain**,下载 **MY-IMX-A7** 目录。 | |
− | + | **A9系列**:打开网盘到 **2.4_OS_Linux-4.9.88 -> 03_toolchain**,下载 **MY-IMX-A9** 目录。 | |
− | ** | + | #### 源码 |
− | + | **u-boot**:打开网盘到 **2.4_OS_Linux-4.9.88 -> 02_source**,下载 **u-boot-2016.03-*.tar.bz2**。 | |
− | + | **Kernel**:打开网盘到 **2.4_OS_Linux-4.9.88 -> 02_source**,下载 **linux-4.9.88-*.tar.bz2**。 | |
− | + | ||
− | ** | + | <br/> |
− | |||
− | |||
− | |||
− | ### 源码 | ||
− | **u-boot | ||
− | |||
− | |||
− | **Kernel | ||
− | |||
− | |||
## **安装交叉编译工具链** | ## **安装交叉编译工具链** | ||
第163行: | 第159行: | ||
Thread model: posix | Thread model: posix | ||
gcc version 7.3.0 (GCC) | gcc version 7.3.0 (GCC) | ||
+ | </pre> | ||
+ | |||
+ | <br> | ||
+ | |||
+ | ## **u-boot编译** | ||
+ | **说明**:MY-IMX8M 不需要编译此 u-boot。 | ||
+ | ### 编译前的准备 | ||
+ | * 创建编译工作目录 | ||
+ | <pre> | ||
+ | =====> Input: | ||
+ | mkdir ~/my-work/02_source/ -p | ||
+ | </pre> | ||
+ | * 解压源码包到工作目录 | ||
+ | <pre> | ||
+ | =====> Input: | ||
+ | tar xf u-boot-2016.03-svn*.tar.bz2 -C ~/my-work/02_source/ | ||
+ | </pre> | ||
+ | ### 编译u-boot目标文件 | ||
+ | * 进入源码目录 | ||
+ | <pre> | ||
+ | =====> Input: | ||
+ | cd ~/my-work/02_source/u-boot-2016.03 | ||
+ | </pre> | ||
+ | * 生成目标开发板的 .config 文件 | ||
+ | <pre> | ||
+ | =====> Input: | ||
+ | make myimx6ek140p-6y-256m-emmc_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 | ||
+ | # | ||
+ | </pre> | ||
+ | * 执行编译 | ||
+ | <pre> | ||
+ | =====> Input: | ||
+ | make | ||
+ | |||
+ | =====> Output: | ||
+ | scripts/kconfig/conf --silentoldconfig Kconfig | ||
+ | CHK include/config.h | ||
+ | UPD include/config.h | ||
+ | GEN include/autoconf.mk | ||
+ | GEN include/autoconf.mk.dep | ||
+ | CHK include/config/uboot.release | ||
+ | CHK include/generated/timestamp_autogenerated.h | ||
+ | CFG u-boot.cfg | ||
+ | ...... | ||
+ | LD u-boot | ||
+ | OBJCOPY u-boot-nodtb.bin | ||
+ | OBJCOPY u-boot.srec | ||
+ | SYM u-boot.sym | ||
+ | COPY u-boot.bin | ||
+ | CFGS board/myzr/myimx6/myimx6a7-6y-ddr3.cfg.cfgtmp | ||
+ | MKIMAGE u-boot.imx | ||
+ | </pre> | ||
+ | **Note: 如果有提示 “cc1: error”,通常是交叉编译工具的配置没生效,可以按前面 “交叉编译工具链安装” 中的 “source 工具链配置文件” 操作一次后再执行此步骤。** | ||
+ | |||
+ | * 目标文件改名 | ||
+ | <pre> | ||
+ | =====> Input: | ||
+ | cp u-boot.imx uboot-myimx6ek140p-6y-256m-emmc.imx | ||
+ | </pre> | ||
+ | ### 编译u-boot环境变量脚本 | ||
+ | <pre> | ||
+ | =====> Input: | ||
+ | ./tools/mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "myzr bootscripts" -d bootscripts/myimxa7_l4988_emmc_script.cmd my_environment_emmc.scr | ||
+ | |||
+ | =====> Output: | ||
+ | Image Name: myzr bootscripts | ||
+ | Created: Tue Dec 18 14:16:48 2018 | ||
+ | Image Type: ARM Linux Script (uncompressed) | ||
+ | Data Size: 1433 Bytes = 1.40 kB = 0.00 MB | ||
+ | Load Address: 00000000 | ||
+ | Entry Point: 00000000 | ||
+ | Contents: | ||
+ | Image 0: 1425 Bytes = 1.39 kB = 0.00 MB | ||
+ | </pre> | ||
+ | ### 目标文件 | ||
+ | **uboot-myimx6ek140p-6y-256m-emmc.imx 和 my_environment_emmc.scr 即编译得到的目标文件,保存这两个文件** | ||
+ | |||
+ | <br/> | ||
+ | ## **内核编译** | ||
+ | ### 编译前的准备 | ||
+ | * 创建编译工作目录 | ||
+ | <pre> | ||
+ | =====> Input: | ||
+ | mkdir ~/my-work/02_source/ -p | ||
+ | </pre> | ||
+ | * 解压源码包到工作目录 | ||
+ | <pre> | ||
+ | =====> Input: | ||
+ | tar xf linux-4.9.88-svn*.tar.bz2 -C ~/my-work/02_source/ | ||
+ | </pre> | ||
+ | ### 编译内核目标文件 | ||
+ | * 进入内核源码目录 | ||
+ | <pre> | ||
+ | =====> Input: | ||
+ | cd ~/my-work/02_source/linux-4.9.88 | ||
+ | </pre> | ||
+ | * 生成目标平台的 .config 文件 | ||
+ | <pre> | ||
+ | =====> Input: | ||
+ | make myimxa7_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 | ||
+ | # | ||
+ | </pre> | ||
+ | **Note: 如果有“Can't find default configuration "arch/x86/configs” 的错误,是因为交叉编译工具链的配置没有生效,可以按前面 “交叉编译工具链安装” 中的 “source 工具链配置文件” 操作一次后再执行此步骤** | ||
+ | |||
+ | * 编译内核目标文件 | ||
+ | <pre> | ||
+ | =====> Input: | ||
+ | make zImage | ||
+ | |||
+ | =====> Output: | ||
+ | scripts/kconfig/conf --silentoldconfig Kconfig | ||
+ | CHK include/config/kernel.release | ||
+ | UPD include/config/kernel.release | ||
+ | WRAP arch/arm/include/generated/asm/bitsperlong.h | ||
+ | ...... | ||
+ | AS arch/arm/boot/compressed/piggy.o | ||
+ | LD arch/arm/boot/compressed/vmlinux | ||
+ | OBJCOPY arch/arm/boot/zImage | ||
+ | Kernel: arch/arm/boot/zImage is ready | ||
+ | </pre> | ||
+ | * 内核目标文件改名 | ||
+ | <pre> | ||
+ | =====> Input: | ||
+ | cp arch/arm/boot/zImage zImage-myimxa7 | ||
+ | </pre> | ||
+ | ### 编译设备树目标文件 | ||
+ | * 执行编译命令 | ||
+ | <pre> | ||
+ | =====> Input: | ||
+ | make myimx6ek140p-6y-256m-emmc.dtb | ||
+ | |||
+ | =====> Output: | ||
+ | DTC arch/arm/boot/dts/myimx6ek140p-6y-256m-emmc.dtb | ||
+ | </pre> | ||
+ | * 复制设备树目标文件 | ||
+ | <pre> | ||
+ | =====> Input: | ||
+ | cp arch/arm/boot/dts/myimx6ek140p-6y-256m-emmc.dtb ./ | ||
+ | </pre> | ||
+ | |||
+ | ### 编译内核模块包 | ||
+ | * 执行编译 | ||
+ | <pre> | ||
+ | =====> 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 | ||
+ | </pre> | ||
+ | * 创建内核模块的保存目录 | ||
+ | <pre> | ||
+ | =====> Input: | ||
+ | mkdir modules | ||
+ | </pre> | ||
+ | * 安装内核模块到指定目录 | ||
+ | <pre> | ||
+ | =====> Input: | ||
+ | make modules_install INSTALL_MOD_PATH=./modules | ||
+ | |||
+ | =====> Output: | ||
+ | INSTALL crypto/echainiv.ko | ||
+ | INSTALL crypto/tcrypt.ko | ||
+ | ...... | ||
+ | INSTALL sound/usb/snd-usb-audio.ko | ||
+ | INSTALL sound/usb/snd-usbmidi-lib.ko | ||
+ | DEPMOD 4.9.88-myimx_armv7-svn432 | ||
+ | </pre> | ||
+ | * 打包内核模块文件 | ||
+ | <pre> | ||
+ | =====> Input: | ||
+ | tar cjf kernel-modules-myimxa9.tar.bz2 -C modules lib | ||
+ | </pre> | ||
+ | ### 目标文件 | ||
+ | **zImage-myimxa7、myimx6ek140p-6y-256m-emmc.dtb 和 kernel-modules-myimxa9.tar.bz2 即编译得到的目标文件,保存这三个文件** | ||
+ | |||
+ | <br/> | ||
+ | |||
+ | ## **Linux C程序编译** | ||
+ | ### 准备源码 | ||
+ | 打开网盘到 **5_MY-Demo -> MY-Linux-C-Demo**,下载 **hello.c** 文件,并复制到虚拟机。 | ||
+ | ### 编译目标文件 | ||
+ | <pre> | ||
+ | =====> Input: | ||
+ | $CC hello.c -o hello.out | ||
+ | </pre> | ||
+ | **Note: 如果有“未找到命令”的信息,是因为交叉编译工具链的配置没有生效,可以按前面 “交叉编译工具链安装” 中的 “source 工具链配置文件” 操作一次后再执行此步骤** | ||
+ | ### 运行Linux C目标程序 | ||
+ | * 把编译得到的 hello.out 复制到开发板上 | ||
+ | * 在开发板上运行Linux C目标程序 | ||
+ | <pre> | ||
+ | =====> Input: | ||
+ | ./hello.out | ||
+ | |||
+ | =====> Output: | ||
+ | MYZR Technology Co.,Ltd. | ||
+ | |||
+ | 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> | ||
+ | **Note: 如果有“Permission denied”的信息,通常是目标程序没有可执行权限,可以参照下面指令增加目标文件的可执行权限后再运行程序** | ||
+ | <pre> | ||
+ | =====> Input: | ||
+ | chmod +x ./hello.out | ||
</pre> | </pre> | ||
第169行: | 第398行: | ||
## **Linux QT5程序编译** | ## **Linux QT5程序编译** | ||
### 准备源码 | ### 准备源码 | ||
− | * | + | 打开网盘到 **5_MY-Demo**,下载 **MY-Linux-QT5-Demo-AboutUs-svn*.tar.bz2** 文件,并复制到虚拟机。 |
− | |||
− | |||
* 解压源码包到工作目录 | * 解压源码包到工作目录 | ||
<pre> | <pre> | ||
第177行: | 第404行: | ||
tar xf MY-Linux-QT5-Demo-AboutUs-svn*.tar.bz2 -C ~/my-work/02_source/ | tar xf MY-Linux-QT5-Demo-AboutUs-svn*.tar.bz2 -C ~/my-work/02_source/ | ||
</pre> | </pre> | ||
− | ### | + | ### QT程序编译 |
* 进入源码目录 | * 进入源码目录 | ||
<pre> | <pre> | ||
第189行: | 第416行: | ||
=====> Output: | =====> Output: | ||
− | Info: creating stash file /home/myzr/my-work/02_source/AboutUs/.qmake.stash | + | Info: creating stash file /home/myzr/my-work/02_source/my-demo/myzr-qt5-demo/AboutUs/.qmake.stash |
</pre> | </pre> | ||
**Note: 如果有“未找到 'qamke' 命令”的信息,是因为交叉编译工具链的配置没有生效,可以按前面 “交叉编译工具链安装” 中的 “source 工具链配置文件” 操作一次后再执行此步骤** | **Note: 如果有“未找到 'qamke' 命令”的信息,是因为交叉编译工具链的配置没有生效,可以按前面 “交叉编译工具链安装” 中的 “source 工具链配置文件” 操作一次后再执行此步骤** | ||
第198行: | 第425行: | ||
=====> Output: | =====> Output: | ||
− | / | + | /home/myzr/my-work/03_toolchain/fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-neon-toolchain-4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr/bin/qt5/uic widget.ui -o ui_widget.h |
...... | ...... | ||
− | arm-poky-linux-gnueabi-g++ -march= | + | arm-poky-linux-gnueabi-g++ -march=armv7-a -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 --sysroot=/home/myzr/my-work/03_toolchain/fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-neon-toolchain-4.9.88-2.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed --sysroot=/home/myzr/my-work/03_toolchain/fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-neon-toolchain-4.9.88-2.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi -Wl,-O1 -o AboutUs main.o widget.o qrc_source.o moc_widget.o -lQt5Widgets -lQt5Gui -lQt5Core -lGLESv2 -lEGL -lpthread |
</pre> | </pre> | ||
### 运行Linux QT5目标程序 | ### 运行Linux QT5目标程序 | ||
第218行: | 第445行: | ||
可以看到开发板显示屏上输出了 MYZR 的 Logo 和一些信息。 | 可以看到开发板显示屏上输出了 MYZR 的 Logo 和一些信息。 | ||
− | <br> | + | <br/> |
+ | <br/> | ||
+ | |||
+ | -------------------------------------------------------------------------------- | ||
+ | <pre> | ||
+ | -------------------------------------------------------------------------------- | ||
+ | * 珠海明远智睿科技有限公司 | ||
+ | * ZhuHai MYZR Technology CO.,LTD. | ||
+ | * Latest Update: 2018/12/18 | ||
+ | * Supporter: Tang Bin | ||
+ | -------------------------------------------------------------------------------- | ||
+ | </pre> |
2018年12月18日 (二) 15:57的版本
必要的说明
A7系列 包括 MY-IMX6-EK140、MY-IMX6-EK140P。
A9系列 包括 MY-IMX6-EK200、MY-IMX6-EK314、MY-IMX6-EK336。
下载相关的文件
交叉编译工具链
IMX8M:打开网盘到 2.4_OS_Linux-4.9.88 -> 03_toolchain,下载 MY-IMX8M 目录。
A7系列:打开网盘到 2.4_OS_Linux-4.9.88 -> 03_toolchain,下载 MY-IMX-A7 目录。
A9系列:打开网盘到 2.4_OS_Linux-4.9.88 -> 03_toolchain,下载 MY-IMX-A9 目录。
源码
u-boot:打开网盘到 2.4_OS_Linux-4.9.88 -> 02_source,下载 u-boot-2016.03-*.tar.bz2。
Kernel:打开网盘到 2.4_OS_Linux-4.9.88 -> 02_source,下载 linux-4.9.88-*.tar.bz2。
安装交叉编译工具链
MY-IMX8 系列交叉编译工具链安装
1. 执行安装
=====> Input: ./fsl-imx-xwayland-glibc-x86_64-meta-toolchain-qt5-aarch64-toolchain-4.9.88-2.0.0.sh =====> Output: NXP i.MX Release Distro SDK installer version 4.9.88-2.0.0 ========================================================== Enter target directory for SDK (default: /opt/fsl-imx-xwayland/4.9.88-2.0.0): =====> Input: /home/myzr/my-work/03_toolchain/fsl-imx-xwayland-glibc-x86_64-meta-toolchain-qt5-aarch64-toolchain-4.9.88-2.0.0 =====> Output: You are about to install the SDK to "/home/myzr/my-work/03_toolchain/fsl-imx-xwayland-glibc-x86_64-meta-toolchain-qt5-aarch64-toolchain-4.9.88-2.0.0". Proceed[Y/n]? =====> Input: y =====> Output: Extracting SDK.......................................................................................................................................................................................................................done Setting it up...done SDK has been successfully set up and is ready to be used. Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g. $ . /home/myzr/my-work/03_toolchain/fsl-imx-xwayland-glibc-x86_64-meta-toolchain-qt5-aarch64-toolchain-4.9.88-2.0.0/environment-setup-aarch64-poky-linux
2. source 工具链配置文件
=====> Input: source /home/myzr/my-work/03_toolchain/fsl-imx-xwayland-glibc-x86_64-meta-toolchain-qt5-aarch64-toolchain-4.9.88-2.0.0/environment-setup-aarch64-poky-linux
3. 检验交叉编译工具安装
=====> Input: $CC -v =====> Output: Using built-in specs. COLLECT_GCC=aarch64-poky-linux-gcc COLLECT_LTO_WRAPPER=/home/myzr/my-work/03_toolchain/fsl-imx-xwayland-glibc-x86_64-meta-toolchain-qt5-aarch64-toolchain-4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr/libexec/aarch64-poky-linux/gcc/aarch64-poky-linux/7.3.0/lto-wrapper Target: aarch64-poky-linux Configured with: ../../../../../../work-shared/gcc-7.3.0-r0/gcc-7.3.0/configure --build=x86_64-linux --host=x86_64-pokysdk-linux --target=aarch64-poky-linux --prefix=/opt/fsl-imx-xwayland/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr --exec_prefix=/opt/fsl-imx-xwayland/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr --bindir=/opt/fsl-imx-xwayland/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux --sbindir=/opt/fsl-imx-xwayland/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux --libexecdir=/opt/fsl-imx-xwayland/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr/libexec/aarch64-poky-linux --datadir=/opt/fsl-imx-xwayland/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr/share --sysconfdir=/opt/fsl-imx-xwayland/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/etc --sharedstatedir=/opt/fsl-imx-xwayland/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/com --localstatedir=/opt/fsl-imx-xwayland/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/var --libdir=/opt/fsl-imx-xwayland/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr/lib/aarch64-poky-linux --includedir=/opt/fsl-imx-xwayland/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr/include --oldincludedir=/opt/fsl-imx-xwayland/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr/include --infodir=/opt/fsl-imx-xwayland/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr/share/info --mandir=/opt/fsl-imx-xwayland/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr/share/man --disable-silent-rules --disable-dependency-tracking --with-libtool-sysroot=/home/myzr/my-work/imx-4.9.88-2.0.0_ga/imx8mqevk__fsl-imx-xwayland/tmp/work/x86_64-nativesdk-pokysdk-linux/gcc-cross-canadian-aarch64/7.3.0-r0/recipe-sysroot --with-gnu-ld --enable-shared --enable-languages=c,c++ --enable-threads=posix --enable-multilib --enable-c99 --enable-long-long --enable-symvers=gnu --enable-libstdcxx-pch --program-prefix=aarch64-poky-linux- --without-local-prefix --enable-lto --enable-libssp --enable-libitm --disable-bootstrap --disable-libmudflap --with-system-zlib --with-linker-hash-style=gnu --enable-linker-build-id --with-ppl=no --with-cloog=no --enable-checking=release --enable-cheaders=c_global --without-isl --with-gxx-include-dir=/not/exist/usr/include/c++/7.3.0 --with-build-time-tools=/home/myzr/my-work/imx-4.9.88-2.0.0_ga/imx8mqevk__fsl-imx-xwayland/tmp/work/x86_64-nativesdk-pokysdk-linux/gcc-cross-canadian-aarch64/7.3.0-r0/recipe-sysroot-native/usr/aarch64-poky-linux/bin --with-sysroot=/not/exist --with-build-sysroot=/home/myzr/my-work/imx-4.9.88-2.0.0_ga/imx8mqevk__fsl-imx-xwayland/tmp/work/x86_64-nativesdk-pokysdk-linux/gcc-cross-canadian-aarch64/7.3.0-r0/recipe-sysroot --without-long-double-128 --enable-poison-system-directories --with-mpfr=/home/myzr/my-work/imx-4.9.88-2.0.0_ga/imx8mqevk__fsl-imx-xwayland/tmp/work/x86_64-nativesdk-pokysdk-linux/gcc-cross-canadian-aarch64/7.3.0-r0/recipe-sysroot --with-mpc=/home/myzr/my-work/imx-4.9.88-2.0.0_ga/imx8mqevk__fsl-imx-xwayland/tmp/work/x86_64-nativesdk-pokysdk-linux/gcc-cross-canadian-aarch64/7.3.0-r0/recipe-sysroot --enable-nls --enable-initfini-array --enable-__cxa_atexit Thread model: posix gcc version 7.3.0 (GCC)
MY-IMX-A7 系列交叉编译工具链安装
1. 执行安装
=====> Input: ./fsl-imx-fb-glibc-x86_64-meta-toolchain-cortexa7hf-neon-toolchain-4.9.88-2.0.0.sh =====> Output: NXP i.MX Release Distro SDK installer version 4.9.88-2.0.0 ========================================================== Enter target directory for SDK (default: /opt/fsl-imx-fb/4.9.88-2.0.0): =====> Input: /home/myzr/my-work/03_toolchain/fsl-imx-fb-glibc-x86_64-meta-toolchain-cortexa7hf-neon-toolchain-4.9.88-2.0.0 =====> Output: You are about to install the SDK to "/home/myzr/my-work/03_toolchain/fsl-imx-fb-glibc-x86_64-meta-toolchain-cortexa7hf-neon-toolchain-4.9.88-2.0.0". Proceed[Y/n]? =====> Input: y =====> Output: Extracting SDK.........................done Setting it up...done SDK has been successfully set up and is ready to be used. Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g. $ . /home/myzr/my-work/03_toolchain/fsl-imx-fb-glibc-x86_64-meta-toolchain-cortexa7hf-neon-toolchain-4.9.88-2.0.0/environment-setup-cortexa7hf-neon-poky-linux-gnueabi
2. source 工具链配置文件
=====> Input: source /home/myzr/my-work/03_toolchain/fsl-imx-fb-glibc-x86_64-meta-toolchain-cortexa7hf-neon-toolchain-4.9.88-2.0.0/environment-setup-cortexa7hf-neon-poky-linux-gnueabi
3. 检验交叉编译工具安装
=====> Input: $CC -v =====> Output: Using built-in specs. COLLECT_GCC=arm-poky-linux-gnueabi-gcc COLLECT_LTO_WRAPPER=/home/myzr/my-work/03_toolchain/fsl-imx-fb-glibc-x86_64-meta-toolchain-cortexa7hf-neon-toolchain-4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/7.3.0/lto-wrapper Target: arm-poky-linux-gnueabi Configured with: ../../../../../../work-shared/gcc-7.3.0-r0/gcc-7.3.0/configure --build=x86_64-linux --host=x86_64-pokysdk-linux --target=arm-poky-linux-gnueabi --prefix=/opt/fsl-imx-fb/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr --exec_prefix=/opt/fsl-imx-fb/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr --bindir=/opt/fsl-imx-fb/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi --sbindir=/opt/fsl-imx-fb/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi --libexecdir=/opt/fsl-imx-fb/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi --datadir=/opt/fsl-imx-fb/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr/share --sysconfdir=/opt/fsl-imx-fb/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/etc --sharedstatedir=/opt/fsl-imx-fb/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/com --localstatedir=/opt/fsl-imx-fb/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/var --libdir=/opt/fsl-imx-fb/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi --includedir=/opt/fsl-imx-fb/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr/include --oldincludedir=/opt/fsl-imx-fb/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr/include --infodir=/opt/fsl-imx-fb/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr/share/info --mandir=/opt/fsl-imx-fb/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr/share/man --disable-silent-rules --disable-dependency-tracking --with-libtool-sysroot=/home/myzr/my-work/imx-4.9.88-2.0.0_ga/imx6qpdlsolox__fsl-imx-fb/tmp/work/x86_64-nativesdk-pokysdk-linux/gcc-cross-canadian-arm/7.3.0-r0/recipe-sysroot --with-gnu-ld --enable-shared --enable-languages=c,c++ --enable-threads=posix --enable-multilib --enable-c99 --enable-long-long --enable-symvers=gnu --enable-libstdcxx-pch --program-prefix=arm-poky-linux-gnueabi- --without-local-prefix --enable-lto --enable-libssp --enable-libitm --disable-bootstrap --disable-libmudflap --with-system-zlib --with-linker-hash-style=gnu --enable-linker-build-id --with-ppl=no --with-cloog=no --enable-checking=release --enable-cheaders=c_global --without-isl --with-gxx-include-dir=/not/exist/usr/include/c++/7.3.0 --with-build-time-tools=/home/myzr/my-work/imx-4.9.88-2.0.0_ga/imx6qpdlsolox__fsl-imx-fb/tmp/work/x86_64-nativesdk-pokysdk-linux/gcc-cross-canadian-arm/7.3.0-r0/recipe-sysroot-native/usr/arm-poky-linux-gnueabi/bin --with-sysroot=/not/exist --with-build-sysroot=/home/myzr/my-work/imx-4.9.88-2.0.0_ga/imx6qpdlsolox__fsl-imx-fb/tmp/work/x86_64-nativesdk-pokysdk-linux/gcc-cross-canadian-arm/7.3.0-r0/recipe-sysroot --without-long-double-128 --enable-poison-system-directories --with-mpfr=/home/myzr/my-work/imx-4.9.88-2.0.0_ga/imx6qpdlsolox__fsl-imx-fb/tmp/work/x86_64-nativesdk-pokysdk-linux/gcc-cross-canadian-arm/7.3.0-r0/recipe-sysroot --with-mpc=/home/myzr/my-work/imx-4.9.88-2.0.0_ga/imx6qpdlsolox__fsl-imx-fb/tmp/work/x86_64-nativesdk-pokysdk-linux/gcc-cross-canadian-arm/7.3.0-r0/recipe-sysroot --enable-nls --enable-initfini-array Thread model: posix gcc version 7.3.0 (GCC)
MY-IMX-A9 系列交叉编译工具链安装
1. 执行安装
=====> Input: ./fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-neon-toolchain-4.9.88-2.0.0.sh =====> Output: NXP i.MX Release Distro SDK installer version 4.9.88-2.0.0 ========================================================== Enter target directory for SDK (default: /opt/fsl-imx-fb/4.9.88-2.0.0): =====> Input: /home/myzr/my-work/03_toolchain/fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-neon-toolchain-4.9.88-2.0.0 =====> Output: You are about to install the SDK to "/home/myzr/my-work/03_toolchain/fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-neon-toolchain-4.9.88-2.0.0". Proceed[Y/n]? =====> Input: y =====> Output: Extracting SDK..................................................................................................................................................................................................done Setting it up...done SDK has been successfully set up and is ready to be used. Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g. $ . /home/myzr/my-work/03_toolchain/fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-neon-toolchain-4.9.88-2.0.0/environment-setup-cortexa9hf-neon-poky-linux-gnueabi
2. source 工具链配置文件
=====> Input: source /home/myzr/my-work/03_toolchain/fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-neon-toolchain-4.9.88-2.0.0/environment-setup-cortexa9hf-neon-poky-linux-gnueabi
3. 检验交叉编译工具安装
=====> Input: $CC -v =====> Output: Using built-in specs. COLLECT_GCC=arm-poky-linux-gnueabi-gcc COLLECT_LTO_WRAPPER=/home/myzr/my-work/03_toolchain/fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-neon-toolchain-4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/7.3.0/lto-wrapper Target: arm-poky-linux-gnueabi Configured with: ../../../../../../work-shared/gcc-7.3.0-r0/gcc-7.3.0/configure --build=x86_64-linux --host=x86_64-pokysdk-linux --target=arm-poky-linux-gnueabi --prefix=/opt/fsl-imx-fb/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr --exec_prefix=/opt/fsl-imx-fb/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr --bindir=/opt/fsl-imx-fb/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi --sbindir=/opt/fsl-imx-fb/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi --libexecdir=/opt/fsl-imx-fb/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi --datadir=/opt/fsl-imx-fb/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr/share --sysconfdir=/opt/fsl-imx-fb/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/etc --sharedstatedir=/opt/fsl-imx-fb/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/com --localstatedir=/opt/fsl-imx-fb/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/var --libdir=/opt/fsl-imx-fb/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi --includedir=/opt/fsl-imx-fb/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr/include --oldincludedir=/opt/fsl-imx-fb/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr/include --infodir=/opt/fsl-imx-fb/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr/share/info --mandir=/opt/fsl-imx-fb/4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr/share/man --disable-silent-rules --disable-dependency-tracking --with-libtool-sysroot=/home/myzr/my-work/imx-4.9.88-2.0.0_ga/imx6qpdlsolox__fsl-imx-fb/tmp/work/x86_64-nativesdk-pokysdk-linux/gcc-cross-canadian-arm/7.3.0-r0/recipe-sysroot --with-gnu-ld --enable-shared --enable-languages=c,c++ --enable-threads=posix --enable-multilib --enable-c99 --enable-long-long --enable-symvers=gnu --enable-libstdcxx-pch --program-prefix=arm-poky-linux-gnueabi- --without-local-prefix --enable-lto --enable-libssp --enable-libitm --disable-bootstrap --disable-libmudflap --with-system-zlib --with-linker-hash-style=gnu --enable-linker-build-id --with-ppl=no --with-cloog=no --enable-checking=release --enable-cheaders=c_global --without-isl --with-gxx-include-dir=/not/exist/usr/include/c++/7.3.0 --with-build-time-tools=/home/myzr/my-work/imx-4.9.88-2.0.0_ga/imx6qpdlsolox__fsl-imx-fb/tmp/work/x86_64-nativesdk-pokysdk-linux/gcc-cross-canadian-arm/7.3.0-r0/recipe-sysroot-native/usr/arm-poky-linux-gnueabi/bin --with-sysroot=/not/exist --with-build-sysroot=/home/myzr/my-work/imx-4.9.88-2.0.0_ga/imx6qpdlsolox__fsl-imx-fb/tmp/work/x86_64-nativesdk-pokysdk-linux/gcc-cross-canadian-arm/7.3.0-r0/recipe-sysroot --without-long-double-128 --enable-poison-system-directories --with-mpfr=/home/myzr/my-work/imx-4.9.88-2.0.0_ga/imx6qpdlsolox__fsl-imx-fb/tmp/work/x86_64-nativesdk-pokysdk-linux/gcc-cross-canadian-arm/7.3.0-r0/recipe-sysroot --with-mpc=/home/myzr/my-work/imx-4.9.88-2.0.0_ga/imx6qpdlsolox__fsl-imx-fb/tmp/work/x86_64-nativesdk-pokysdk-linux/gcc-cross-canadian-arm/7.3.0-r0/recipe-sysroot --enable-nls --enable-initfini-array Thread model: posix gcc version 7.3.0 (GCC)
u-boot编译
说明:MY-IMX8M 不需要编译此 u-boot。
编译前的准备
- 创建编译工作目录
=====> Input: mkdir ~/my-work/02_source/ -p
- 解压源码包到工作目录
=====> Input: tar xf u-boot-2016.03-svn*.tar.bz2 -C ~/my-work/02_source/
编译u-boot目标文件
- 进入源码目录
=====> Input: cd ~/my-work/02_source/u-boot-2016.03
- 生成目标开发板的 .config 文件
=====> Input: make myimx6ek140p-6y-256m-emmc_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 #
- 执行编译
=====> Input: make =====> Output: scripts/kconfig/conf --silentoldconfig Kconfig CHK include/config.h UPD include/config.h GEN include/autoconf.mk GEN include/autoconf.mk.dep CHK include/config/uboot.release CHK include/generated/timestamp_autogenerated.h CFG u-boot.cfg ...... LD u-boot OBJCOPY u-boot-nodtb.bin OBJCOPY u-boot.srec SYM u-boot.sym COPY u-boot.bin CFGS board/myzr/myimx6/myimx6a7-6y-ddr3.cfg.cfgtmp MKIMAGE u-boot.imx
Note: 如果有提示 “cc1: error”,通常是交叉编译工具的配置没生效,可以按前面 “交叉编译工具链安装” 中的 “source 工具链配置文件” 操作一次后再执行此步骤。
- 目标文件改名
=====> Input: cp u-boot.imx uboot-myimx6ek140p-6y-256m-emmc.imx
编译u-boot环境变量脚本
=====> Input: ./tools/mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "myzr bootscripts" -d bootscripts/myimxa7_l4988_emmc_script.cmd my_environment_emmc.scr =====> Output: Image Name: myzr bootscripts Created: Tue Dec 18 14:16:48 2018 Image Type: ARM Linux Script (uncompressed) Data Size: 1433 Bytes = 1.40 kB = 0.00 MB Load Address: 00000000 Entry Point: 00000000 Contents: Image 0: 1425 Bytes = 1.39 kB = 0.00 MB
目标文件
uboot-myimx6ek140p-6y-256m-emmc.imx 和 my_environment_emmc.scr 即编译得到的目标文件,保存这两个文件
内核编译
编译前的准备
- 创建编译工作目录
=====> Input: mkdir ~/my-work/02_source/ -p
- 解压源码包到工作目录
=====> Input: tar xf linux-4.9.88-svn*.tar.bz2 -C ~/my-work/02_source/
编译内核目标文件
- 进入内核源码目录
=====> Input: cd ~/my-work/02_source/linux-4.9.88
- 生成目标平台的 .config 文件
=====> Input: make myimxa7_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 #
Note: 如果有“Can't find default configuration "arch/x86/configs” 的错误,是因为交叉编译工具链的配置没有生效,可以按前面 “交叉编译工具链安装” 中的 “source 工具链配置文件” 操作一次后再执行此步骤
- 编译内核目标文件
=====> Input: make zImage =====> Output: scripts/kconfig/conf --silentoldconfig Kconfig CHK include/config/kernel.release UPD include/config/kernel.release WRAP arch/arm/include/generated/asm/bitsperlong.h ...... AS arch/arm/boot/compressed/piggy.o LD arch/arm/boot/compressed/vmlinux OBJCOPY arch/arm/boot/zImage Kernel: arch/arm/boot/zImage is ready
- 内核目标文件改名
=====> Input: cp arch/arm/boot/zImage zImage-myimxa7
编译设备树目标文件
- 执行编译命令
=====> Input: make myimx6ek140p-6y-256m-emmc.dtb =====> Output: DTC arch/arm/boot/dts/myimx6ek140p-6y-256m-emmc.dtb
- 复制设备树目标文件
=====> Input: cp arch/arm/boot/dts/myimx6ek140p-6y-256m-emmc.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 INSTALL_MOD_PATH=./modules =====> Output: INSTALL crypto/echainiv.ko INSTALL crypto/tcrypt.ko ...... INSTALL sound/usb/snd-usb-audio.ko INSTALL sound/usb/snd-usbmidi-lib.ko DEPMOD 4.9.88-myimx_armv7-svn432
- 打包内核模块文件
=====> Input: tar cjf kernel-modules-myimxa9.tar.bz2 -C modules lib
目标文件
zImage-myimxa7、myimx6ek140p-6y-256m-emmc.dtb 和 kernel-modules-myimxa9.tar.bz2 即编译得到的目标文件,保存这三个文件
Linux C程序编译
准备源码
打开网盘到 5_MY-Demo -> MY-Linux-C-Demo,下载 hello.c 文件,并复制到虚拟机。
编译目标文件
=====> Input: $CC hello.c -o hello.out
Note: 如果有“未找到命令”的信息,是因为交叉编译工具链的配置没有生效,可以按前面 “交叉编译工具链安装” 中的 “source 工具链配置文件” 操作一次后再执行此步骤
运行Linux C目标程序
- 把编译得到的 hello.out 复制到开发板上
- 在开发板上运行Linux C目标程序
=====> Input: ./hello.out =====> Output: MYZR Technology Co.,Ltd. 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
Note: 如果有“Permission denied”的信息,通常是目标程序没有可执行权限,可以参照下面指令增加目标文件的可执行权限后再运行程序
=====> Input: chmod +x ./hello.out
Linux QT5程序编译
准备源码
打开网盘到 5_MY-Demo,下载 MY-Linux-QT5-Demo-AboutUs-svn*.tar.bz2 文件,并复制到虚拟机。
- 解压源码包到工作目录
=====> Input: tar xf MY-Linux-QT5-Demo-AboutUs-svn*.tar.bz2 -C ~/my-work/02_source/
QT程序编译
- 进入源码目录
=====> Input: cd ~/my-work/02_source/AboutUs/
- 生成Makefile文件
=====> Input: qmake =====> Output: Info: creating stash file /home/myzr/my-work/02_source/my-demo/myzr-qt5-demo/AboutUs/.qmake.stash
Note: 如果有“未找到 'qamke' 命令”的信息,是因为交叉编译工具链的配置没有生效,可以按前面 “交叉编译工具链安装” 中的 “source 工具链配置文件” 操作一次后再执行此步骤
- 编译目标文件
=====> Input: make =====> Output: /home/myzr/my-work/03_toolchain/fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-neon-toolchain-4.9.88-2.0.0/sysroots/x86_64-pokysdk-linux/usr/bin/qt5/uic widget.ui -o ui_widget.h ...... arm-poky-linux-gnueabi-g++ -march=armv7-a -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 --sysroot=/home/myzr/my-work/03_toolchain/fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-neon-toolchain-4.9.88-2.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed --sysroot=/home/myzr/my-work/03_toolchain/fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-neon-toolchain-4.9.88-2.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi -Wl,-O1 -o AboutUs main.o widget.o qrc_source.o moc_widget.o -lQt5Widgets -lQt5Gui -lQt5Core -lGLESv2 -lEGL -lpthread
运行Linux QT5目标程序
- 把编译得到的 AboutUs 复制到开发板上
- 在开发板上运行QT5目标程序
=====> Input: chmod +x AboutUs ./AboutUs -platform eglfs
Note: 如果有“Permission denied”的信息,通常是目标程序没有可执行权限,可以参照下面指令增加目标文件的可执行权限后再运行程序
=====> Input: chmod +x ./AboutUs
- 运行结果
可以看到开发板显示屏上输出了 MYZR 的 Logo 和一些信息。
-------------------------------------------------------------------------------- * 珠海明远智睿科技有限公司 * ZhuHai MYZR Technology CO.,LTD. * Latest Update: 2018/12/18 * Supporter: Tang Bin --------------------------------------------------------------------------------