Tutorial: How to Build and Run an Embedded Linux System for/on a Raspberry Pi Model B+

3 minute read

Introduction

According to the book “Mastering Embedded Linux Programming” [1] there are four things you need to build an embedded Linux system. They are:

  1. a (cross) toolchain
  2. a bootloader
  3. a kernel
  4. a root file system

Back in 2023 I started a series of post on how to build such an embeeded Linux system for and run it on a Raspberry Pi 3 Model B+. This was supposed to become a little tutorial. Unfortunately, I somehow didn’t find the time to finish it until now. But now it finally consist of seven post (excluding this one) that explain all necessary steps:

In case you are wondering why that specific Raspberry Pi model? Well, I just happen to have one of them lying around 😊.

What You Need to Follow Along

  • A Raspberry Pi 3 Model B+
  • A SD card
  • A way to communicate with the UART (serial) interface of the Raspberry Pi
  • A development system on which everything is built.

Ideally development system is a computer that runs Linux. I used an Arch Linux system. I haven’t tried to go through the process on any other computer. I have to admit I don’t exactly know which packages have to be installed on the system, as my installation had pretty much all that was needed already installed. Maybe I’ll find the time to check that in the future. One thing that is essential though, you need to be able to run commands using sudo.

A long explanation on how to communicate with the UART of the Raspberry Pi is out of the scope of this tutorial. In short:

You need to connect three of the GPIO pins (GND, UART_TXD0, and UART_RXD0) of the Raspberry Pi to some UART to USB cable/board and connect that cable/board to one of the USB ports of your development computer. On your computer you need a program to display the serial communication. To find out which pins of the Raspberry Pi to use, have a look in the article Raspberry Pi UART Communication using Python and C [2]. One such UART to USB cable is the USB-RS232-WE-5000-BT_3.3 - FDTI [3] by FDTI. For possible programs to display the serial communication, I recommand to have a look into the article Working with the serial console [4] in the Arch Wiki.

Project Setup

Within the tutorial, I will refere to the host system a couple of times. This is the development computer. I also refere to the <project/root/dir> directory multiple times. This is some directory on your host system that should be empty at the beginning. It could be some directory in your home directory (e.g. /home/<your-username>/embedded_linux_tutorial/). So whenever you see <project/root/dir> somewhere in a command, make sure you replace it with the correct path to the project root directory on your machine.

Before we actually get started, we need to prepare the SD card. An in depth explanation on how to prepare the SD card can be found in the article “Boot a Raspberry Pi 4 using u-boot and Initramfs” [5] by Hechao. Please follow the instruction in that article. Afterwards you should have an SD card with two partions on it. One with a FAT32 and one with an ext4 file system on it.

Well, let’s get started with the actual tutorial and build a toolchain.



Take care,
Andreas


References

  1. F. Vasquez and C. Simmonds, Mastering Embedded Linux Programming, 3rd ed. Packt Publishing Ltd., 2021.
  2. ElectronicWings, “Raspberry Pi UART Communication using Python and C.” [Online]. Available at: https://www.electronicwings.com/raspberry-pi/raspberry-pi-uart-communication-using-python-and-c. [Accessed: 02-Nov-2023].
  3. FDTI Chip, “USB-RS232-WE-5000-BT_3.3 - FDTI.” [Online]. Available at: https://ftdichip.com/products/usb-rs232-we-5000-bt_3-3/. [Accessed: 02-Nov-2023].
  4. ArchWiki, “Working with the serial console,” 25-Jul-2023. [Online]. Available at: https://wiki.archlinux.org/title/working_with_the_serial_console. [Accessed: 02-Nov-2023].
  5. Hechao, “Boot a Raspberry Pi 4 using u-boot and Initramfs,” 20-Dec-2020. [Online]. Available at: https://hechao.li/posts/Boot-Raspberry-Pi-4-Using-uboot-and-Initramfs/. [Accessed: 31-Jan-2025].

Updated:

Leave a comment