Creating our own meta layer & creating a custom helloworld application and adding it to our project using yocto
Hello All,
In my previous article we have seen that how to construct an embedded linux image for "qemux86-64" and verify its booting.
In case if you have missed it, here is the link: https://learnyoctowithme.blogspot.com/2022/04/constructing-embedded-linux-image-for.html
In this article we are going to see how we can create our own layer and adding it to our project using yocto
pre-requisite: You need to be familiar with my previous article as it shows the image construction and setting up the build environment
link : https://www.blogger.com/blog/posts/8695339245532547417?tab=rj
what is a layer?
Layer is nothing but a logical collection of related recipes
Types of Layers: oe-core, BSP Layer, application layer
Layer name starts with meta-, but this is not a technical restriction.
Eg. meta-mylayer
creating our own meta layer(meta-mylayer) using yocto project:
step 1: source the environment
$ source ./oe-init-build-env build_x86
step 2: Inside build_x86 folder, run the command
$ bitbake-layers add-layer /home/shashank/poky/meta-mylayer
NOTE: This will create a new folder called "meta-mylayer" in poky directory
step 3: switch to meta-mylayer directory
$ cd ../poky/meta-mylayer
Inside meta-mylayer directory we can see folders called conf and recipes-example
conf folder consists of layer configuration file as seen below
recipes-example folder consists of example folder and in example folder we can find example_0.1.bb file
step 4: meta-mylayer is already added to your bblayer.conf file, to view it use command
$ bitbake-layers show-layers
step 5: now check your layer compatibility using command
$ yocto-check-layer ../meta-mylayer
creating a sample hello world.c application and integrating it to our rootfs:
step 1: Inside meta-mylayer folder, there is a folder named recipes-example and inside recipes-example folder there is a folder called example
$ cd poky/meta-mylayer/recipes-examples/example
step 2: create a folder named files inside example folder
$ mkdir files
step 3: switch to files folder and create a file called helloworld.c
$ vi helloworld.c
step 4: switch back to example folder
$ cd ..
step 5: now create a file called helloworld_0.1.bb with below content
$ vi helloworld_0.1.bb
step 6: now compile the helloworld recipe using
$ bitbake helloworld
Now your helloworld recipe has been successfully compiled using bitbake
step 7: now add helloworld package to our image
switch to build_x86 folder
$ cd ../../../build_x86
open the local.conf file
$ vi conf/local.conf
append the line IMAGE_INSTALL_append +="helloworld"
step 8: now compile the image as
$ bitbake core-image-minimal
now image compilation has been successful
step 9: now boot the image using qemu
$ runqemu nographic
step 10: after image booted, run the command to verify the helloworld application
$ helloworld
Thats it we have successfully integrated our helloworld application to our rootfs.
Comments
Post a Comment