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.