美文网首页
YOCTO新建自己的层(layer)

YOCTO新建自己的层(layer)

作者: Lazy_Caaat | 来源:发表于2018-11-14 22:06 被阅读0次
    //记得先执行环境脚本,并在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 
    
    

    相关文章

      网友评论

          本文标题:YOCTO新建自己的层(layer)

          本文链接:https://www.haomeiwen.com/subject/nhsjfqtx.html