MY-IMX6 Linux-3.14 编译手册
[复制链接]
编译内核(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
内核编译配置(kernel compilation configuration)使编译配置文件生效(validate compilfer configuration file)$ source ~/my-imx6/03_tools/gcc-linaro-arm-linux-gnueabihf-492-env
清除内核临时文件(remove kernel temporary file)enter linux source code directory
$ cd ~/my-imx6/02_source/linux-3.14.52
remove temporary file
$ make distclean
内核配置(kernel configuration)kernel configuration file
评估板型号
(evaluation board model) | 配置文件
(configuration file) | MY-IMX6-EK200 | myimx6_defconfig | MY-IMX6-EK314 | MY-IMX6-EK336 | MY-IMX6-EK140 | myimx6ul_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。
编译内核(compife kernel)execute compilation
$ make zImage
complete compilation
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
注意:我们烧录及启动的内核文件名为“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
编译设备树(compife device tree)评估板型号规格与设备树文件对应关系见下表:
The correspondence between the type of evaluation board and device tree is shown below:
评估板主型号
(development main model) | CPU类型-内存容量
(CPU type-memory capacity) | 对应的设备树文件
(corresponding device tree file) | MY-IMX6-EK200 | i.MX 6QuadPlus - 1G | myimx6ek200-6qp.dtb | i.MX 6QuadPlus - 2G | myimx6ek200-6qp-2g.dtb | i.MX6 Quad - 1G | myimx6ek200-6q.dtb | i.MX6 Quad - 2G | myimx6ek200-6q-2g.dtb | i.MX6 DualLite - 1G | myimx6ek200-6u.dtb | i.MX 6Solo - 512M | myimx6ek200-6s.dtb | i.MX 6Solo - 1G | myimx6ek200-6s-1g.dtb | MY-IMX6-EK314 | i.MX 6QuadPlus - 1G | myimx6ek314-6qp.dtb | i.MX 6QuadPlus - 2G | myimx6ek314-6qp-2g.dtb | i.MX6 Quad - 1G | myimx6ek314-6q.dtb | i.MX6 Quad - 2G | myimx6ek314-6q-2g.dtb | i.MX6 DualLite - 1G | myimx6ek314-6u.dtb | MY-IMX6-EK336 | i.MX 6QuadPlus - 1G | myimx6ek336-6qp.dtb | i.MX 6QuadPlus - 2G | myimx6ek336-6qp-2g.dtb | i.MX6 Quad - 1G | myimx6ek336-6q.dtb | i.MX6 Quad - 2G | myimx6ek336-6q-2g.dtb | MY-IMX6-EK140 | i.MX 6UltraLite-256M | myimx6ek140-6g.dtb | i.MX 6UltraLite-512M | myimx6ek140-6g-512m.dtb | i.MX 6UltraLite Full - 256M (2eth) | myimx6ek140p-6g.dtb | i.MX 6UltraLite Full - 256M (8uart) | myimx6ek140p-6g-8uart.dtb | i.MX 6UltraLite Full - 512M (2eth) | myimx6ek140p-6g-512m.dtb | i.MX 6UltraLite Full - 512M (8uart) | myimx6ek140p-6g-512m-8uart.dtb |
take MY-IMX6-EK200-6Q-1G as example
$ make myimx6ek200-6q.dtb
target file
使用ls命令可查看编译得到的目标设备树文件信息:
You can browse the target device tree file information from compilation with ls command:
$ ls arch/arm/boot/dts/myimx6ek*.dtb
复制设备树文件到镜像目录
Copy device tree file to image directory
$ cp arch/arm/boot/dts/myimx6ek*.dtb ~/my-imx6/04_image/image-linux-31452/
编译模块 (compife module)compile module command
$ make modules
Install module to the specified directory
$ make modules_install INSTALL_MOD_PATH=./modules
package the module file
$ cd modules
$ tar cjf ../modules.tar.bz2 *
Copy module package to image directory
评估板型号
(development board model) | 目标模块包
(target module package) | MY-IMX6-EK200 | kernel-modules-myimx6.tar.bz2 | MY-IMX6-EK314 | MY-IMX6-EK336 | MY-IMX6-EK140 | kernel-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
$ mkdir ~/my-demo/bin-l31452 -p
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
$ cat hello.c
编译应用程序(compife application)Configure environment variables
$ source ~/my-imx6/03_tools/gcc-linaro-arm-linux-gnueabihf-492-env
compife
$ ${CROSS_COMPILE}gcc hello.c -o hello.out
注意:上面的命令有包含“$”号,即“${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
可以看到目标文件 hello.out 的属性。
you can see the property of target file hello.out。
保存目标可执行文件(save target executable file)$ mv hello.out ~/my-demo/bin-l31452/
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
编译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
如果执行命令后当前终端有输出“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
执行qmake后通过ls可以看到多了Makefile文件
you can see an extra Makefile with ls after execution of qmake
4)编译
compile
$ make
5)目标文件
target file
target file
$ file Qt5_NMap_CarouselDemo
source file
QT5程序的运行需要对应的qml文件和content
Running QT5 needs the corresponding qml file and content
保存目标可执行文件(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
应用程序打包(package application)说明(instruction)烧录工具支持烧录“my-demo.tar.xz”的文件包到评估板。所以在这里我们把我们需要的应用程序打包为“my-demo.tar.xz”。至于“my-demo.tar.xz”会被烧录到哪个位置,请看《烧录手册》。
Programming tool supports to program “my-demo.tar.xz” file package to evaluation board.So We package applications We need as “my-demo.tar.xz”.while where “my-demo.tar.xz” will be programmed ,refer to 《burning manual》。
打包应用程序(package application)1)打包
package
这里我们将整个my-demo目录打包。
Here We package the whole my-demo directory。
$ cd ~
$ tar cjf my-demo.tar.bz2 my-demo
2)复制应用程序包为目标烧录文件
Copy application package as target programming file
$ cp my-demo.tar.bz2 ~/my-imx6/04_image/image-linux-31452/
目标烧录文件(target programming file)
至此,我们在“~/my-imx6/04_image/image-linux-31452/”得到了除文件系统以外的一套烧录文件。包括“uboot*.imx”、“myimx6*.dtb”、“zImage-myimx6”、“kernel-modules.tar.bz2”、“my-demo.tar.bz2”。
So far,we get a set of programming file except file system from“~/my-imx6/04_image/image-linux-31452/”。including“uboot*.imx”、“myimx6*.dtb”、“zImage-myimx6”、“kernel-modules.tar.bz2”、“my-demo.tar.bz2”。
现在可以参照《烧录手册》烧录我们自己编译出来的image了。
Now we can program the image we compiled by ourselves referring to programming manual.
在评估板上运行应用程序 (run application on the evaluation board)烧录系统之后,对评估板重新上电,登录系统后并执行以下命令。
After the burning, supply power for evaluation board,login system and execute commands below.
- /home/root/my-demo/bin-l31452/hello.out
- export DISPLAY=:0
- /home/root/my-demo/bin-l31452/Qt5_NMap_CarouselDemo_1.0/Qt5_NMap_CarouselDemo
附:文件系统编译(Appendix:file system compilation)注意及说明:
notes and instructions:
1)原始编译的过程中的下载量会超过4G。(提示:可以使用我们下载好的一些文件,以减少下载量,节约时间,在7.4中会说到)。
The download of the original compilation exceed 4G。(tips:you can use files we have downloaded in order to reduce downloads and save time,which is going to be mentioned in 7.4)。
2)编译主机的网络连接最好使用能访问www.fackbook.com 的网络,不然可能会受到境内防火墙的限制而无法下载编译需要的软件包。
The network of the compilation host is good to access to www.fackbook.com .Otherwise It may be subject to the condition of the domestic firewall and It is unable to download the software for compilation.
3)初次编译需要的时间根据网络状态及编译主机的配置需要2小时到无限时间(经粗略统计除去下载时间,在16核CPU、16G内存的主机上编译QT5系统用了大约100分钟。)
The initial compilation may take 2 hours to unlimited time.It depends on the network state and the configuration of the host.(After a rough statistics, It took about 100 minutes to compile QT5 system on the 16-core CPU 16 G memory host except download time。)
客户请根据实际情况决定是否自行编译文件系统或使用我们提供的文件系统。如果我们提供的文件系统能够满足需求,建议不要自行编译,因为编译过程可能会出现很多错误。
Customer may decide whether to compile the file system or use the file system We provide based on the actual situation. If the file system we provide meets the requirements, you had better not to compile by yourself. Since It may be a lot of errors during compilation.
准备编译 (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
$ 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
$ sudo apt-get install uboot-mkimage
准备源码(prepare source code)1)下载源码
download source code
在网盘中下载 yocto__imx-3.14.52-1.1.0_ga.tar.xz
from network disk download yocto__imx-3.14.52-1.1.0_ga.tar.xz
2)创建工作目录
create working directory
$ mkdir ~/yocto
3)将源码包复制到工作目录
Copy source code package to working directory
复制“yocto__imx-3.14.52-1.1.0_ga.tar.xz”到“~/my-imx6/02_source”。
copy“yocto__imx-3.14.52-1.1.0_ga.tar.xz”to“~/my-imx6/02_source”。
这一步骤自己采取相应的方式进行
complete this step by yourself in a proper way
4) 解压源码包
decompress source code package
$ cd ~/yocto/
$ tar xf yocto__imx-3.14.52-1.1.0_ga.tar.xz
准备编译需要的软件包(Prepare software package required for compilation)提示1:如果自己网络状况好且能访问境外网站,可以跳过这一节内容。
tips1:If you have a good network and can access a foreign website ,you can skip this section.
提示2:如果是使用我们下载好的一些包,请继续往下。
tips2:If you use the package we have downloaded, please go on to the next step.
提示3:限于网络上传速度的影响及软件包的更新,我们下载的软件包目录中可能不包括
编译需要的全部软件包,但是编译中缺少的软件包编译程序会在编译过程中自行下载。
tips3:As a result of the upload speed and the update of software package , the software package directory we downloaded may not include all the required software packages for compilation.But the compiler package that is missing from compilation will be downloaded on its own during compilation process.
1)下载软件包
download software package
在网盘中下载downloads文件夹(位置:MYZR-通用资源/yocto/downloads。目前该文件夹大小在6 ~ 8G)。
download downloads folder on the network disk(Path: MYZR-通用资源/yocto/downloads. currently, the folder size is 6~8G)。
2)将软件包复制到BSP目录
copy software package to BSP directory
将downloads移动到 “~/yocto/imx-3.14.52-1.1.0_ga” 目录
move downloads to “~/yocto/imx-3.14.52-1.1.0_ga” directory
这一步自己采取相应的方法完成。
complete this step by yourself in a proper way。
编译 (compilation)更新BSP(update BSP)$ cd ~/yocto/imx-3.14.52-1.1.0_ga/
$ ./bin/repo sync
编译配置(compilation configuration)$ DISTRO=fsl-imx-x11 MACHINE=imx6qsabresd source fsl-setup-release.sh -b build-x11
执行命令后终端会接收到输出的信息,一直按“空格”,在最后的对话中输入y
After executing the command,the terminal will receive the output message, keep pressing "space" ,enter "y" in the final dialog
示例:Do you accept the EULA you just read? (y/n) y
example:Do you accept the EULA you just read? (y/n) y
编译QT5文件系统(compife QT5文 file system)1)执行编译命令
execute compilation command
$ bitbake fsl-image-qt5
提示:整个编译过程除去下载时间,在16核CPU、16G内存的主机上需要1小时左右。
Tips: It takes about one hour to compile on the 16-core CPU and 16G memory host to complete the compilation process except download time.
2)目标文件
target file
$ ls ./tmp/deploy/images/imx6qsabresd/fsl-image-qt5-imx6qsabresd.tar.bz2
3)复制目标文件
copy target file
我们烧录的QT5系统文件名为“distro-fsl-image-qt5.tar.bz2”,所以需要将编译的文件系统复制为“distro-fsl-image-qt5.tar.bz2”。
The QT5 file system name we programmed is “distro-fsl-image-qt5.tar.bz2”, So we need to copy the compiled file as “distro-fsl-image-qt5.tar.bz2”。
$ cp ./tmp/deploy/images/imx6qsabresd/fsl-image-qt5-imx6qsabresd.tar.bz2 ~/my-imx6/04_image/image-linux-31452/distro-fsl-image-qt5.tar.bz2
编译Linux文件系统(compile Linux file system)1)执行编译命令
execute compile command
$ bitbake fsl-image-machine-test
2)目标文件
target file
$ ls ./tmp/deploy/images/imx6qsabresd/fsl-image-machine-test-imx6qsabresd.tar.bz2
3)复制目标文件
copy target file
我们烧录的QT5系统文件名为“distro-fsl-image.tar.bz2”,所以需要将编译的文件系统复制为“distro-fsl-image.tar.bz2”。
The QT5 file system name We programmed is “distro-fsl-image.tar.bz2”, So we need to copy the compiled file as “distro-fsl-image.tar.bz2”
$ cp ./tmp/deploy/images/imx6qsabresd/fsl-image-machine-test-imx6qsabresd.tar.bz2 ~/my-imx6/04_image/image-linux-31452/distro-fsl-image.tar.bz2
编译QT5的交叉编译工具(compile the cross-compiler tool for QT5)如果不需要自定义QT5交叉编译工具,则跳过本小节。
If you do not need to customize QT5 cross-compiler tool ,skip this section。
1)执行编译命令
execute compilation command
$ bitbake meta-toolchain-qt5
2)目标文件
target file
在“./tmp/deploy/sdk/”目录下可以找到我们编译生成的目标文件。
3)保存目标文件
save target file
将编译得到的“fsl-imx-x11-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-vfp-neon-toolchain-3.14.52-1.1.0.sh”复制到“~/my-imx6/03_tools/”
copy“fsl-imx-x11-glibc-x86_64-meta-toolchain-qt5-cortexa9hf-vfp-neon-toolchain-3.14.52-1.1.0.sh”we compiled to“~/my-imx6/03_tools/”
4)安装QT5交叉编译工具
Install QT5 cross-compiler tool
如果需要使用自己编译的QT5交叉编译工具,需要先删除已经安装的QT5交叉编译工具。并参照前面“安装配置交叉编译工具链”中的“安装QT5交叉编译工具”进行安装。
if you need to use QT5 cross-compiler tool compiled by yourself, you have to remove QT5 cross-compiler tool which has been already Installed. Install it referring to the "Install QT5 cross-compile tool" of "Install and Configure cross-compile tool chain。
|