YOCTO新建自己的层(layer)

//记得先执行环境脚本,并在sources目录下执行下面的命令,在哪个目录,新的layer文件夹就会创建在哪里!
marvin@ubuntu:build$ yocto-layer create my_layer
//优先级
Please enter the layer priority you'd like to use for the layer: [default: 6] 
//是否创建一个recipe的例子
Would you like to have an example recipe created? (y/n) [default: n] y
Please enter the name you'd like to use for your example recipe: [default: example] 
//是否创建一个bbappend的例子
Would you like to have an example bbappend file created? (y/n) [default: n] y
//输入bbappend的名字
Please enter the name you'd like to use for your bbappend file: [default: example] 
//版本号,最好不要改。
Please enter the version number you'd like to use for your bbappend file (this should match the recipe you're appending to): [default: 0.1] 

New layer created in meta-my_layer.
//记得在主bblayer里enable这个新建的layer
Don't forget to add it to your BBLAYERS (for details see meta-my_layer/README).
marvin@ubuntu:build$ 
2 将新建的层添加到我们的工程中。

修改fsl-setup-release.sh添加

echo "BBLAYERS += \" \${BSPDIR}/sources/meta-my_layer\"" >> $BUILD_DIR/conf/bblayers.conf
参考原文件中的写法

使用sudo vim fsl-setup-release.sh
保存的时候先用:w!保存文本
然后退出。


修改完的样子
  • 编译我们新的层
DISTRO=fsl-imx-x11 MACHINE=imx6qsabresd source fsl-setup-release.sh -b build
bitbake example  //example是因为我们使用的默认名称

找到我们编译出的文件

marvin@ubuntu:0.1-r0$ pwd
/home/marvin/fsl-release-bsp/build/tmp/work/cortexa9hf-neon-poky-linux-gnueabi/example/0.1-r0
marvin@ubuntu:0.1-r0$ ls
configure.sstate   example.spec  image            packages-split  sstate-build-package      sstate-build-package_write_rpm  sysroot-destdir
debugsources.list helloworld license-destdir  pkgdata         sstate-build-packagedata  sstate-build-populate_lic       temp
deploy-rpms        helloworld.c  package          pseudo          sstate-build-package_qa   sstate-build-populate_sysroot
marvin@ubuntu:0.1-r0$ file helloworld
helloworld: ELF 32-bit LSB  executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=1891ac9d8827b6208e0eadeb06585bd9b53af121, not stripped
marvin@ubuntu:0.1-r0$ 

可以看到我们之前例子中的源码被交叉编译成arm文件了


源码

此时文件系统里并没有我们的helloworld,这时挂载镜像文件是没有我们的程序的。

sudo mount -o loop -t ext4 fsl-release-bsp/build/tmp/deploy/images/imx6qsabresd/fsl-image-qt5-imx6qsabresd.ext4 /mnt

看完后记得umount

因为我们的APP没有加进系统,现在我们加进去。

vim ../sources/meta-my_layer/conf/layer.conf 

打开后添加一行命令

# We have a conf and classes directory, add to BBPATH
BBPATH .= ":${LAYERDIR}"

# We have recipes-* directories, add to BBFILES
BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
        ${LAYERDIR}/recipes-*/*/*.bbappend"
------------------------------------------------------
IMAGE_INSTALL_append = "example"   //添加这句话
------------------------------------------------------
BBFILE_COLLECTIONS += "my_layer"
BBFILE_PATTERN_my_layer = "^${LAYERDIR}/"
BBFILE_PRIORITY_my_layer = "6"
重新编译文件系统
bitbake fsl-image-qt5

sudo mount -o loop -t ext4 fsl-release-bsp/build/tmp/deploy/images/imx6qsabresd/fsl-image-qt5-imx6qsabresd.ext4 /mnt

ls /mnt/usr/bin/helloworld 

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,969评论 19 139
  • 1.ios高性能编程 (1).内层 最小的内层平均值和峰值(2).耗电量 高效的算法和数据结构(3).初始化时...
    欧辰_OSR阅读 29,613评论 8 265
  • Linux习惯问题: 在vim编辑时,按了ctrl + s后,再按ctrl + q就可以继续执行了。ctrl + ...
    光着脚的鞋阅读 4,544评论 0 16
  • 一、Python简介和环境搭建以及pip的安装 4课时实验课主要内容 【Python简介】: Python 是一个...
    _小老虎_阅读 5,819评论 0 10
  • 大概我们曾经有过同样的感慨 同样的快乐 同样的悲伤 同样的难过 所以才迎来了今世的回眸一笑
    半分微凉阅读 186评论 -1 1