明远智睿 IMX6-CB314源码编译

2018年04月17日 14:50    发布者:明远智睿Lan
源码文件(source code)评估板对应的Linux版本及对应的源码文件见下表:
The corresponding Linux version of the evaluation board and the corresponding source code files are shown in the table below:

评估板型号
(evaluation board model)u-boot源码文件
(u-boot source code)linux源码文件
(linux source code)
MY-IMX6-EK200u-boot-2015.04.tar.xzlinux-3.14.52.tar.xz
MY-IMX6-EK314
MY-IMX6-EK336
MY-IMX6-EK140

交叉编译工具文件(cross compiler tool file)Linux程序交叉编译工具:gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux.tar.xz
Linux program cross compiler tool:gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux.tar.xz
Linux交叉编译工具配置文件:gcc-linaro-arm-linux-gnueabihf-492-env
Linux cross compiler tool configuration file:gcc-linaro-arm-linux-gnueabihf-492-env
QT5程序交叉编译工具:fsl-imx-x11-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-vfp-neon-toolchain-3.14.52-1.1.0.sh
QT5 program compiler tool:fsl-imx-x11-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-vfp-neon-toolchain-3.14.52-1.1.0.sh

创建工作目录(creat working directory)1)源码目录
source code directory
$ mkdir ~/my-imx6/02_source –p
http://wiki.myzr.com.cn/images/3/30/Myimx6linux3.14_build_2.3.0.1.png
2)工具目录
tool directory
$ mkdir ~/my-imx6/03_tools –p
http://wiki.myzr.com.cn/images/c/ca/Myimx6linux3.14_build_2.3.0.2.png
3)镜像目录
image directory
$ mkdir ~/my-imx6/04_image –p
http://wiki.myzr.com.cn/images/c/c9/Myimx6linux3.14_build_2.3.0.3.png
$ mkdir ~/my-imx6/04_image/image-linux-31452 –p
http://wiki.myzr.com.cn/images/7/75/Myimx6linux3.14_build_2.3.0.4.png
4)应用程序目录
application diretory
$ mkdir ~/my-demo
http://wiki.myzr.com.cn/images/2/22/Myimx6linux3.14_build_2.3.0.5.png

安装交叉编译工具链(install cross compiler tool chain)安装Linux交叉编译工具链(install Linux cross compiler tool chain)1)进入交叉编译工具链目录
enter cross compiler tool chain diretory
$ cd ~/my-imx6/03_tools/
2)复制Linux交叉编译工具到目录
copy Linux cross compiler tool to directory
将gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux.tar.xz复制到“~/my-imx6/03_tools”,这一步自己采取相应的方式完成。

3)解压Linux交叉编译工具
copy gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux.tar.xz to“~/my-imx6/03_tools”,complete this step by yourself in a proper way。
$ tar xf gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux.tar.xz
http://wiki.myzr.com.cn/images/c/c2/Myimx6linux3.14_build_4.1.0.1.png
4)复制交叉编译工具配置文件
copy cross compiler tool configuration file
将gcc-linaro-arm-linux-gnueabihf-492-env复制到“~/my-imx6/03_tools”,这一步自己采取相应的方式完成。
copy gcc-linaro-arm-linux-gnueabihf-492-env to“~/my-imx6/03_tools”,complete this step by yourself in a proper way。
5)检查安装
check installation
$ source gcc-linaro-arm-linux-gnueabihf-492-env
$ ${CROSS_COMPILE}gcc –v
http://wiki.myzr.com.cn/images/c/c0/Myimx6linux3.14_build_4.1.0.2.png

