嵌入式系统定制工具—yocto

转自:https://blog.csdn.net/zengxianyang/article/details/50298643

1.yocto_project是什么?

Yocto Project是一个开源协作项目。它可以提供一些模板、工具(交叉编译工具链等)用于构建嵌入式系统。有关于yocto_project的详细介绍请看以下博客:

http://www.ibm.com/developerworks/cn/linux/l-yocto-linux/

(声明:博客引自他人文章,特此说明)

2.yocto_project使用简介

2.1 获取yocto_project源码包,构建yocto_project开发环境

这里,作者只讲Ubuntu-12.04环境下的yocto_project配置,其他版本的Linux系统详见上文中的引用博客。

1.下载Ubuntu-12.04必备插件,初始化yocto_project环境:

  1. $ sudo apt-get install libsdl1.2-dev xterm sed cvs subversion coreutils texi2html \  
  2. docbook-utils python-pysqlite2 help2man make gcc g++ desktop-file-utils \  
  3. libgl1-mesa-dev libglu1-mesa-dev mercurial autoconf automake groff curl lzop asciidoc  


2.使用repo获取yocto_project源码包:

[objc] view plain copy
  1. 1. Create a bin folder in the home directory.  
  2. $ mkdir ~/bin (this step may not be needed if the bin folder already exists)  
  3. $ curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo  
  4. $ chmod a+x ~/bin/repo  
  5. 2. Add the following line to the .bashrc file to ensure that the ~/bin folder is in your PATH variable.  
  6. export PATH=~/bin:$PATH  
[objc] view plain copy
  1. $ git config --global user.name "Your Name"  
  2. $ git config --global user.email "Your Email"  
  3. $ git config --list  

3.接下来的例子是展示如何下载NXP(飞思卡尔)厂商的BSP开发使用的yocto_project,其中fsl-release-bsp是自己创建的一个目录:

[objc] view plain copy
  1. $ mkdir fsl-release-bsp  
  2. $ cd fsl-release-bsp  
  3. $ repo init -u git://git.freescale.com/imx/fsl-arm-yocto-bsp.git -b imx-3.14.38-6UL7D_beta  

2.2 使用yocto_project进行NXP(飞思卡尔)BSP开发实例说明

2.2.1 配置环境变量

1.解压下载好的yocto_project工具包,到工具包根目录下,看到如下文件:

[objc] view plain copy
  1. /yocto_project$ ls  
  2. fsl-release-bsp_1025.tgz  fsl-setup-release.sh  README  setup-environment  sources  

2.2.2 yocto_project工程下载和编译

说明:yocto_project工程编译完毕之后非常大,建议预留120G空间给yocto_project。

2.选择你要编译的板子名字,指定编译生成目录,指定生成的文件系统的gui类型(-fb、-x11、-wayland)

使用示例:

[objc] view plain copy
  1. $ MACHINE=<machine name> source fsl-setup-release.sh -b <build dir> -e <backend>  

比如i.MX6ul平台CPU,编译生成目录指定为build-fb:gui类型为-fb:

[objc] view plain copy
  1. /yocto_project$ MACHINE=imx6ulevk source fsl-setup-release.sh -b build-fb -e fb  


第一次编译的时候会出现以下信息:

[objc] view plain copy
  1. The local.conf file contains the machine and distro specifications:  
  2. MACHINE ??= 'imx6qsabresd'  
  3. DISTRO ?= 'poky'  
  4. ACCEPT_FSL_EULA = "1"  
  5. The MACHINE configuration can be changed by editing this file, if necessary.  
  6. ACCEPT_FSL_EULA in the local.conf file indicates that you have accepted the conditions of the EULA.  


反正你选择接受就是了,然后一直敲回车,直到开始编译。OK,第一次编译yocto_project非常的漫长,好一点的电脑配置都要一天,用虚拟机带Linux系统的环境进行编译的话,会让你等到蛋疼,so,你可以让电脑一直运行,然后你去泡妞吧。


3.yocto_project使用技巧和心得

3.1.如何加快yocto_project编译速度

修改build-dir/conf/local.conf配置文件,具体修改如下图:

3.2 编译出错,如何重新编译?

如果编译出错,将sources/poky/meta/recipes-sato/images这个文件中的一些包去掉,在最后根据自己的需要加入相应的包
比如:IMAGE_INSTALL += " nodejs"
注意:这里的包名必须按照官方提供的来,不能想当然。

3.3 编译生成的u-boot、内核、文件系统镜像在哪里?

编译完成之后,生成的u-boot、内核、文件系统镜像在build-dir/tmp/deploy/images/machine_board(imx6ulevk)目录下,如图所示:

[objc] view plain copy
  1. ~/newland-work/yocto_project/build-fb/tmp/deploy/images/imx6ulevk$ ls  
  2. fsl-image-gui-imx6ulevk-20150908123149.rootfs.ext3      fsl-image-gui-imx6ulevk.manifest                    zImage  
  3. fsl-image-gui-imx6ulevk-20150908123149.rootfs.manifest  fsl-image-gui-imx6ulevk.sdcard                      zImage--3.14.38-r0-imx6ul-14x14-evk-20150908123149.dtb  
  4. fsl-image-gui-imx6ulevk-20150908123149.rootfs.sdcard    fsl-image-gui-imx6ulevk.tar.bz2                     zImage--3.14.38-r0-imx6ul-14x14-evk-csi-20150908123149.dtb  
  5. fsl-image-gui-imx6ulevk-20150908123149.rootfs.tar.bz2   modules--3.14.38-r0-imx6ulevk-20150908123149.tgz    zImage--3.14.38-r0-imx6ulevk-20150908123149.bin  
  6. fsl-image-gui-imx6ulevk-20150908214837.rootfs.ext3      modules-imx6ulevk.tgz                               zImage-imx6ul-14x14-evk-csi.dtb  
  7. fsl-image-gui-imx6ulevk-20150908214837.rootfs.manifest  README_-_DO_NOT_DELETE_FILES_IN_THIS_DIRECTORY.txt  zImage-imx6ul-14x14-evk.dtb  
  8. fsl-image-gui-imx6ulevk-20150908214837.rootfs.sdcard    u-boot.imx                                          zImage-imx6ulevk.bin  
  9. fsl-image-gui-imx6ulevk-20150908214837.rootfs.tar.bz2   u-boot-imx6ulevk.imx  
  10. fsl-image-gui-imx6ulevk.ext3                            u-boot-sd-2015.04-r0.imx  

3.4 如何单独编译u-boot、Linux内核呢?

3.4.1 单独编译u-boot

bitbake命令单独编译u-boot:
$ bitbake -c compile -f u-boot-imx
$ bitbake -c deploy -f u-boot-imx        //指定编译生成的u-boot镜像到deploy

3.4.2 单独编译Linux内核

bitbake命令单独编译kernel:

bitbake -c compile -f linux-imx       //编译内核
bitbake -c deploy -f linux-imx        //部署内核镜像到deploy目录


猜你喜欢

转载自blog.csdn.net/qq_38446366/article/details/79725864
今日推荐