bitbake recipe - doing a simple copy of the image

╄→гoц情女王★ 提交于 2019-12-20 03:33:27

问题


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 structure looks like:

MyDir/MyRecipe.bb
MyDir/files/MyfileA
MyDir/files/MyfileB

I would like the two files to be copied to a folder in home (which would not exist initially hence the directories should be created)The folder lets say is called "Testfolder" This is what my bitbake file looks like

DESCRIPTION = "Testing Bitbake file"
PR = "r0"

SRC_URI = "file://MyfileA \
           file://MyfileB "

do_install() {
        install -d  MyfileA ~/TestFolder/
}

Kindly let me know if I am doing something wrong here? When i run bitbake on this I get the following

The BBPATH variable is not set and bitbake did not find a conf/bblayers.conf file in the expected location.
Maybe you accidentally invoked bitbake from the wrong directory?
DEBUG: Removed the following variables from the environment: LANG, LS_COLORS, LESSCLOSE, XDG_RUNTIME_DIR, SHLVL, SSH_TTY, OLDPWD, LESSOPEN, SSH_CLIENT, MAIL, SSH_CONNECTION, XDG_SESSION_ID, _, BUILDDIR

Any help in this regard would be appreciated.


回答1:


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.



来源:https://stackoverflow.com/questions/36163173/bitbake-recipe-doing-a-simple-copy-of-the-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!