In Episode 41, Hacking the Linux Kernel, Part 2, I successfully hacked the Linux kernel, both on a native Linux partition, and within a Ubuntu VM on VirtualBox, by using the general directions within the Linux Newbies First Kernel Patch tutorial. This week, I worked towards hacking the Linux kernel using a Yocto-based qemux86 on VirtualBox, as a final step towards actually hacking the kernel on my MinnowBoard.
But first, a segue: I spent some cycles learning more about the GitHub, because I’ve been using git extensively by rote, without fully understanding the power of this utility. GitHub is a code hosting platform for version control and collaboration, and it lets you and others work together on projects from anywhere. Yocto uses git extensively, and it’s important to understand the terms and concepts, such as repositories, branches, commits, and Pull Requests. As soon as I had created a userid and logged in, I created a Git Project using the Hello World tutorial:
Note that this is only typing in a bit of text. It’s not even covering creating code, as I am doing in the background with the classic “HelloWorld.c” using Visual Studio 2017:
That’s a topic for a future blog, perhaps!
I also took a second segue in my explorations, to explore how the MinnowBoard could boot from a large image. The collateral I had read on the MinnowBoard tutorials pages (both Installing Yocto 2.4.1 and the Yocto Project Quick Start Guide) indicated that you should use a FAT32-formatted USB stick to boot the Minnow from, and create the USB bootable image via the “dd” command, as in:
sudo dd if=tmp/deploy/images/intel-corei7-64/core-image-base-intel-corei7-64.wic of=TARGET_DEVICE
That works for smaller images, as generated for example by “bitbake core-image-minimal”. But, larger images, such as those generated by “bitbake core-image-sato-sdk”, are more than 4GB in size. And FAT32 is limited to a 4GB maximum file size. When you try to use “dd” to create a boot USB stick with large image size, it seems to work, but then you try to boot, you get only partway, and it hangs:
What to do?
Well, as it turns out, some of the copy utilities will allow the use of FAT32 for the EFI boot partition, and a separate NTFS partition for the rest of the image. In the past, I had created such images (unknowingly) using Rufus on my Windows PC. In this case, since I built the image using Linux, I used the application balena Etcher to create such a USB bootable image. It worked like a charm, and I was able to boot all the way into core-image-sato-sdk.
But, I’ll come back to this when I start playing with the SDK, using GDB, etc. For now, I’ll continue to use the smaller core-image-minimal, which is a superset of the following:
This minimal recipe provides an image with the least number of packages to be a bootable image for a given platform (MACHINE) from a stock Yocto Project distribution. It is not necessarily the smallest image that can be created, as many size reductions can be made with kernel changes, etc. But, when first starting a project, this is the fastest complete build, and it is also a good place to start to create a custom image. So, that will also enable the “dd” command to suffice for now.
So, onwards! Let’s hack the kernel with qemux86, and then move to the MinnowBoard.
There are two options for hacking:
- Using Traditional Kernel Development to Patch the Kernel
- Using devtool to Patch the Kernel
I’ll roll the dice and guess which one is easier. Stay tuned for the next episode!