Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Mastering Embedded Linux Development

You're reading from   Mastering Embedded Linux Development Craft fast and reliable embedded solutions with Linux 6.6 and The Yocto Project 5.0 (Scarthgap)

Arrow left icon
Product type Paperback
Published in May 2025
Publisher Packt
ISBN-13 9781803232591
Length 710 pages
Edition 4th Edition
Tools
Arrow right icon
Authors (2):
Arrow left icon
Frank Vasquez Frank Vasquez
Author Profile Icon Frank Vasquez
Frank Vasquez
Chris Simmonds Chris Simmonds
Author Profile Icon Chris Simmonds
Chris Simmonds
Arrow right icon
View More author details
Toc

Table of Contents (28) Chapters Close

Preface 1. Part 1: Elements of Embedded Linux
2. Starting Out FREE CHAPTER 3. Learning about Toolchains 4. All about Bootloaders 5. Configuring and Building the Kernel 6. Building a Root Filesystem 7. Part 2: Building Embedded Linux Images
8. Selecting a Build System 9. Developing with Yocto 10. Yocto under the Hood 11. Part 3: System Architecture and Design Decisions
12. Creating a Storage Strategy 13. Updating Software in the Field 14. Interfacing with Device Drivers 15. Prototyping with Add-On Boards 16. Starting Up – The init Program 17. Managing Power 18. Part 4: Developing Applications
19. Packaging Python 20. Deploying Container Images 21. Learning about Processes and Threads 22. Managing Memory 23. Part 5: Debugging and Optimizing Performance
24. Debugging with GDB 25. Profiling and Tracing 26. Real-Time Programming 27. Index

Obtaining the hardware for this book

The examples in this book are intended to be generic. To make them relevant and easy to follow I have had to choose specific hardware. I have chosen three exemplary devices: the Raspberry Pi 4, BeaglePlay, and QEMU. The first is by far the most popular Arm-based SBC on the market. The second is a widely available SBC that can also be used in serious embedded hardware. The third is a machine emulator that can be used to create a range of systems that are typical of embedded hardware.

It was tempting to use QEMU exclusively, but like all emulations, it is not quite the same as the real thing. Using the Raspberry Pi 4 and BeaglePlay, you have the satisfaction of interacting with real hardware and seeing real LEDs flash. The BeaglePlay, like the BeagleBone Black before it, is open source hardware, unlike the Raspberry Pi 4. This means that the board design materials are freely available for anyone to build the BeaglePlay or a derivative into their products.

In any case, I encourage you to try out as many of the examples as you can, using either of these three platforms or any embedded hardware you may have on hand.

The Raspberry Pi 4

From June 2019 until October 2023, the Raspberry Pi 4 Model B was the flagship SBC produced by the Raspberry Pi Foundation. The Raspberry Pi 4’s technical specs include the following:

  • A Broadcom BCM2711 1.5 GHz quad-core Cortex-A72 (Arm v8) 64-bit SoC
  • 2, 4, or 8 GB DDR4 RAM
  • 2.4 GHz and 5 GHz 802.11ac wireless, Bluetooth 5.0, BLE
  • A serial port for debugging and development
  • A microSD slot, which can be used as a boot device
  • A USB-C connector to power the board
  • Two full-size USB 3.0 and two full-size USB 2.0 host ports
  • A Gigabit Ethernet port
  • Two micro HDMI ports for video and audio output

In addition, there is a 40-pin expansion header for which there are a great variety of daughter boards known as Hardware Attached on Top (HATs) that allow you to adapt the board to do many different things. However, you will not need any HATs for the examples in this book.

In addition to the board itself you will require the following:

  • A microSD card and a means of writing to it from your development PC or laptop
  • A USB-to-TTL serial cable with a 3.3 V logic level
  • A 5 V USB-C power supply capable of delivering 3 A
  • An Ethernet cable and a router to plug it into as some of the examples require network connectivity

The BeaglePlay

