Yocto Devtool Tutorial - 38 Create Recipe with Devtool | add & build Commands
Summary
TLDRThis tutorial video guides viewers on creating a recipe using the def tool, focusing on the workflow and essential commands. It covers the process of fetching source code, building, deploying, and finishing a recipe. The video uses a factorial C program example with a make file, demonstrating how to resolve common errors like permission issues and file format recognition. It also touches on the importance of using the right compiler for the target system.
Takeaways
- 🔧 The DEFTOOL workflow involves four main blocks: Source, Workspace, Target, and Layers.
- 🛠️ Source is where the source code is fetched from, like a Git repository.
- 📝 The 'add' command in DEFTOOL fetches the source into the workspace and creates a recipe.
- 🔄 Recipes in DEFTOOL are created based on the source code's build system, such as Makefiles or CMake.
- 🏗️ The 'build' command is used to compile the recipe, similar to 'bitbake' in Yocto.
- 📦 Once built, the recipe can be deployed to a target system using 'deploy target'.
- 🔄 'Undeploy target' is used to remove the deployed binary from the target system.
- 📚 The 'finish' command places the created recipe into the layer system and removes it from the workspace.
- 👨💻 The tutorial demonstrates creating a recipe for a simple C program with a Makefile.
- 🚫 Errors during the build process are common and are addressed by modifying the recipe or build environment.
- 🔄 The 'extra' variable is used to override the default prefix during the installation step to ensure the binary is built for the target system.
Q & A
What is the main focus of this Yoka tutorial video?
-The main focus of this Yoka tutorial video is to teach viewers how to create a recipe using the def tool, including the workflow and important commands.
What are the four blocks involved in creating a recipe with def tool?
-The four blocks involved in creating a recipe with def tool are Source, Workspace, Target, and Layers.
What is the purpose of the 'add' command in def tool?
-The 'add' command in def tool is used to fetch the source code from a repository into the workspace and create a recipe based on the source.
How does def tool determine the build system for a recipe?
-Def tool determines the build system for a recipe by checking for the presence of a makefile, cmake file, or other build system indicators in the source code.
What does the 'build' command do in def tool?
-The 'build' command in def tool is used to compile the recipe, similar to how one would use 'bitbake' with the recipe name to build in Yocto.
What is the role of the 'deploy target' command in def tool?
-The 'deploy target' command in def tool is used to deploy the successfully built binary to the target system for testing.
What does the 'finish' command accomplish in def tool?
-The 'finish' command in def tool places the created recipe into the layer system and removes it from the workspace.
What is the significance of the 'oe-runmake' variable in the context of def tool?
-The 'oe-runmake' variable is used to override the prefix for installation, directing the build output to the desired location within the target system rather than the host system.
Why is it necessary to create the 'user/bin' directory before installation in the def tool recipe?
-It is necessary to create the 'user/bin' directory before installation because the def tool will not automatically create directories for the installation path, and it needs to exist for the binary to be installed correctly.
What error occurs if the binary is built for the wrong architecture?
-If the binary is built for the wrong architecture, an error stating 'file format not recognized' or a similar message indicating incompatibility with the target system's architecture will occur.
How can one ensure that the binary is built for the target system's architecture?
-To ensure the binary is built for the target system's architecture, one must set the appropriate cross-compiler variables such as 'CC' and 'CFLAGS' using the 'EXTRA_OEMAKE' variable in the def tool recipe.
Outlines
🛠️ Introduction to DEF Tool Workflow
The video begins with an introduction to the DEF tool, emphasizing its role in creating recipes. The presenter outlines the four primary components of the DEF tool workflow: source, workspace, target, and layers. The source is the repository from which the source code is fetched, such as a git repository. The workspace is where the source is fetched and a recipe is created based on the source code, such as a makefile. The target is the system where the built recipe is deployed, and the layers are where the recipe is placed after it's finished. The video promises to cover important DEF tool commands and an example with a makefile. The presenter also mentions that if viewers are unfamiliar with DEF tool, they should watch the introductory video before proceeding.
📝 Understanding DEF Tool Recipe Creation
The presenter explains how to create a recipe using DEF tool, starting with the 'add' command followed by the recipe name and repository. An error is encountered because the branch is not specified, leading to a correction where the 'SRCBRANCH' argument is added to fetch from the correct branch. The video then shows the contents of the recipe created by DEF tool, including the source URI, version, and build processes. The presenter also discusses the need to modify the recipe if additional configuration steps are required. The video concludes this section by detailing the process of building the recipe and encountering an error related to file installation permissions.
🚀 Troubleshooting DEF Tool Recipe Build
The section starts with an error encountered during the installation process of the recipe. The error is due to a permission issue when trying to install to 'user/bin' on the host system. The presenter explains that the installation should target the destination system and not the host. To resolve this, the 'EXTRA_OEMAKE' variable is used to override the installation prefix. The presenter then demonstrates how to create the necessary directory for installation and retries the build. Another error occurs due to the binary being built for the wrong architecture (x86_64 instead of ARM). The video explains how to use 'EXTRA_OEMAKE' to set the correct cross-compiler and flags for the target system.
🔄 Deploying and Testing the Recipe
After successfully building the recipe for the target architecture, the presenter connects to the Beaglebone Black via SSH to deploy and test the recipe. Initially, the 'factorial' command is not found, indicating that the recipe has not yet been deployed. The presenter then proceeds to deploy the recipe and plans to finish and transfer it to the layers in the next video. The video concludes with a call to action for viewers to like and subscribe for more content.
Mindmap
Keywords
💡DEF Tool
💡Workflow
💡Source
💡Workspace
💡Target
💡Layers
💡Makefile
💡Build
💡Deploy
💡Undeploy
💡Finish
💡Cross Compiler
Highlights
Introduction to creating a recipe with the def tool.
Explanation of the def tool workflow.
Description of the four blocks in def tool: source, workspace, target, and layers.
How to fetch source code using the def tool.
Creating a recipe based on a make file.
Building the recipe using the def tool.
Deploying the build onto the target system.
The importance of the five key commands: add, build, deploy target, undeploy target, and finish.
Source the environment for the build system.
How to add a recipe without an existing workspace.
Error handling while fetching the repo from the wrong branch.
Automatic addition of the workspace to the BBL layers.conf file.
Explanation of the SRC_URI and build processes in the recipe.
Navigating the sources and understanding the make file.
Building the recipe and encountering errors during do_install.
Fixing permission issues by overriding the installation prefix.
Creating the destination directory for the binary installation.
Addressing the file format not recognized error by cross-compiling for the target system.
Deploying the successfully built binary to the Beagle Bone Black.
Testing the deployed binary on the target system.
Next steps: creating the recipe and transferring it to the layers.
Transcripts
hi welcome to another video of yoka
tutorial Series in this video we are
going to learn how to create a recipe
with def tool in previous recipe we have
learned the about some basic things
about the def tool it was kind of
introduction to the def tool in this
video we are going to learn about the
following topics def tool workflow some
important commands in Def tool and uh an
example with a make
file if you haven't watched my
introduction to Def tool please watch
the first and then continue with this
video so let us begin with the def tool
workflow so how to create a recipe in
Def
tool we have the
following four blocks a source a
workspace Target and layers A source is
a repo from which we fetch our source
code for example we have a source code
somewhere for example in a git or
somewhere else from where we fetch that
Source if you use this add
command the the def tool with def tool
the def tool which will fetch that
Source into the workspace and it will
create a recipe according to the source
for example if there is a make file in a
source So Def tool will try to create a
recipe which is based on OE run make if
there is a cmake file in the source or a
c build system in the source the dep
tool will create accordingly and so on
in this example we're going to learn how
to make how to create a recipe of a
source that is based on make
file then when the source is feted here
and the def tool will create a recipe
then we can run the build command to
build the recipe same as same as we do
in bitp so for example in bitp we do
bitp and the name of the recipe to build
but in here we'll do def tool build and
the name of the recipe that we have
created after that if the build is
successful so we can deploy that on the
target if the build is unsuccessful so
we need to check what we need to add or
subtract or modify within the recipe so
then after that if the build is
successful tool we can test our build
into the target system using Diplo
Target in our case the target is beagle
Moon black so we will deploy our Target
to the ble one
black and then we will run our final
output or some kind of binary file that
we have as output a a bin file or uh
some code or some util that we have just
compiled or we have just built using def
tool we can check that on our Target
Target using deploy Target after that if
we are satisfied and we are certain that
it is working properly then we can
undeploy and
the that binary or that final output
will be removed from the
target after doing everything when we
are certain then what we can do is we
can finish our task what does finish
mean finish means
that we need to place our that
particular recipe that we have created
it into the layers into the layer system
and we will remove it from the workspace
there are some also sub uh some uh
arguments that we need to give to add to
deploy Target undeploy Target and finish
that we will learn in
the further in this
video so in summary to create a recipe
from scratch using def tool these five
commands are very important add build
deploy Target undeploy Target and finish
so first of all let us see what is our
source I have created a git repo that is
a simple C program for calculating the
factorial and along with we also have a
make file I will put the repo in the
description that we are using in our
this
tutorial before we begin begin with the
def tool we have to Source our
environment as we do always for also for
our breb system so we'll do Source OE
run make so now here you can see that we
can also use def
tool if our workspace is not created
when when we run this our add command
the workspace will be created and it
will be automatically added to our BBL
layers. con file so let us create the
let us execute this add command first
along this in this tutorial I will also
demonstrate some errors that we can get
while building
the our recipe so first of all let us do
def
tool add and the argument is the name of
the recipe the name that we want to give
to the recipe so first name is the name
that uh I want to give the to the recipe
is
factorial and then then after that the
repo in our case that is a get repo that
I have
created and now I will press
enter you can see that we have we got an
error here we got an error here because
if you do not specify from which
branch do we need to fetch this repo
then the def tool tool will try to fetch
from Master Branch as it is written here
but in our repo we don't have our Master
Branch instead we have the branch name
as main so what we can do is we will
give an extra argument
SRC
Branch
Main and
then SRC branch
mean and then we will try to run it once
more
so as you can see that this time it has
built and it has added and created this
factorial unorg getbb recipe now what we
can do is we will see our
B.C as you see in our
B.C this workspaces
also automatically added to our conf
file bs. conon file otherwise our def
tool will not work because it cannot see
this
folder now what we'll do is first of all
we will check the recipe what it has
created for
us so you can see that here is the SRC
URI that is which is from git factorial
doget and the branch is Main
furthermore it has also automatically
created
our version the revision it has set our
source directory you can see here we
have these three build
processes to configure to compile and
install but you can see that there is
nothing to do in do configure if you
want to do some extra step to configure
our build then we can added here right
now we don't need it so what we'll do is
we'll
remove now let us see
our sources what do we have in our
sources to see the sources you need to
go into the workspace sources and here
you will see that we have a factorial
this hello world da I have created in
the previous
video and this is our new factorial code
so in
this we will go and we will see that
here we have two main files C do c and
do make file so what now we can see both
of these files using
this so in the factorial file it is a
simple factorial code which asks for a
number and then it generates the
factorial or calculates the factorial in
make file we have how to compile or make
this code so here we have default
compiler it is GCC our clex our Target
name our user bin if you don't know how
Mech file works please watch my video
on creating decip with me file which is
without Dev
tool so now what we'll do is first of
all we will simply try to build the
recipe to build the recipe we need to
run def
tool
built Factor
it is
building you can see that we have got
some error and this will be the case
most of the time first of all we don't
have we have an error during do install
what does it
say it says
that cannot install cannot create
regular file user been factorial
permission denied why it happens because
if our if we see our make file here in
install process we are installing to the
prefix and the prefix is user bin this
user bin is actually the user bin of my
this laptop or this my system host
system which cannot be exist without the
permission but we do not not want to
install it in our host system we want to
install it in our Target system to do
that we need to override this
prefix so to override this prefix there
are possibly two methods first of all we
can give here an extra argument for
prefix and it will install it into the
that particular folder we can also use
extra o run make so in our case we are
going to use EXT EXT ra OE run make if
you don't know how to use extra OE Run
please watch my video on extra o run
make I have made I have made an extra
video for that we'll use
extra OE make and then here we will give
prefix equals and where we want to
install we want to install into
our
destination the variable of the
destination is D if you don't know
please watch my video on basic variables
in Yoko there I have explained about the
basic variables for example destination
source and further on and then we need
to install it in our user
bin whose variable is bin
di so now here now we have overwritten
this prefix variable which is now in the
destination folder now what we'll do is
we will run it once
more after running it once more
again the installation
fails why it fails this time
it says cannot create regular file user
bin no such file or directory what we
need to do is before we install our
binary into user bin we need to create
it so how we create it in the install
we'll do
install minus D and then we'll do
D
and wiin
Di so now it will first create the
folder and then it will install in this
folder so now what we'll do is we'll run
it once
again as you can see that once again we
got an error it says file format not
recognized what does it mean first of
all let us go to
our
source uh we are already in Source let
us see here we have this factorial
binary already created but what is the
problem actually so let us
check by running this command file
factorial if you run this command you
can see that it says 64 bit and it is
been built for the x86 64 system it
means it has been built for my this
particular system if I will run it from
here it will definitely run and if I
calculate so it will give me the answer
as well but we don't want to build it
for our this system we want to build it
for not for our who we don't want to
build it for our H system but we want to
build it for our destination system for
our Target system for that what we need
to do is if you see that here our CC and
C flags are for this host system we also
need to overwrite all these two
variables for that we can also
use
extra om make
variable so first of all CC which will
be equal to and here we need to keep in
mind that we need to provide these
single commas I don't know if it works
but we definitely need to define the
double inverted
commas let us try it first with single
inverted commas and then here we need to
pass
this CC compiler variable this compiler
here is actually our cross compiler that
is used by our build system and this CC
variable holds the CC variable holds
the cross compiler for our Arm System
and all
its uh Flex now we need to give C
flex and also with C Flex We need to
provide
this clex variable of our Target
system now let us compile it build it
once more
if you see this time it has been built
successfully and now if you will
check again using the file variable uh
using the file command this time time
you see that it is thir dobit and it has
been compiled for the arm system now
what we will do is we will deploy this
into our Target and we will test it
there so I have connected the Beagle
bone
black
using SSH so first of all let us check
if the factorial is already present or
not I have written a factorial and it
says no command
[Music]
found this time now we will
deploy and we
will then finish
it and we will create the recipe and we
will transfer the recipe into the layers
into our meta layers but that we will do
in the next video thanks for watching
please like And subscribe my channel and
I will see you in the next
video
Посмотреть больше похожих видео
5.0 / 5 (0 votes)