bitbake recipe - doing a simple copy of the image

后端 未结 1 570
你的背包
你的背包 2021-01-21 17:54

I am attempting to write a recipe that would simple copy two files (MyfileA , MyfileB) to a specific directory when the overall image is built. This is what my directory structu

相关标签:
1条回答
  • 2021-01-21 18:43

    First of all, to create your own meta-layer, you should run command yocto-layer create MyRecipe in your Yocto Environment. This is to make sure that you have all the necessary element in your meta layer. Make sure to put the new meta-layer into conf/bblayers.conf

    Creating HelloWorld Recipe Video can be found here

    Second, to copy a file from one to another directories.

    DESCRIPTION = "Testing Bitbake file"
    SECTION = "TESTING"
    LICENSE = "MIT"
    LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
    PR = "r0"
    
    SRC_URI = "file://MyfileA \
               file://MyfileB "
    
    #specify where to get the files
    S = "${WORKDIR}"
    
    inherit allarch
    
    #create the folder in target machine
    #${D} is the directory of the target machine
    #move the file from working directory to the target machine
    
    do_install() {
            install -d ${D}/TestFolder 
            install -m ${WORKDIR}/MyfileA ${D}/TestFolder
    }
    

    To get more in details, this is my understanding of how the files move around in Yocto.

    You have a directory that stored metadata in /sourced/meta-mylayer/recipes-myRecipe/. In that directory, there would be a folder with the same name as the recipe. I.E. myRecipe/ myRecipe_001.bb.

    You would store the files that are related to myRecipe.bb (usually it is a patch) in myRecipe/ so that SRC_URI will get into that myRecipe/ directory to grab files. I.E. myFileA, myFileB

    Then, you specify the S. This is the location in the Build Directory where unpacked recipe source code resides. By that mean, myFileA and myFileB are moved/copied to there when myRecipe builds.

    Usually, S is equal to ${WORKDIR}, this is equivalent to ${TMPDIR}/work/${MULTIMACH_TARGET_SYS}/${PN}/${EXTENDPE}${PV}-${PR}

    The actual directory depends on several things:

    TMPDIR: The top-level build output directory

    MULTIMACH_TARGET_SYS: The target system identifier

    PN: The recipe name

    EXTENDPE: The epoch - (if PE is not specified, which is usually the case for most recipes, then EXTENDPE is blank)

    PV: The recipe version

    PR: The recipe revision

    After that, we inherit allarch. This class is used for architecture independent recipes/data files (usually scripts).

    Then, the last thing we have to do is copy the files.

    ${D} is the location in the Build Directory where components are installed by do_install task. This location defaults to ${WORKDIR}/image

    ${WORKDIR}/image can also be described as the / directory in the target system.

    Go to ${D} directory and create a folder call TestFolder Then, copy myFileA from ${WORKDIR} to the ${D}/TestFolder

    P.S. Please add comment to fix. There might be mistaken information here, cause I learned all this by myself.

    0 讨论(0)
提交回复
热议问题