源碼文件(source code) 評估板對應的Linux版本及對應的源碼文件見下表: The corresponding Linux version of the evaluation board and the corresponding source code files are shown in the table below:
交叉編譯工具文件(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) 3)鏡像目錄 image directory $ mkdir ~/my-imx6/04_image –p $ mkdir ~/my-imx6/04_image/image-linux-31452 –p 安裝交叉編譯工具鏈(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 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。 安裝QT5交叉編譯工具(install QT5 cross compiler tool) 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/n]? 這時輸入“Y”并按“回車(Enter)”鍵表示確認。 then enter“Y”and press“Enter”key for confirmation。 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) 使編譯配置文件生效(validate compiler configuration file)執行編譯(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.
complete compilation 提示:u-boot編譯過程大概需要一、兩分鐘時間。 Tips: u-boot compiling process may take one or two minutes。 目標文件(target file)
compile file 編譯完成后通過ls命令即可看到編譯得到的文件u-boot.imx you can get the compiled file u-boot .imx with ls command after compilation. $ ls 我們需要將編譯得到的u-boot.imx復制為我們的目標文件名。 編譯內核(compile kernel)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 準備編譯(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) 內核編譯配置(kernel compilation configuration)使編譯配置文件生效(validate compilfer configuration file) 清除內核臨時文件(remove kernel temporary file)
內核配置(kernel configuration)
kernel configuration file
$ 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)
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)
target file 使用ls命令可查看編譯得到的目標設備樹文件信息: You can browse the target device tree file information from compilation with ls command: $ ls arch/arm/boot/dts/myimx6ek*.dtb 復制設備樹文件到鏡像目錄 編譯模塊 (compife module)Copy device tree file to image directory $ cp arch/arm/boot/dts/myimx6ek*.dtb ~/my-imx6/04_image/image-linux-31452/
Copy module package to image directory
$ 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)
Create application source code directory and Linux-3.14.52 executable program directory $ mkdir ~/my-demo/source_code -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; }
$ cat hello.c 編譯應用程序(compife application)
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) 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。 編譯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 5)目標文件 target file
保存目標可執行文件(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 準備編譯 (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 |