hello world bb for for yocto

How to write a hello world recipe in yocto

 

I hope you are already setup the yocto source in your Ubuntu pc. if not click here how to setup yocto in ubuntu pc

 

helloworld recipe : helloworld.bb

 

This is mainly three parts

1. Descption

2. Download

3. compilation

 

 

Step-1: for every recipe we will write descrption,summury,license like below

 

DESCRPTION =”Basic recipe for helloworld.c”

By default bitbake will check for license for every recipe. if you have written your own recipe with source. you can keep the license close. see below

LICENSE = “CLOSED”

 

Step-2: here we can Download the source locally or using internet. below is SRC_URI will fetch the source.

syntax:

SRC_URI = “file://your source file”

S =  “${WORKDIR}”

 

Step-3: here we can extract the source and compile the source and also copy the compiled binaries to rootfs.

syntax for compilation:

 

do_compile(){

${CC} your source file

}

 

syntax for installation:

 

do_install(){

install -d ${D}${bindir}

install -m 0777 ${S}/binary ${D}${bindir}

}

Below is the simple example for helloworld.bb recipe.

 

example: helloworld.bb

 

DESCRPTION =”Basic recipe for helloworld.c”

LICENSE = “CLOSED”

SRC_URI = “file://helloworld.c”

S =  “${WORKDIR}”

do_compile(){

${CC} helloworld.c -o hello

}

do_install(){

install -d ${D}${bindir}

install -m 0777 ${S}/hello ${D}${bindir}

}

 

If you want to learn more click here.