//記得先執(zhí)行環(huán)境腳本,并在sources目錄下執(zhí)行下面的命令,在哪個(gè)目錄,新的layer文件夾就會(huì)創(chuàng)建在哪里!
marvin@ubuntu:build$ yocto-layer create my_layer
//優(yōu)先級(jí)
Please enter the layer priority you'd like to use for the layer: [default: 6]
//是否創(chuàng)建一個(gè)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]
//是否創(chuàng)建一個(gè)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]
//版本號(hào),最好不要改。
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這個(gè)新建的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

參考原文件中的寫(xiě)法
使用sudo vim fsl-setup-release.sh
保存的時(shí)候先用:w!保存文本
然后退出。

修改完的樣子
- 編譯我們新的層
DISTRO=fsl-imx-x11 MACHINE=imx6qsabresd source fsl-setup-release.sh -b build
bitbake example //example是因?yàn)槲覀兪褂玫哪J(rèn)名稱
找到我們編譯出的文件
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文件了

源碼
此時(shí)文件系統(tǒng)里并沒(méi)有我們的helloworld,這時(shí)掛載鏡像文件是沒(méi)有我們的程序的。
sudo mount -o loop -t ext4 fsl-release-bsp/build/tmp/deploy/images/imx6qsabresd/fsl-image-qt5-imx6qsabresd.ext4 /mnt
看完后記得umount
因?yàn)槲覀兊腁PP沒(méi)有加進(jìn)系統(tǒng),現(xiàn)在我們加進(jìn)去。
vim ../sources/meta-my_layer/conf/layer.conf
打開(kāi)后添加一行命令
# 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"
重新編譯文件系統(tǒng)
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