安装QT5交叉编译工具(install QT5 cross compiler tool)1)进入交叉编译工具链目录
enter cross compiler tool chain directory
$ cd ~/my-imx6/03_tools/
http://wiki.myzr.com.cn/images/a/a6/Myimx6linux3.14_build_4.2.0.1.png
2)执行安装命令
execute installation command
$ sh fsl-imx-x11-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-vfp-neon-toolchain-3.14.52-1.1.0.sh
3)选择安装路径
choose installation path
执行安装命令后会出现如下提示信息:
after execution of installation command,there will be a following prompt message:
Enter target directory for SDK (default: /opt/fsl-imx-x11/3.14.52-1.1.0):
这时按“回车(Enter)”键,我们保持默认的安装路径。
then press“Enter”key,let's keep defauted installation path。
4)确认安装路径
confirm installation path
之后,会提示如下信息:
afterwards,there will be a following prompt message:
You are about to install the SDK to "/opt/fsl-imx-x11/3.14.52-1.1.0". Proceed? 这时输入“Y”并按“回车(Enter)”键表示确认。
then enter“Y”and press“Enter”key for confirmation。
http://wiki.myzr.com.cn/images/a/a0/Myimx6linux3.14_build_4.2.0.2.png
U-Boot编译(U-Boot compilation)准备编译(prepare compilation)复制源码包到开发主机中(copy source code package to development host)将下载的“u-boot源码”复制到Linux开发主机的“~/my-imx6/02_source”。
copy“u-boot source code”downloaded to “~/my-imx6/02_source”of Linux development host。
这一步自己采取相应的方式完成。
complete this step by yourself in a proper way。

解压u-boot源码包(decompress u-boot source code package)$ cd ~/my-imx6/02_source/
$ tar xf u-boot-2015.04.tar.xz
http://wiki.myzr.com.cn/images/3/34/Myimx6linux3.14_build_5.1.2.1.png

使编译配置文件生效(validate compiler configuration file)MYIMX6EK200-6Q-1G configuration example:
$ make myimx6ek200-6q_config
http://wiki.myzr.com.cn/images/9/95/Myimx6linux3.14_build_5.2.4.1.png
执行编译(execute compilation)$ make
提示:这里为了提高编译速度,在make后面加了“-j4”。这里编译的Linux主机是双核4线程的,所以“-j”后面用了4,也就是采用4线程编译。“-j”后面的数字可以根据系统资源分配,但是不应该超过编译主机最大支持的线程数。
Tips:To speed up the compilation,add "-j4" after make.The Linux host used to compile is dual-core ,4 threads .So "-j" is followed by 4, which takes 4 threads to compile. The number behind "-j" is allocated based on system resources,but It should not exceed the maximum threads the host support.
http://wiki.myzr.com.cn/images/0/03/Myimx6linux3.14_build_5.2.5.1.png

[*]编译完成
complete compilation
提示:u-boot编译过程大概需要一、两分钟时间。
Tips: u-boot compiling process may take one or two minutes。
http://wiki.myzr.com.cn/images/8/8b/Myimx6linux3.14_build_5.2.5.2.png

目标文件(target file)
[*]编译文件
compile file
编译完成后通过ls命令即可看到编译得到的文件u-boot.imx
you can get the compiled file u-boot .imx with ls command after compilation.
$ ls
http://wiki.myzr.com.cn/images/b/b9/Myimx6linux3.14_build_5.3.0.1.png我们需要将编译得到的u-boot.imx复制为我们的目标文件名。
We need to copy the compilied file u-boot.imx as our target file name.:
这里以MY-IMX6-EK200-6Q为例(把配置myimx6ek200-6q_config编译生成的u-boot.imx复制为目标文件):
Copy the generated file u-boot.imx from the compilation of myimx6ek200-6q_config as target file.):
$ cp u-boot.imx ~/my-imx6/04_image/image-linux-31452/uboot-myimx6ek200-6q.imx
http://wiki.myzr.com.cn/images/1/15/Myimx6linux3.14_build_5.3.0.2.png
编译内核(compile kernel)准备编译(prepare compilation)复制源码包到开发主机中(copy source code package to development host)将下载的“linux源码”复制到Linux开发主机的“~/my-imx6/02_source”。
copy “linux source code”downloaded to “~/my-imx6/02_source”of Linux development host。
这一步自己采取相应的方式完成。
complete this step by yourself in a proper way。

