Working on U-boot from Yocto (iMX8)
I have been asked a couple of times how to quickly make changes for U-Boot in Yocto. Those who asked have used to rebuild and flash an entire image each time, which takes an unnecessarily which is not a fast procedure.
To rebuild U-Boot is`nt significantly different from any other recipe, but one difference is that imx-mkimage must also be built to generate a bootable image.
I wrote this post because it is just easier for me to write it down and refer rather than keep repeat myself :-)
So, this is my workflow when working with U-boot for iMX8 in an Yocto environment.
Tools I use
bitbake
All working with Yocto will somehow use bitbake. No further explanation.
devtool
devtool [1] is a command line tool that provides a number of features that help you build, test and package software. It is incredible useful when working with Yocto and making changes to the software. It will let you work with the software, make changes, commit and then smoothly create patches and include them into the recipe.
kas
kas [2] is my absolute favorite tool to administrate and setup bitbake based projects.
I always use kas-container which is part of the projects. kas-container does the very same thing as kas but execute every command in a container. This is useful if you, for example, using a rolling distribution (Archlinux in my case) where the tools is not always compatible with the latest software on your system.
The following steps will assume that you use kas-container, but can easely be adapted to whatever you use.
The workflow
Start a development shell in the container:
1kas-container shell ./my-kas-file.yml
Use devtool to create a workspace for the u-boot-imx repository:
1devtool modify u-boot-imx
2cd /build/workspace/sources/u-boot-imx
You will find the workspace in /build/workspace/sources/u-boot-imx.
Now you can make changes to the source code as you like and even commit your changes.
1#make changes to the repository
2git commit -a --signoff -m "my cool changes"
Usually you just run devtool build <package> and eventually devtool deploy <package> to test it on target. However, this does not work for u-boot (for at least iMX8) as the output needs to be run though the ìmx-mkimage tool before is is usable.
Also, devtool build-image does not work either as it will only include the newly built u-boot into the image without run it through imx-mkimage.
So, what we have to do is generate patches and add them into the recipe. devtool will help us with that:.
1devtool update-recipe u-boot-imx -a /work/layers/meta-custom
-a /work/layers/meta-custom, tells devtool to update that specific layer, otherwise it will update meta-freescale, and that is something we want to avoid.
kas-container maps the working directory to /work/, you will probably find your layers there.
The last thing we need to do is to build the imx-boot target that is provided by the imx-mkimage recipe. imx-boot will also rebuild u-boot-imx with our patches applied.
To do this we use bitbake:
1bitbake imx-boot
That is all.
The generate imx-boot image you find in build/tmp/deploy/images/<machine>/imx-boot is ready to be flashed to your hardware using the uuu [5] tool.
Summary
Working with U-boot is not more complicated to work on than anything else, but you should be aware of that you cannot use devtool as usual as the image u-boot-imx produce is not the final product that can be flashed to the hardware.
Also, there is no good ways to invoke the complete build chain with only devtool, so bitbake has to be used for that.