“MY-IMX6-A9 Linux-3.14.52 编译参考手册”的版本间的差异
第113行: | 第113行: | ||
MKIMAGE u-boot.imx | MKIMAGE u-boot.imx | ||
</pre> | </pre> | ||
− | **Note: 如果有提示 “cc1: | + | **Note: 如果有提示 “cc1: error”,通常是交叉编译工具的配置没生效,可以按前面 “交叉编译工具链安装” 中的 “source 工具链配置文件” 操作一次后再执行此步骤。** |
* 目标文件改名 | * 目标文件改名 | ||
第253行: | 第253行: | ||
### 目标文件 | ### 目标文件 | ||
**zImage-myimx6a9、myimx6ek200-6q-1g.dtb 和 kernel-modules-myimx6a9.tar.bz2 即编译得到的目标文件,保存这三个文件** | **zImage-myimx6a9、myimx6ek200-6q-1g.dtb 和 kernel-modules-myimx6a9.tar.bz2 即编译得到的目标文件,保存这三个文件** | ||
+ | |||
+ | ## **Linux C程序编译** | ||
+ | ### 准备源码 | ||
+ | * 下载Demo源码 | ||
+ | 位置:5_MY-Demo -> MY-Linux-C-Demo | ||
+ | 文件名:hello.c | ||
+ | * 复制源码到开发主机中 | ||
+ | ### MY-IMX6-A9 Linux 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> | ||
+ | |||
+ | <br> | ||
+ | ## **Linux QT5程序编译** | ||
+ | ### 准备源码 | ||
+ | * 下载Demo源码 | ||
+ | 位置:5_MY-Demo | ||
+ | 文件名:MY-Linux-QT5-Demo-AboutUs-svn*.tar.bz2 | ||
+ | * 解压源码包到工作目录 | ||
+ | <pre> | ||
+ | =====> Input: | ||
+ | tar xf MY-Linux-QT5-Demo-AboutUs-svn*.tar.bz2 -C ~/my-work/02_source/ | ||
+ | </pre> | ||
+ | ### MY-IMX6-A9 QT程序编译 | ||
+ | * 进入源码目录 | ||
+ | <pre> | ||
+ | =====> Input: | ||
+ | cd ~/my-work/02_source/AboutUs/ | ||
+ | </pre> | ||
+ | * 生成Makefile文件 | ||
+ | <pre> | ||
+ | =====> Input: | ||
+ | qmake | ||
+ | </pre> | ||
+ | **Note1: 如果有“未找到 'qamke' 命令”的信息,是因为交叉编译工具链的配置没有生效,可以按前面 “交叉编译工具链安装” 中的 “source 工具链配置文件” 操作一次后再执行此步骤** | ||
+ | **Note2: 如果有“oe-device-extra.pri: No such file or directory”的信息,执行下面命令后再执行qmake:** | ||
+ | <pre> | ||
+ | =====> Input: | ||
+ | touch /opt/fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-neon-toolchain-4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/lib/qt5/mkspecs/oe-device-extra.pri | ||
+ | </pre> | ||
+ | * 编译目标文件 | ||
+ | <pre> | ||
+ | =====> Input: | ||
+ | make | ||
+ | |||
+ | =====> Output: | ||
+ | /opt/fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-vfp-neon-toolchain-3.14.52-1.1.1/sysroots/x86_64-pokysdk-linux/usr/bin/qt5/uic widget.ui -o ui_widget.h | ||
+ | ...... | ||
+ | arm-poky-linux-gnueabi-g++ -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a9 --sysroot=/opt/fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-vfp-neon-toolchain-3.14.52-1.1.1/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-O1 -o AboutUs main.o widget.o qrc_source.o moc_widget.o -lQt5Widgets -lQt5Gui -lQt5Core -lGLESv2 -lEGL -lpthread | ||
+ | </pre> | ||
+ | ### 运行Linux QT5目标程序 | ||
+ | * 把编译得到的 AboutUs 复制到开发板上 | ||
+ | * 在开发板上运行QT5目标程序 | ||
+ | <pre> | ||
+ | =====> Input: | ||
+ | ./AboutUs -platform eglfs | ||
+ | </pre> | ||
+ | **Note: 如果有“Permission denied”的信息,通常是目标程序没有可执行权限,可以参照下面指令增加目标文件的可执行权限后再运行程序** | ||
+ | <pre> | ||
+ | =====> Input: | ||
+ | chmod +x ./AboutUs | ||
+ | </pre> | ||
+ | * 运行结果 | ||
+ | 可以看到开发板显示屏上输出了 MYZR 的 Logo 和一些信息。 | ||
<br> | <br> | ||
第260行: | 第349行: | ||
* 珠海明远智睿科技有限公司 | * 珠海明远智睿科技有限公司 | ||
* ZhuHai MYZR Technology CO.,LTD. | * ZhuHai MYZR Technology CO.,LTD. | ||
− | * Latest Update: 2018/11/ | + | * Latest Update: 2018/11/14 |
* Supporter: Tang Bin | * Supporter: Tang Bin | ||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
</pre> | </pre> |
2018年11月14日 (三) 10:42的版本
下载相关文件
交叉编译工具链
网盘位置: 2.1_OS_Linux-3.14.52 -> 03_Toolchain
安装文件: fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-vfp-neon-toolchain-3.14.52-1.1.1.sh
描述文件: fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-vfp-neon-toolchain-3.14.52-1.1.1.manifest
u-boot 源码
网盘位置: 2.1_OS_Linux-3.14.52 -> 02_Source
文件名: u-boot-2016.03-*.tar.bz2 (源码包版本号需svn315及以上)
Kernel 源码
网盘位置: 2.1_OS_Linux-3.14.52 -> 02_Source
文件名: linux-3.14.52-*.tar.bz2 (源码包版本号需svn369及以上)
安装交叉编译工具链
- 执行安装
=====> Input: ./fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-vfp-neon-toolchain-3.14.52-1.1.1.sh =====> Output: Enter target directory for SDK (default: /opt/fsl-imx-fb/3.14.52-1.1.1): =====> Input: /opt/fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-vfp-neon-toolchain-3.14.52-1.1.1 =====> Output: You are about to install the SDK to "/opt/fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-vfp-neon-toolchain-3.14.52-1.1.1". 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.
- source 工具链配置文件
=====> Input: source /opt/fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-vfp-neon-toolchain-3.14.52-1.1.1/environment-setup-cortexa9hf-vfp-neon-poky-linux-gnueabi
- 检验交叉编译工具安装
=====> Input: $CC -v =====> Output: Using built-in specs. COLLECT_GCC=arm-poky-linux-gnueabi-gcc COLLECT_LTO_WRAPPER=/opt/fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-vfp-neon-toolchain-3.14.52-1.1.1/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/../../libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.2/lto-wrapper Target: arm-poky-linux-gnueabi Configured with: /home/myzr/my-yocto/imx-3.14.52-1.1.0_ga/imx6qdlsolo__fsl-imx-fb/tmp/work-shared/gcc-4.9.2-r0/gcc-4.9.2/configure --build=x86_64-linux --host=x86_64-pokysdk-linux --target=arm-poky-linux-gnueabi --prefix=/opt/fsl-imx-fb/3.14.52-1.1.1/sysroots/x86_64-pokysdk-linux/usr --exec_prefix=/opt/fsl-imx-fb/3.14.52-1.1.1/sysroots/x86_64-pokysdk-linux/usr --bindir=/opt/fsl-imx-fb/3.14.52-1.1.1/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi --sbindir=/opt/fsl-imx-fb/3.14.52-1.1.1/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi --libexecdir=/opt/fsl-imx-fb/3.14.52-1.1.1/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi --datadir=/opt/fsl-imx-fb/3.14.52-1.1.1/sysroots/x86_64-pokysdk-linux/usr/share --sysconfdir=/opt/fsl-imx-fb/3.14.52-1.1.1/sysroots/x86_64-pokysdk-linux/etc --sharedstatedir=/opt/fsl-imx-fb/3.14.52-1.1.1/sysroots/x86_64-pokysdk-linux/com --localstatedir=/opt/fsl-imx-fb/3.14.52-1.1.1/sysroots/x86_64-pokysdk-linux/var --libdir=/opt/fsl-imx-fb/3.14.52-1.1.1/sysroots/x86_64-pokysdk-linux/usr/lib/arm-poky-linux-gnueabi --includedir=/opt/fsl-imx-fb/3.14.52-1.1.1/sysroots/x86_64-pokysdk-linux/usr/include --oldincludedir=/opt/fsl-imx-fb/3.14.52-1.1.1/sysroots/x86_64-pokysdk-linux/usr/include --infodir=/opt/fsl-imx-fb/3.14.52-1.1.1/sysroots/x86_64-pokysdk-linux/usr/share/info --mandir=/opt/fsl-imx-fb/3.14.52-1.1.1/sysroots/x86_64-pokysdk-linux/usr/share/man --disable-silent-rules --disable-dependency-tracking --with-libtool-sysroot=/home/myzr/my-yocto/imx-3.14.52-1.1.0_ga/imx6qdlsolo__fsl-imx-fb/tmp/sysroots/x86_64-nativesdk-pokysdk-linux --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-target-optspace --enable-lto --enable-libssp --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 --with-gxx-include-dir=/not/exist/usr/include/c++/4.9.2 --with-build-time-tools=/home/myzr/my-yocto/imx-3.14.52-1.1.0_ga/imx6qdlsolo__fsl-imx-fb/tmp/sysroots/x86_64-linux/usr/arm-poky-linux-gnueabi/bin --with-sysroot=/not/exist --with-build-sysroot=/home/myzr/my-yocto/imx-3.14.52-1.1.0_ga/imx6qdlsolo__fsl-imx-fb/tmp/sysroots/imx6qdlsolo --enable-poison-system-directories --with-mpfr=/home/myzr/my-yocto/imx-3.14.52-1.1.0_ga/imx6qdlsolo__fsl-imx-fb/tmp/sysroots/x86_64-nativesdk-pokysdk-linux --with-mpc=/home/myzr/my-yocto/imx-3.14.52-1.1.0_ga/imx6qdlsolo__fsl-imx-fb/tmp/sysroots/x86_64-nativesdk-pokysdk-linux --enable-nls --with-arch=armv7-a Thread model: posix gcc version 4.9.2 (GCC)
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 myimx6ek200-6q-1g_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 UPD include/config/uboot.release CHK include/generated/version_autogenerated.h ...... LD u-boot OBJCOPY u-boot-nodtb.bin OBJCOPY u-boot.srec SYM u-boot.sym COPY u-boot.bin CFGS board/myzr/myimx6/myimx6a9-6q-ddr3.cfg.cfgtmp MKIMAGE u-boot.imx
Note: 如果有提示 “cc1: error”,通常是交叉编译工具的配置没生效,可以按前面 “交叉编译工具链安装” 中的 “source 工具链配置文件” 操作一次后再执行此步骤。
- 目标文件改名
=====> Input: cp u-boot.imx uboot-myimx6ek200-6q-1g.imx
编译u-boot环境变量脚本
=====> Input: ./tools/mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "MYZR script" -d my_env_src/myimx6a9_31452_script.cmd my_env_script.scr =====> Output: Image Name: MYZR script Created: Wed Nov 7 15:23:38 2018 Image Type: ARM Linux Script (uncompressed) Data Size: 2132 Bytes = 2.08 kB = 0.00 MB Load Address: 00000000 Entry Point: 00000000 Contents: Image 0: 2124 Bytes = 2.07 kB = 0.00 MB
目标文件
uboot-myimx6ek200-6q-1g.imx 和 my_env_script.scr 即编译得到的目标文件,保存这两个文件
内核编译
编译前的准备
- 创建编译工作目录
=====> Input: mkdir ~/my-work/02_source/ -p
- 解压源码包到工作目录
=====> Input: tar xf linux-3.14.52-svn*.tar.bz2 -C ~/my-work/02_source/
编译内核目标文件
- 进入内核源码目录
=====> Input: cd ~/my-work/02_source/linux-3.14.52
- 生成目标平台的 .config 文件
=====> Input: make myimx6a9_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/auxvec.h ...... AS arch/arm/boot/compressed/piggy.lzo.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-myimx6a9
编译设备树目标文件
- 执行编译命令
=====> Input: make myimx6ek200-6q-1g.dtb =====> Output: DTC arch/arm/boot/dts/myimx6ek200-6q-1g.dtb
- 复制设备树目标文件
=====> Input: cp arch/arm/boot/dts/myimx6ek200-6q-1g.dtb ./
编译内核模块包
- 执行编译
=====> Input: make modules =====> Output: CHK include/config/kernel.release CHK include/generated/uapi/linux/version.h CHK include/generated/utsrelease.h make[1]: “include/generated/mach-types.h”是最新的。 CALL scripts/checksyscalls.sh ...... LD [M] sound/core/snd-rawmidi.ko 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/tcrypt.ko INSTALL drivers/i2c/algos/i2c-algo-pca.ko ...... INSTALL sound/usb/snd-usbmidi-lib.ko DEPMOD 3.14.52-myimx6-svn369
- 打包内核模块文件
=====> Input: tar cjf kernel-modules-myimx6a9.tar.bz2 -C modules lib
目标文件
zImage-myimx6a9、myimx6ek200-6q-1g.dtb 和 kernel-modules-myimx6a9.tar.bz2 即编译得到的目标文件,保存这三个文件
Linux C程序编译
准备源码
- 下载Demo源码
位置:5_MY-Demo -> MY-Linux-C-Demo
文件名:hello.c - 复制源码到开发主机中
MY-IMX6-A9 Linux 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程序编译
准备源码
- 下载Demo源码
位置: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/
MY-IMX6-A9 QT程序编译
- 进入源码目录
=====> Input: cd ~/my-work/02_source/AboutUs/
- 生成Makefile文件
=====> Input: qmake
Note1: 如果有“未找到 'qamke' 命令”的信息,是因为交叉编译工具链的配置没有生效,可以按前面 “交叉编译工具链安装” 中的 “source 工具链配置文件” 操作一次后再执行此步骤
Note2: 如果有“oe-device-extra.pri: No such file or directory”的信息,执行下面命令后再执行qmake:
=====> Input: touch /opt/fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-neon-toolchain-4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/lib/qt5/mkspecs/oe-device-extra.pri
- 编译目标文件
=====> Input: make =====> Output: /opt/fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-vfp-neon-toolchain-3.14.52-1.1.1/sysroots/x86_64-pokysdk-linux/usr/bin/qt5/uic widget.ui -o ui_widget.h ...... arm-poky-linux-gnueabi-g++ -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a9 --sysroot=/opt/fsl-imx-fb-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-vfp-neon-toolchain-3.14.52-1.1.1/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -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: ./AboutUs -platform eglfs
Note: 如果有“Permission denied”的信息,通常是目标程序没有可执行权限,可以参照下面指令增加目标文件的可执行权限后再运行程序
=====> Input: chmod +x ./AboutUs
- 运行结果
可以看到开发板显示屏上输出了 MYZR 的 Logo 和一些信息。
-------------------------------------------------------------------------------- * 珠海明远智睿科技有限公司 * ZhuHai MYZR Technology CO.,LTD. * Latest Update: 2018/11/14 * Supporter: Tang Bin --------------------------------------------------------------------------------