DEV Community

Can Gulmez
Can Gulmez

Posted on

Embedded Linux Development - 1

In today, I'm beginning a new series about embedded Linux development. I'll show that how to build an end-to-end embedded Linux system from scratch by hand.

I'll fetch the associated every stuffs from source code and then build the corresponding outputs.

I will target the BeagleBone Black Rev C board. I will compile the everything for that board. So you need the following things for this series:

  • BeagleBone Black Rev C

  • USB Mini-B to USB-A cable

  • FTDI FT232R converter

Overall, embedded Linux development consists of four components:

  • Toolchain

  • Bootloader

  • Linux kernel

  • Rootfs

In this post, I will explain the toolchain that I need for all development sequence.

The toolchain is the first element of embedded Linux and the starting point of the project.

A toolchain is the set of tools that compiles source code into executables that can run on your target device, and includes many binaries for the different purposes. Usually, toolchains for Linux are based on components from the GNU project. A standard GNU toolchain consists of three main components:

  • Binutils is a set of tools to generate and manipulate binaries for a given architecture. Common binaries: as, ld, ar, randlib, objdump, readelf, size, nm, strings, strip, etc.

  • GCC is the main compiler.

  • C library is used to interract with the kernel. The programming interface to the UNIX operating system is defined in the C language, which is defined by the POSIX standards. The C library is the implementation of the interface.

In here, there are two types of toolchain:

  • Native: This toolchain runs on the same type of system.

  • Cross: This toolchain run on a different type of system than the target.

Almost all embedded Linux development is done using a cross development toolchain. Because doing embedded development, there is always a split between:

  • The host, the development workstation

  • The target, which is the embedded system

They are connected by various means: almost always a serial line for debugging purposes, frequently a network connection, sometimes a JTAG interface for low-level stuffs.

Many UNIX/Linux toolchains rely on architecture tuple names to identify machines. You probably compiled many programs on your host already and used the gcc command. But it's actually a shorthand. You can exactly see it with:

$ gcc -dumpmachine
x86_64-linux-gnu
Enter fullscreen mode Exit fullscreen mode

Other examples: arm-linux-gnueabihf, mips64el-linux-gnu, arm-none-eabi- etc.

These tuples are 3 or 4 parts:

  • The architecture name: arm, riscv, mips64el, etc.

  • Optionally, a vendor name, which is free-form string.

  • An operating system name, or none when not targeting an operating system.

Of course, these are the pre-built toolchains. If you want, you can also create your own toolchain with crosstool-ng. It's another post topic. But shortly, when building a toolchain, the ABI used to generate binaries needs to be defined. ABI, Application Binary Interface, defines the calling conventions (how function arguments are passed, how the return value is passed, how system calls are made or so on) and the organization of structures. All binaries in a system are typically compiled with the same ABI, and the kernel must understand this ABI.

Anyway, I gave you the enough theoretical toolchain background. Let's go with our concern.

Which toolchain should be used for BeagleBone Black?

You have to know the used ARM processor in here. BeageBone Black has AM335x Sitara processor which is based on ARM-A8 (ARMv7), 32-bit architecture. So the toolchain for that is the gcc-arm-linux-gnueabihf.

The first thing in implementing embedded Linux is to install it.

$ sudo apt install gcc-arm-linux-gnueabihf
Enter fullscreen mode Exit fullscreen mode

After that validate it.

$ arm-linux-gnueabihf-gcc --version
arm-linux-gnueabihf-gcc (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Enter fullscreen mode Exit fullscreen mode

That's it. You have the required toolchain and ready to go with the bootloader.

Resources:

Simmonds C., Mastering Embedded Linux Programming, Packt Publishing, 2015
Embedded Linux system development training, Bootlin, 2024

Top comments (0)