Yocto Devtool Tutorial - 38 Create Recipe with Devtool | add & build Commands

Tech-A-Byte
30 Mar 202417:36

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

00:00

🛠️ 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.

05:03

📝 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.

10:05

🚀 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.

15:05

🔄 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

The DEF Tool is a software development tool used for creating and managing recipes in the context of the video. A recipe, in this case, refers to a set of instructions that define how to build a piece of software. The DEF Tool automates the process of fetching source code from a repository and building it into a deployable package. It's central to the video's theme as it's the main tool being demonstrated for creating recipes.

💡Workflow

Workflow in the video refers to the sequence of steps or processes involved in creating a recipe using the DEF Tool. It encompasses activities such as adding a source, building the recipe, deploying it to a target, and finishing the process by placing the recipe into layers. The workflow is crucial for understanding the systematic approach to recipe creation.

💡Source

In the context of the video, 'source' refers to the repository from which the source code is fetched, such as a Git repository. The source is the origin of the software's codebase that the DEF Tool will use to create a recipe. For example, the video mentions fetching source code for a factorial program from a Git repository.

💡Workspace

A workspace in the video is the environment where the source code is checked out and where the DEF Tool operates to create and build recipes. It's a critical component of the DEF Tool workflow, serving as the staging area for recipe development and compilation.

💡Target

The 'target' in the video is the system onto which the built software will be deployed. It's the ultimate destination for the software after it's successfully built and tested. An example from the script is deploying the built recipe to a Beagle Bone Black device.

💡Layers

Layers in the video refer to a component of the DEF Tool system where completed recipes are stored once they are finished. They are a way to organize and manage different recipes and their versions within the tool's ecosystem.

💡Makefile

A Makefile is a file that contains a set of instructions for building a program, which is used with the 'make' build automation tool. In the video, the DEF Tool is shown to create a recipe based on a Makefile, indicating how the software should be compiled and installed.

💡Build

Building, as discussed in the video, is the process of converting source code into executable software. It's an essential step in the DEF Tool workflow where the recipe's instructions are executed to compile the code into a deployable format.

💡Deploy

To deploy, in the context of the video, means to transfer the built software from the workspace to the target system. It's the step where the software is made available on the target device for testing and use.

💡Undeploy

Undeploying is the process of removing the deployed software from the target system. It's the reverse of deploying and is mentioned in the video as one of the steps that can be performed after the software has been tested.

💡Finish

Finishing, as used in the video, refers to the final step in the DEF Tool workflow where the created recipe is placed into the layers and removed from the workspace, signifying the completion of the recipe creation process.

💡Cross Compiler

A cross compiler is a tool that compiles code for a different system architecture than the one on which the compiler is running. In the video, the need to use a cross compiler is highlighted when building the software for the ARM system instead of the host system.

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

play00:00

hi welcome to another video of yoka

play00:03

tutorial Series in this video we are

play00:05

going to learn how to create a recipe

play00:07

with def tool in previous recipe we have

play00:10

learned the about some basic things

play00:13

about the def tool it was kind of

play00:14

introduction to the def tool in this

play00:17

video we are going to learn about the

play00:18

following topics def tool workflow some

play00:21

important commands in Def tool and uh an

play00:24

example with a make

play00:26

file if you haven't watched my

play00:28

introduction to Def tool please watch

play00:29

the first and then continue with this

play00:32

video so let us begin with the def tool

play00:34

workflow so how to create a recipe in

play00:38

Def

play00:39

tool we have the

play00:41

following four blocks a source a

play00:45

workspace Target and layers A source is

play00:49

a repo from which we fetch our source

play00:55

code for example we have a source code

play00:57

somewhere for example in a git or

play01:00

somewhere else from where we fetch that

play01:04

Source if you use this add

play01:07

command the the def tool with def tool

play01:10

the def tool which will fetch that

play01:12

Source into the workspace and it will

play01:15

create a recipe according to the source

play01:19

for example if there is a make file in a

play01:21

source So Def tool will try to create a

play01:26

recipe which is based on OE run make if

play01:28

there is a cmake file in the source or a

play01:31

c build system in the source the dep

play01:33

tool will create accordingly and so on

play01:35

in this example we're going to learn how

play01:38

to make how to create a recipe of a

play01:41

source that is based on make

play01:43

file then when the source is feted here

play01:47

and the def tool will create a recipe

play01:49

then we can run the build command to

play01:51

build the recipe same as same as we do

play01:54

in bitp so for example in bitp we do

play01:58

bitp and the name of the recipe to build

play02:02

but in here we'll do def tool build and

play02:05

the name of the recipe that we have

play02:11

created after that if the build is

play02:15

successful so we can deploy that on the

play02:18

target if the build is unsuccessful so

play02:21

we need to check what we need to add or

play02:24

subtract or modify within the recipe so

play02:28

then after that if the build is

play02:29

successful tool we can test our build

play02:31

into the target system using Diplo

play02:34

Target in our case the target is beagle

play02:36

Moon black so we will deploy our Target

play02:39

to the ble one

play02:40

black and then we will run our final

play02:44

output or some kind of binary file that