解压linux源码包(decompress linux source code package)$ cd ~/my-imx6/02_source/
$ tar xf linux-3.14.52.tar.xz
http://wiki.myzr.com.cn/images/5/52/Myimx6linux3.14_build_6.1.2.1.png

内核编译配置(kernel compilation configuration)使编译配置文件生效(validate compilfer configuration file)$ source ~/my-imx6/03_tools/gcc-linaro-arm-linux-gnueabihf-492-env
http://wiki.myzr.com.cn/images/a/a1/Myimx6linux3.14_build_6.2.1.1.png

清除内核临时文件(remove kernel temporary file)
[*]进入linux源码目录
enter linux source code directory
$ cd ~/my-imx6/02_source/linux-3.14.52
http://wiki.myzr.com.cn/images/2/2f/Myimx6linux3.14_build_6.2.2.1.png

[*]清除临时文件
remove temporary file
$ make distclean
http://wiki.myzr.com.cn/images/9/9b/Myimx6linux3.14_build_6.2.2.2.png

内核配置(kernel configuration)
[*]内核配置文件
kernel configuration file

评估板型号
(evaluation board model)配置文件
(configuration file)
MY-IMX6-EK200myimx6_defconfig
MY-IMX6-EK314
MY-IMX6-EK336
MY-IMX6-EK140myimx6ul_defconfig
$ make myimx6_defconfig
如果是编译 MY-IMX6-EK140 的内核,请使用 $ make myimx6ul_defconfig
if what compified is kernel of MY-IMX6-EK140,please use $ make myimx6ul_defconfig
这里以 myimx6_defconfig 为例。
take myimx6_defconfig as an example。
http://wiki.myzr.com.cn/images/b/b5/Myimx6linux3.14_build_6.2.3.1.png

编译内核(compife kernel)
[*]执行编译
execute compilation
$ make zImage
http://wiki.myzr.com.cn/images/0/03/Myimx6linux3.14_build_6.3.0.1.png

[*]编译完成
complete compilation
http://wiki.myzr.com.cn/images/2/29/Myimx6linux3.14_build_6.3.0.2.png

[*]目标文件
target file
arch/arm/boot/zImage即为编译得到的内核文件,使用ls命令可查看文件信息。
arch/arm/boot/zImage is the kernel file compifed,you can check file information with ls command。
$ ls arch/arm/boot/zImage -la
http://wiki.myzr.com.cn/images/2/22/Myimx6linux3.14_build_6.3.0.3.png
注意:我们烧录及启动的内核文件名为“zImage-myimx6”,所以我们需要把zImage复制为zImage-myimx6。
Note: The kernel file name which is going to be programed and started is “zImage-myimx6”, So we should Copy zImage as zImage-myimx6
$ cp arch/arm/boot/zImage ~/my-imx6/04_image/image-linux-31452/zImage-myimx6
http://wiki.myzr.com.cn/images/d/df/Myimx6linux3.14_build_6.3.0.4.png

编译设备树(compife device tree)$ make myimx6ek200-6q.dtb
http://wiki.myzr.com.cn/images/e/ef/Myimx6linux3.14_build_6.4.0.1.png

[*]目标文件
target file
使用ls命令可查看编译得到的目标设备树文件信息:
You can browse the target device tree file information from compilation with ls command:
$ ls arch/arm/boot/dts/myimx6ek*.dtb
http://wiki.myzr.com.cn/images/2/2e/Myimx6linux3.14_build_6.4.0.2.png
复制设备树文件到镜像目录
Copy device tree file to image directory
$ cp arch/arm/boot/dts/myimx6ek*.dtb ~/my-imx6/04_image/image-linux-31452/
http://wiki.myzr.com.cn/images/5/51/Myimx6linux3.14_build_6.4.0.3.png
编译模块 (compife module)
[*]编译模块命令
compile module command
$ make modules
http://wiki.myzr.com.cn/images/6/6c/Myimx6linux3.14_build_6.5.0.1.png

[*]安装模块到指定目录
Install module to the specified directory
$ make modules_install INSTALL_MOD_PATH=./modules
http://wiki.myzr.com.cn/images/8/85/Myimx6linux3.14_build_6.5.0.2.png

