Yocto Project是一个开源协作项目。它可以提供一些模板、工具(交叉编译工具链等)用于构建嵌入式系统。有关于yocto_project的详细介绍请看以下博客:
http://www.ibm.com/developerworks/cn/linux/l-yocto-linux/
(声明:博客引自他人文章,特此说明)
这里,作者只讲Ubuntu-12.04环境下的yocto_project配置,其他版本的Linux系统详见上文中的引用博客。
1.下载Ubuntu-12.04必备插件,初始化yocto_project环境:
$ 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
2.使用repo获取yocto_project源码包:
1. Create a bin folder in the home directory. $ mkdir ~/bin (this step may not be needed if the bin folder already exists) $ curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo $ chmod a+x ~/bin/repo 2. Add the following line to the .bashrc file to ensure that the ~/bin folder is in your PATH variable. export PATH=~/bin:$PATH
$ git config --global user.name "Your Name" $ git config --global user.email "Your Email" $ git config --list
3.接下来的例子是展示如何下载NXP(飞思卡尔)厂商的BSP开发使用的yocto_project,其中fsl-release-bsp是自己创建的一个目录:
$ mkdir fsl-release-bsp $ cd fsl-release-bsp $ repo init -u git://git.freescale.com/imx/fsl-arm-yocto-bsp.git -b imx-3.14.38-6UL7D_beta
1.解压下载好的yocto_project工具包,到工具包根目录下,看到如下文件:
/yocto_project$ ls fsl-release-bsp_1025.tgz fsl-setup-release.sh README setup-environment sources
说明:yocto_project工程编译完毕之后非常大,建议预留120G空间给yocto_project。
2.选择你要编译的板子名字,指定编译生成目录,指定生成的文件系统的gui类型(-fb、-x11、-wayland)
使用示例:
$ MACHINE=<machine name> source fsl-setup-release.sh -b <build dir> -e <backend>
比如i.MX6ul平台CPU,编译生成目录指定为build-fb:gui类型为-fb:
/yocto_project$ MACHINE=imx6ulevk source fsl-setup-release.sh -b build-fb -e fb
第一次编译的时候会出现以下信息:
The local.conf file contains the machine and distro specifications: MACHINE ??= 'imx6qsabresd' DISTRO ?= 'poky' ACCEPT_FSL_EULA = "1" The MACHINE configuration can be changed by editing this file, if necessary. ACCEPT_FSL_EULA in the local.conf file indicates that you have accepted the conditions of the EULA.
反正你选择接受就是了,然后一直敲回车,直到开始编译。OK,第一次编译yocto_project非常的漫长,好一点的电脑配置都要一天,用虚拟机带Linux系统的环境进行编译的话,会让你等到蛋疼,so,你可以让电脑一直运行,然后你去泡妞吧。
修改build-dir/conf/local.conf配置文件,具体修改如下图:
如果编译出错,将sources/poky/meta/recipes-sato/images这个文件中的一些包去掉,在最后根据自己的需要加入相应的包
比如:IMAGE_INSTALL += " nodejs"
注意:这里的包名必须按照官方提供的来,不能想当然。
编译完成之后,生成的u-boot、内核、文件系统镜像在build-dir/tmp/deploy/images/machine_board(imx6ulevk)目录下,如图所示:
~/newland-work/yocto_project/build-fb/tmp/deploy/images/imx6ulevk$ ls fsl-image-gui-imx6ulevk-20150908123149.rootfs.ext3 fsl-image-gui-imx6ulevk.manifest zImage fsl-image-gui-imx6ulevk-20150908123149.rootfs.manifest fsl-image-gui-imx6ulevk.sdcard zImage--3.14.38-r0-imx6ul-14x14-evk-20150908123149.dtb fsl-image-gui-imx6ulevk-20150908123149.rootfs.sdcard fsl-image-gui-imx6ulevk.tar.bz2 zImage--3.14.38-r0-imx6ul-14x14-evk-csi-20150908123149.dtb fsl-image-gui-imx6ulevk-20150908123149.rootfs.tar.bz2 modules--3.14.38-r0-imx6ulevk-20150908123149.tgz zImage--3.14.38-r0-imx6ulevk-20150908123149.bin fsl-image-gui-imx6ulevk-20150908214837.rootfs.ext3 modules-imx6ulevk.tgz zImage-imx6ul-14x14-evk-csi.dtb fsl-image-gui-imx6ulevk-20150908214837.rootfs.manifest README_-_DO_NOT_DELETE_FILES_IN_THIS_DIRECTORY.txt zImage-imx6ul-14x14-evk.dtb fsl-image-gui-imx6ulevk-20150908214837.rootfs.sdcard u-boot.imx zImage-imx6ulevk.bin fsl-image-gui-imx6ulevk-20150908214837.rootfs.tar.bz2 u-boot-imx6ulevk.imx fsl-image-gui-imx6ulevk.ext3 u-boot-sd-2015.04-r0.imx
bitbake命令单独编译u-boot:
$ bitbake -c compile -f u-boot-imx
$ bitbake -c deploy -f u-boot-imx //指定编译生成的u-boot镜像到deploy
bitbake命令单独编译kernel:
bitbake -c compile -f linux-imx //编译内核
bitbake -c deploy -f linux-imx //部署内核镜像到deploy目录