Yocto Project Build tools
In this article, we’ll be talking about some Yocto build tools I've used so far working on my task "add support for elfutils debuginfod" in the Yocto project. In my previous post here, I passively made mention of some of the tools and now in today’s article we are going to delve right into explaining these tools and I'll also discuss what my internship task is about.
Where do we start? Okay....
A proper Introduction to The Yocto project
“The Yocto Project (YP) is an open source collaboration project that helps developers create custom Linux-based systems regardless of the hardware architecture. The project provides a flexible set of tools and a space where embedded developers worldwide can share technologies, software stacks, configurations, and best practices that can be used to create tailored Linux images for embedded and IOT devices, or anywhere a customized Linux OS is needed. “yeah, I just just quoted that word for word from the the company’s page because there was no better way to describe it but in summary The Yocto project helps you create customized Linux images, and software. to know more about Yocto project check the overview and documentations here
devtool
One of the tools Yocto provides is a command line tool “devtool”.
The devtool command line tool enables you to add new recipes software to be built, modify source code of a recipe, or even upgrade recipes. Lets dig into the steps used in devtool to customize a recipe.
1) Assuming you have built an image according to the documentation here
2) Run the command devtool modify <recipename>
in mycase it was devtool modify elfutils
What this command does is that it fetches the sources and unpacks them into /build/workspace/sources/<recipename> directory.
3) cd into your source code directory and make the required changes in your code, note that these changes are being made in your vi editor.
4) After the changes are being made and you’re okay with the changes, in your source folder commit the changes.
5) Run the command devtool update-recipe <recipename>
command to update the existing recipe and create a patch of the changes you made in your layer, or run the command devtool update-recipe <recipename> -a <path to your layer>’
to create a bbappend and patch of the changes you made.
6) Finish your work with the recipe using the command devtool finish <recipename>’
Note you must have staged and committed your patches within the local git repository before you use the devtool finish
command.
7) You can now delete the /build/workspace/sources/<recipename> directory folder.
You can read more about using devtool in Yocto here using-devtool-in-your-sdk-workflow
Quilt
you know one can also apply patches in Yocto using ‘quilt’ tool, although that's an old school way of applying patches to recipes layer. below are Steps using quilt to customize a recipe.
1) Again assuming you have built an image according to the documentation here
2) Find the recipe you want to modify and add a SRC_URI for the patch file, like this below in the recipe.SRC_URI += "file://<name>.patch"
3) If a folder named "files" in the same folder of recipe doesn’t already exist create one.
4) Create a blank file with the same name given in the recipe manually or using command line as such; touch files/<file-name>.patch
5) Run the command: bitbake <recipe> -c devshell
this will open up the quilt terminal.
6) Do "quilt top" and verify if the patch file is reflected there.# quilt top
patches/<file-name>.patch
if the patch is not reflected, you might have to use quilt pop and quilt push to get the specific patch file you want to be reflected. Run quilt series to view the stack of files, then you’ll find where your file is being stacked. To know more about quilt commands check this out
7) Run quilt add "filename which you need to modify"
(If multiple files are there, then add all those)
eg: quilt add configure.ac README.txt
8) Make necessary modifications required for these files, note that these changes are being made in your vi editor.
9) After the changes are being made and you’re okay with the changes, in your source folder commit the changes.
10) Do # quilt refresh
11) Check if your modifications are reflected in the patch file.
vi patches/<name>.patch
12) Then replace this patch file with original one in files folder.
13) Exit, clean and build.
closing thoughts - I had initially modified an existing recipe using quilt but I realized that using devtool was much more easier, in subsequent blogs I will talk about other tools used in The Yocto Project.
Where are we now?...
About my Internship task –
add support for elfutils debuginfod to the Yocto Project.
I’ll try my best to explain this the best way I can.
Some introduction first – debuginfo files are notorious for taking up large amounts of space and the size of a debuginfo file could be 5 to 15 times that of the corresponding executable. And because bugs are inevitable, developers need quick and easy access to the artifacts that debuging tools like GDB and Systemtap depends on, but most times these resources are not readily available. Hence debuginfod a simple HTTP server that serves debuginfo to debugger-like tools. debuginfod from elfutils 0.178 onwards is a way to distribute debuginfo files, you can find more information here
So am being tasked to add support for elfutils debuginfod to Yocto this way
1) Enable debuginfod in elfutils. This should be a PACKAGECONFIG, and the build needs some extra dependencies (libmicrohttpd curl sqlite3 libarchive). Initially disabled by default.
2) Add support for ipkg to the debuginfod scanner. 0.178 only supports RPM but the next release (and git master) can also scan .debs, and as ipkgs are binary-compatible with dpkg then this is a trivial addition to the filename matching.
3) Verify that running debuginfod manually over $DEPLOY_DIR and setting DEBUGINFOD_URLS correctly works. Test case: debuginfod-find source hexcode /bin/bash.
4) Determine final integration. Straw man proposal: a class that turns on debuginfod for elfutils and sets DEBUGINFOD_URLS in the image, and a script that runs the elfutils-native debuginfod on DEPLOY_DIR.
To those who read this article to the end, I hope a thing or two was helpful to you here, and i am also extending my warmest hug and appreciation to you.