play02:47

we have as output a a bin file or uh

play02:51

some code or some util that we have just

play02:54

compiled or we have just built using def

play02:56

tool we can check that on our Target

play02:59

Target using deploy Target after that if

play03:02

we are satisfied and we are certain that

play03:05

it is working properly then we can

play03:07

undeploy and

play03:09

the that binary or that final output

play03:12

will be removed from the

play03:13

target after doing everything when we

play03:16

are certain then what we can do is we

play03:18

can finish our task what does finish

play03:23

mean finish means

play03:25

that we need to place our that

play03:28

particular recipe that we have created

play03:29

it into the layers into the layer system

play03:32

and we will remove it from the workspace

play03:35

there are some also sub uh some uh

play03:39

arguments that we need to give to add to

play03:42

deploy Target undeploy Target and finish

play03:44

that we will learn in

play03:46

the further in this

play03:52

video so in summary to create a recipe

play03:56

from scratch using def tool these five

play03:59

commands are very important add build

play04:03

deploy Target undeploy Target and finish

play04:06

so first of all let us see what is our

play04:10

source I have created a git repo that is

play04:13

a simple C program for calculating the

play04:17

factorial and along with we also have a

play04:20

make file I will put the repo in the

play04:22

description that we are using in our

play04:25

this

play04:28

tutorial before we begin begin with the

play04:30

def tool we have to Source our

play04:31

environment as we do always for also for

play04:34

our breb system so we'll do Source OE

play04:37

run make so now here you can see that we

play04:40

can also use def

play04:43

tool if our workspace is not created

play04:46

when when we run this our add command

play04:48

the workspace will be created and it

play04:50

will be automatically added to our BBL

play04:53

layers. con file so let us create the

play04:56

let us execute this add command first

play04:59

along this in this tutorial I will also

play05:03

demonstrate some errors that we can get

play05:06

while building

play05:08

the our recipe so first of all let us do

play05:11

def

play05:14

tool add and the argument is the name of

play05:19

the recipe the name that we want to give

play05:21

to the recipe so first name is the name

play05:24

that uh I want to give the to the recipe

play05:26

is

play05:28

factorial and then then after that the

play05:31

repo in our case that is a get repo that

play05:33

I have

play05:35

created and now I will press

play05:45

enter you can see that we have we got an

play05:48

error here we got an error here because

play05:51

if you do not specify from which

play05:54

branch do we need to fetch this repo

play05:58

then the def tool tool will try to fetch

play06:01

from Master Branch as it is written here

play06:04

but in our repo we don't have our Master

play06:06

Branch instead we have the branch name

play06:08

as main so what we can do is we will

play06:11

give an extra argument

play06:15

SRC

play06:17

Branch

play06:18

Main and

play06:21

then SRC branch

play06:25

mean and then we will try to run it once

play06:28

more

play06:39

so as you can see that this time it has

play06:42

built and it has added and created this

play06:46

factorial unorg getbb recipe now what we

play06:51

can do is we will see our

play06:54

B.C as you see in our

play06:57

B.C this workspaces

play07:00

also automatically added to our conf

play07:03

file bs. conon file otherwise our def

play07:06

tool will not work because it cannot see

play07:08

this

play07:12

folder now what we'll do is first of all

play07:15

we will check the recipe what it has

play07:17

created for

play07:19

us so you can see that here is the SRC

play07:23

URI that is which is from git factorial

play07:27

doget and the branch is Main

play07:30

furthermore it has also automatically

play07:32

created

play07:33

our version the revision it has set our

play07:37

source directory you can see here we

play07:40

have these three build

play07:41

processes to configure to compile and

play07:45

install but you can see that there is

play07:47

nothing to do in do configure if you

play07:48

want to do some extra step to configure

play07:51

our build then we can added here right

play07:54

now we don't need it so what we'll do is

play07:56

we'll

play07:58

remove now let us see

play08:00

our sources what do we have in our

play08:03

sources to see the sources you need to

play08:05

go into the workspace sources and here

play08:10

you will see that we have a factorial

play08:12

this hello world da I have created in

play08:14

the previous

play08:15

video and this is our new factorial code

play08:19

so in

play08:20

this we will go and we will see that

play08:23

here we have two main files C do c and

play08:27

do make file so what now we can see both

play08:31

of these files using

play08:33

this so in the factorial file it is a

play08:37

simple factorial code which asks for a

play08:40

number and then it generates the

play08:42

factorial or calculates the factorial in

play08:45

make file we have how to compile or make

play08:50

this code so here we have default

play08:54

compiler it is GCC our clex our Target

play08:58

name our user bin if you don't know how

play09:02

Mech file works please watch my video

play09:05

on creating decip with me file which is

play09:09

without Dev

play09:10

tool so now what we'll do is first of

play09:13

all we will simply try to build the

play09:19

recipe to build the recipe we need to

play09:23

run def

play09:25

tool

play09:27

built Factor

play09:40

it is

play09:44

building you can see that we have got

play09:47

some error and this will be the case

play09:49

most of the time first of all we don't

play09:52

have we have an error during do install

play09:56