[*]打包模块文件
package the module file
$ cd modules
$ tar cjf ../modules.tar.bz2 *
http://wiki.myzr.com.cn/images/6/68/Myimx6linux3.14_build_6.5.0.3.png

[*]复制模块包到镜像目录
Copy module package to image directory

评估板型号
(development board model)目标模块包
(target module package)
MY-IMX6-EK200kernel-modules-myimx6.tar.bz2
MY-IMX6-EK314
MY-IMX6-EK336
MY-IMX6-EK140kernel-modules-myimx6g.tar.bz2
$ cp ../modules.tar.bz2 ~/my-imx6/04_image/image-linux-31452/kernel-modules-myimx6.tar.bz2
注意:如果是编译内核时配置文件使用的是 myimx6_defconfig,在这里要把 modules.tar.bz2 复制为 kernel-modules-myimx6.tar.bz2;如果是编译内核时配置文件使用的是 myimx6ul_defconfig,在这里要把 modules.tar.bz2 复制为 kernel-modules-myimx6g.tar.bz2
Note:when you compile the Kernel If the configuration file you use is myimx6_defconfig, here you should Copy modules.tar.bz2 as kernel-modules-myimx6.tar.bz2.If the configuration file is myimx6ul_defconfig,you should Copy modules.tar.bz2 as kernel-modules-myimx6g.tar.bz2.

应用程序编译(application compilation)Linux应用程序编译(Linux application compilation)编写应用程序(write an application)
[*]创建应用程序的源码目录和Linux-3.14.52的可执行程序目录
Create application source code directory and Linux-3.14.52 executable program directory
$ mkdir ~/my-demo/source_code -p
http://wiki.myzr.com.cn/images/e/ed/Myimx6linux3.14_build_8.1.1.1.png
$ mkdir ~/my-demo/bin-l31452 -p
http://wiki.myzr.com.cn/images/b/b9/Myimx6linux3.14_build_8.1.1.2.png

[*]编写源代码
write source code
$ cd ~/my-demo/source_code
$ vi hello.c
写入以下代码并保存
write following code and save
#include

int main(int argc, char **argv)
{
  printf("Hello, MYZR!\n");

  return;
}

[*]查看代码
view code
http://wiki.myzr.com.cn/images/3/38/Myimx6linux3.14_build_8.1.1.3.png
$ cat hello.c
编译应用程序(compife application)
[*]配置环境变量
Configure environment variables
$ source ~/my-imx6/03_tools/gcc-linaro-arm-linux-gnueabihf-492-env
http://wiki.myzr.com.cn/images/0/0d/Myimx6linux3.14_build_8.1.2.1.png

[*]编译
compife
$ ${CROSS_COMPILE}gcc hello.c -o hello.out
http://wiki.myzr.com.cn/images/f/f0/Myimx6linux3.14_build_8.1.2.2.png
注意:上面的命令有包含“$”号,即“${CROSS_COMPILE}gcc”,是引用我们source时产生的环境变量。
Note:The above command contains “$”,which is “${CROSS_COMPILE}gcc”. It is the environment variable generated when referring to our source.。

[*]目标文件
target file
$ file hello.out
http://wiki.myzr.com.cn/images/7/70/Myimx6linux3.14_build_8.1.2.3.png
可以看到目标文件 hello.out 的属性。
you can see the property of target file hello.out。

保存目标可执行文件(save target executable file)$ mv hello.out ~/my-demo/bin-l31452/
http://wiki.myzr.com.cn/images/5/55/Myimx6linux3.14_build_8.1.3.1.png

