Being a First Year University Student During a Pandemic

This pandemic has majorly altered the way we all live (in ways I don’t even need to explain). But how are new university students coping with this big and drastic change? Moving to university is a…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Compile your own embedded Linux system

Learn how to build you own custom Linux embedded system from source using Yocto

In this article, you’ll get acquainted with the Yocto Project (YP): a powerful set of tools for creating and building completed Linux embedded systems. After a quick discussion on the tool itself, there’s a tutorial on how to use Yocto to build the Angstrom Distribution from source to run on a Raspberry Pi 3.

The best way to get what Yocto is is to understand the problem it is trying to solve. Generating Linux systems can be astronomically complex if you try to do it manually. You can always search online for a prepackaged distro and see if it fits your needs. If you’re working on embedded systems, it’s most likely that you will not find a suitable candidate.

Embedded systems are very specific and, usually, very resource-limited. Only the absolute necessary pieces of software need to be included; nothing more. Don`t forget to add a great deal of cross-compiling and toolchain manipulation in the mix. So, how can you build yourself a custom Linux system without having a bad time? Enter the Yocto Project!

Yocto is a comprehensive set of tools that helps you automate the building process of a complete Linux system from source. It cross-compiles the kernel, modules and apps; creates the rootfs; packages the image; and even prepares toolchains enabling you to develop software for your brand new system.

If your goal is to understand what’s really going on under the hood, YP can have a steep learning curve — not as steep as learning how to perform every single step manually. Yocto’s strength comes from its flexibility and automation capabilities. It works by running user-defined recipes that can be very simple — describing how to create a particular directory tree and populate them with random text files — or very complex — compiling the Linux kernel for the target architecture. These procedures can relate to one another by being components or dependancies. Begin chaining these recipes together and when you realize, you’ll have yourself a full-fledged Distro.

In a simplified example, let’s say you have an Allwinner based embedded computer and you need to run a nodejs app in it. You’ll probably stack the following layers:

After building the system, you’ll have a complete system compiled and prepared to boot on your Allwinner board with the exact software pieces you need to run your application.

The following example is a good way to start — a Yocto “Hello World” if you will.

Lets build the Angstrom Linux Distro for a Raspberry Pi 3. Angstrom is a very reduced Distro; it will pretty much get you a blinking cursor at the end. I mean it, the complete system takes no more than 58mb. Think of it as a good starting point for your custom system. There is really no need to start from nothing.

To exemplify Yocto’s capabilities, let’s make a single modification to the default system. We’ll use U-Boot as our bootloader and this will be done by changing a single line of code. Yocto will compile a different bootloader, install it and set up a completely different boot sequence with the addition of a single line. Our course the recipe for this process is longer than that but it is amazing how you can encapsulate complex processes this way.

Compiling a Linux system can be very resource-intensive. Be patient. Depending on the host system, the process can take many hours and use up to 50Gb of free disk space.

And run the following:

2. Now lets clone Yocto. At the time of writing, the latest version available of Yocto is code named thud; this will be the version used.

3. Clone the Angstrom Distro layer. Notice that all of the following branches are also thud related.

4. Clone the Raspberry Pi Layer. This is a Machine(BSP) Layer.

5. Finally clone the Qt 5 Layer. This software Layer is indirectly needed.

6. Open a terminal and initialize the build environment. This is needed whenever you open a new terminal to work with Yocto. In addition, it will perform a first time configuration and populate some files that we will change next.

7. Even though you’ve added 3 layers inside Yocto’s folder, you need to tell it explicitly to use them. This is done in the bblayers.conf file. I’ll also add a few other layers that come by default and will also be needed to build the system.

8. Now let set some global build configurations on local.conf.

9. That’s it. Let’s build the system.

bitbake is the primary tool for building recipes in Yocto. core-image-base is the image recipe that describes a basic system. From it, all other thousands of recipes are chained and executed. After the process is done. Check for the final image on following directories:

Note that the exact name of the image can differ depending on the version you’re building. Look for the file ended in .rpi-sdimg.

10. Flash the image and see the results! Use whatever method you prefer to transfer the image to the SD Card.

I hope after reading this piece you’ll be encouraged to try to build your own systems taking advantage of Yocto. It’s a good way to learn what are the building blocks of a Linux system. In the future we will explore more advanced concepts like how to cross-compile your apps to the target, how to flash custom Linux kernels and finally we’ll begin to build our own customized Linux Distro.

Meanwhile, happy coding!

Add a comment

Related posts:

Use Of Reddit Software To Brighten Up The Future Of Your Marketing

I admit that most of the businesses still unknown to the perk that Reddit marketing brings to them. But, this is not the truth, Reddit will be ruling over the advertising world after ten years. Those…

Our Engineering hiring process at Teads

Building a great interview process in software engineering is quite tricky, there is no magic playbook for that. In this article, we talk about our hiring process at Teads.

Sales season is on

You could call me a hipster…or maybe you could call me a yuppie. I believe I have trouble with fitting boxes, but maybe even this reinforces the paradigm I struggle with. I read (not that much), I…