what does it

play09:58

say it says

play10:01

that cannot install cannot create

play10:04

regular file user been factorial

play10:06

permission denied why it happens because

play10:09

if our if we see our make file here in

play10:13

install process we are installing to the

play10:16

prefix and the prefix is user bin this

play10:19

user bin is actually the user bin of my

play10:22

this laptop or this my system host

play10:25

system which cannot be exist without the

play10:27

permission but we do not not want to

play10:29

install it in our host system we want to

play10:32

install it in our Target system to do

play10:35

that we need to override this

play10:38

prefix so to override this prefix there

play10:42

are possibly two methods first of all we

play10:45

can give here an extra argument for

play10:48

prefix and it will install it into the

play10:52

that particular folder we can also use

play10:55

extra o run make so in our case we are

play10:58

going to use EXT EXT ra OE run make if

play11:01

you don't know how to use extra OE Run

play11:03

please watch my video on extra o run

play11:05

make I have made I have made an extra

play11:06

video for that we'll use

play11:11

extra OE make and then here we will give

play11:18

prefix equals and where we want to

play11:21

install we want to install into

play11:26

our

play11:28

destination the variable of the

play11:30

destination is D if you don't know

play11:32

please watch my video on basic variables

play11:34

in Yoko there I have explained about the

play11:37

basic variables for example destination

play11:39

source and further on and then we need

play11:41

to install it in our user

play11:44

bin whose variable is bin

play11:49

di so now here now we have overwritten

play11:55

this prefix variable which is now in the

play11:58

destination folder now what we'll do is

play12:01

we will run it once

play12:18

more after running it once more

play12:22

again the installation

play12:26

fails why it fails this time

play12:35

it says cannot create regular file user

play12:40

bin no such file or directory what we

play12:42

need to do is before we install our

play12:46

binary into user bin we need to create

play12:48

it so how we create it in the install

play12:52

we'll do

play12:55

install minus D and then we'll do

play13:01

D

play13:03

and wiin

play13:06

Di so now it will first create the

play13:09

folder and then it will install in this

play13:11

folder so now what we'll do is we'll run

play13:14

it once

play13:27

again as you can see that once again we

play13:30

got an error it says file format not

play13:33

recognized what does it mean first of

play13:36

all let us go to

play13:38

our

play13:40

source uh we are already in Source let

play13:42

us see here we have this factorial

play13:45

binary already created but what is the

play13:48

problem actually so let us

play13:51

check by running this command file

play13:54

factorial if you run this command you

play13:57

can see that it says 64 bit and it is

play14:00

been built for the x86 64 system it

play14:04

means it has been built for my this

play14:07

particular system if I will run it from

play14:10

here it will definitely run and if I

play14:14

calculate so it will give me the answer

play14:16

as well but we don't want to build it

play14:19

for our this system we want to build it

play14:21

for not for our who we don't want to

play14:23

build it for our H system but we want to

play14:25

build it for our destination system for

play14:29

our Target system for that what we need

play14:32

to do is if you see that here our CC and

play14:36

C flags are for this host system we also

play14:39

need to overwrite all these two

play14:41

variables for that we can also

play14:45

use

play14:47

extra om make

play14:50

variable so first of all CC which will

play14:53

be equal to and here we need to keep in

play14:56

mind that we need to provide these

play15:00

single commas I don't know if it works

play15:02

but we definitely need to define the

play15:05

double inverted

play15:07

commas let us try it first with single

play15:10

inverted commas and then here we need to

play15:13

pass

play15:16

this CC compiler variable this compiler

play15:20

here is actually our cross compiler that

play15:22

is used by our build system and this CC

play15:27

variable holds the CC variable holds

play15:32

the cross compiler for our Arm System

play15:35

and all

play15:37

its uh Flex now we need to give C

play15:42

flex and also with C Flex We need to

play15:46

provide

play15:48

this clex variable of our Target

play15:55

system now let us compile it build it

play15:58

once more

play16:18

if you see this time it has been built

play16:19

successfully and now if you will

play16:22

check again using the file variable uh

play16:26

using the file command this time time

play16:29

you see that it is thir dobit and it has

play16:31

been compiled for the arm system now

play16:35

what we will do is we will deploy this

play16:39

into our Target and we will test it

play16:42

there so I have connected the Beagle

play16:44

bone

play16:45

black

play16:47

using SSH so first of all let us check

play16:51

if the factorial is already present or

play16:55

not I have written a factorial and it

play16:58

says no command

play17:00

[Music]

play17:08

found this time now we will

play17:13

deploy and we

play17:15

will then finish

play17:18

it and we will create the recipe and we

play17:21

will transfer the recipe into the layers

play17:24

into our meta layers but that we will do

play17:26

in the next video thanks for watching

play17:30

please like And subscribe my channel and

play17:32

I will see you in the next

play17:34

video

Rate This

5.0 / 5 (0 votes)

相关标签
Deftool TutorialYoka SeriesRecipe CreationBuild SystemMakefile ExampleGit RepoCross CompilationBeaglebone BlackEmbedded LinuxOpenEmbedded
您是否需要英文摘要?