QT应用程序编译 (QT application compife)准备QT5程序代码(prepare QT5 program code)提示:这里我们使用“Qt5_NMap_CarouselDemo_1.0.tgz”进行演示。
Tips:Here We demonstrate with “Qt5_NMap_CarouselDemo_1.0.tgz".
1)将代码包复制到Linux开发主机
copy code package to Linux development host
将代码包“Qt5_NMap_CarouselDemo_1.0.tgz”复制到“~/my-demo/source_code”。
copy code package“Qt5_NMap_CarouselDemo_1.0.tgz”to“~/my-demo/source_code”。
这一步自己采取相应的操作完成。
complete this step by yourself in a proper way。
2)解压代码包
decompress code package
$ cd ~/my-demo/source_code
$ tar zxf Qt5_NMap_CarouselDemo_1.0.tgz
http://wiki.myzr.com.cn/images/c/c1/Myimx6linux3.14_build_8.2.1.1.png

编译QT5程序(compile QT5 application)提示:我们将使用命令行编译。
Tips: We compile with commands。
1)进入代码目录
enter code directory
提示:我们前面将代码包“Qt5_NMap_CarouselDemo_1.0.tgz”解压在“~/my-demo/source_code”。
tips:first we decompress code package“Qt5_NMap_CarouselDemo_1.0.tgz”to“~/my-demo/source_code”。
$ cd ~/my-demo/source_code/Qt5_NMap_CarouselDemo_1.0/
2)检查QMake
check QMake
$ qmake –v
http://wiki.myzr.com.cn/images/0/08/Myimx6linux3.14_build_8.2.2.2.png
如果执行命令后当前终端有输出“QMake version 3.0”,则表示交叉编译工具配置正常。 If the current terminal output has “QMake version 3.0” after the execution of command,that means cross compiler is Configured normally..
否则需要执行下面的命令:
Otherwise you need to execute the command below:
$ source /opt/fsl-imx-x11/3.14.52-1.1.0/environment-setup-cortexa9hf-vfp-neon-poky-linux-gnueabi
3)生成Makefile文件
creat Makefile
$ qmake
http://wiki.myzr.com.cn/images/e/e5/Myimx6linux3.14_build_8.2.2.3.png
执行qmake后通过ls可以看到多了Makefile文件
you can see an extra Makefile with ls after execution of qmake
4)编译
compile
$ make
http://wiki.myzr.com.cn/images/6/67/Myimx6linux3.14_build_8.2.2.4.png
5)目标文件
target file

[*]可执行文件
target file
$ file Qt5_NMap_CarouselDemo
http://wiki.myzr.com.cn/images/f/f0/Myimx6linux3.14_build_8.2.2.5.png

[*]资源文件
source file
QT5程序的运行需要对应的qml文件和content
Running QT5 needs the corresponding qml file and content
http://wiki.myzr.com.cn/images/9/9a/Myimx6linux3.14_build_8.2.2.6.png

保存目标可执行文件(save target executable file)由于QT5程序的运行需要对应的qml文件和content文件,这里我们为了操作的简洁,直接将整个目录复制到目标目录
Because running QT5 program requires qml file and content file, here We copy the entire directory to the target directory for simplicity.
$ cp ../Qt5_NMap_CarouselDemo_1.0 ~/my-demo/bin-l31452/ -a
http://wiki.myzr.com.cn/images/f/f7/Myimx6linux3.14_build_8.2.3.1.png
准备编译 (Prepare for compilation)安装软件包(install software package)说明,Yocto编译依赖一些软件包,所以需要在开发主机上进行安装。
instruction,Yocto compilation relies on some software package. So you need to Install them on the host。
$ sudo apt-get install gawk wget git-core diffstat unzip texinfo \
gcc-multilib build-essential chrpath socat
http://wiki.myzr.com.cn/images/3/34/Myimx6linux3.14_build_10.1.1.1.png
$ sudo apt-get install libsdl1.2-dev xterm sed cvs subversion \
coreutils texi2html docbook-utils python-pysqlite2 help2man make gcc \
g++ desktop-file-utils libgl1-mesa-dev libglu1-mesa-dev mercurial \
autoconf automake groff curl lzop asciidoc
http://wiki.myzr.com.cn/images/1/18/Myimx6linux3.14_build_10.1.1.2.png
$ sudo apt-get install uboot-mkimage
http://wiki.myzr.com.cn/images/c/c6/Myimx6linux3.14_build_10.1.1.3.png