The BeaglePlay is an open source hardware design for an SBC produced by the BeagleBoard.org Foundation. The main points of the specification are:

  • A TI AM6254 1.4 GHz Arm quad-core Cortex-A53 (Arm v8) 64-bit Sitara SoC
  • 2 GB DDR4 RAM
  • 16 GB eMMC on-board flash
  • 2.4 GHz and 5 GHz MIMO Wi-Fi, BLE, Zigbee
  • A serial port for debugging and development
  • A microSD slot, which can be used as a boot device
  • A USB-C connector to power the board
  • A full-size USB 2.0 host port
  • A Gigabit Ethernet port
  • A full-size HDMI port for video and audio output

Instead of a large expansion header, the BeaglePlay has mikroBUS, Grove, and Qwiic interfaces for connecting add-on boards.

In addition to the board itself, you will require the following:

  • A microSD card and a means of writing to it from your development PC or laptop
  • A USB-to-TTL serial cable with a 3.3 V logic level
  • A 5 V USB-C power supply capable of delivering 3 A
  • An Ethernet cable and a router to plug it into as some of the examples require network connectivity

In addition to the above, Chapter 12 also requires the following:

  • A MikroE-5764 GNSS 7 Click add-on board
  • An external active GNSS antenna with an SMA connector
  • A MikroE-5546 Environment Click add-on board
  • A MikroE-5545 OLED C Click add-on board

QEMU

QEMU is a machine emulator. It comes in different flavors, each of which can emulate a processor architecture and various boards built using that architecture. For example, we have the following:

  • qemu-system-arm: 32-bit Arm
  • qemu-system-aarch64: 64-bit Arm
  • qemu-system-mips: MIPS
  • qemu-system-ppc: Power PC
  • qemu-system-x86: x86 and x86-64

For each architecture, QEMU emulates a range of hardware that you can see by using the -machine help option. Each architecture emulates most of the hardware that would normally be found on that board. There are options to link hardware to local resources, such as using a local file for the emulated disk drive. Here is a concrete example:

$ qemu-system-arm -machine vexpress-a9 -m 256M -drive file=rootfs.ext4,sd -net nic -net use -kernel zImage -dtb vexpress-v2p-ca9.dtb -append "console=ttyAMA0,115200 root=/dev/mmcblk0" -serial stdio -net nic,model=lan9118 -net tap,ifname=tap0

IMPORTANT NOTE

The preceding command is not meant to be executed and will fail since qemu-system-arm is not installed and the rootfs.ext4.sd, zImage, and vexpress-v2p-ca9.dtb files do not exist on your host system. It is just an example for us to expand on.

The options used in the preceding command line are as follows:

  • -machine vexpress -a9: Creates an emulation of an Arm Versatile Express development board with a Cortex-A9 processor.
  • -m 256M: Populates it with 256 MB of RAM.
  • -drive file=rootfs.ext4,sd: Connects the SD interface to the local rootfs.ext4 file, which contains a filesystem image.
  • -kernel zImage: Loads the Linux kernel from the local file named zImage.
  • -dtb vexpress-v2p-ca9.dtb: Loads the device tree from the local vexpress-v2p-ca9.dtb file.
  • -append "…": Appends the string in quotes as the kernel command line.
  • -serial stdio: Connects the serial port to the terminal that launched QEMU so that you can log on to the emulated machine via the serial console.
  • -net nic,model=lan9118: Creates a network interface.
  • -net tap,ifname=tap0: Connects the network interface to the virtual network interface tap0.

To configure the host side of the network you need the tunctl command from the User Mode Linux (UML) project. On Debian and Ubuntu, the package is named uml-utilities:

$ sudo tunctl -u $(whoami) -t tap0

This creates a network interface named tap0 that is connected to the network controller in the emulated QEMU machine. You configure tap0 the same way as any other network interface.

All these options are described in the following chapters. I will be using Versatile Express for most of my examples, but it should be easy to use a different machine or architecture.

You have been reading a chapter from
Mastering Embedded Linux Development - Fourth Edition
Published in: May 2025
Publisher: Packt
ISBN-13: 9781803232591
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Visually different images