Embedded Linux


Core components of an embedded Linux system are boot loader, custom Linux kernel and root file system. Source code is compiled by GCC cross compiler. Common boot loader is Das U-Boot – the Universal Boot Loader. Root FS usually is based on BusyBox – software suite that provides many Unix utilities in a single executable file. Local debugging often is limited, so gdbserver can be used.

Basic embedded Linux system can be compiled manually from modules above. There are tools for complete system generation from old and simple Buildroot to huge Yocto Project, which creates customized embedded Linux distributions. PC distributions Debian, Ubuntu ant others have build for ARM processors.

Raspberry Pi, BeagleBoard and Nvidia Jetson are examples of popular single-board computers supporting embedded Linux.

Unlike regular desktop or server distributions of Linux these versions of Linux usually have much fewer libraries and application, firmware is smaller and typically boot from flash memory or SD card.


ProjectsEdit

Build frameworks and environmentsEdit

Wear OS – Android for smartwatches and other wearables.
AOSP – Android Open Source Project
Buildroot – old simple patch and make based build environment
Yocto Project and OpenEmbedded – a BitBake based build framework and environment
BitBake – make-like build tool
OpenWrt – open wireless router
Embeddable Linux Kernel Subset – for ancient 16-bit x86 machines and emulators


ComponentsEdit

The Linux Kernel
"init" implementations: OpenRC, runit
GUIs: LXQt, LXDE, Xfce, FLTK
coreboot – lightweight BIOS


C standard library variantsEdit

General purpose GNU C Library glibc, 7.9 MB
uClibc, 560 KB
musl, 527 KB
dietlibc, 185 KB
Newlib
klibc – primarily for booting Linux systems
Bionic – originally developed by Google for the Android embedded system operating system


Further reading:

Comparison of C/POSIX standard library implementations for Linux
Choosing System C library

DistributionsEdit

Distributions for ARM processors:

Arch Linux ARM – port of Arch Linux for ARM processors
ArmbianDebian and Ubuntu based
RedSleeve – port of Red Hat Enterprise Linux
emteria.OS – proprietary Android based


Lightweight multi-platform distributions:

Alpine Linux
Gentoo Linux
Tiny Core Linux
Kali Linux
Lubuntu
Slackware
Void Linux
Xubuntu


Common multi-platform distributions:

Debian
Fedora
openSUSE
Ubuntu


Features of Linux kernel for embedded systemsEdit

I/O and buses:
GPIO
drivers/gpio src, tools/gpio src, General Purpose Input/Output doc
SPI
drivers/spi src, tools/spi src, Serial Peripheral Interface doc
I2C
⚲ UAPI: Instantiate I2C devices from user-space doc
drivers/i2c src, https://i2c.wiki.kernel.org
I2C/SMBus Subsystem doc
drivers/net/can srcController Area Network bus
drivers/mfd srcMulti-Function Devices
drivers/usb/gadget src – peripheral USB device implementation
drivers/iio src – Industrial I/O
drivers/pwm srcPulse-width modulation
drivers/regulator src – Generic Voltage and Current Regulator support
drivers/fpga src
drivers/slimbus src
SLOB – Simple List Of Blocks memory allocator
Devicetree – describes hardware components for the kernel


MultimediaEdit

Audio
ASoC – ALSA System on Chip
snd_soc_card id
ASoC – ALSA SoC Layer doc
https://www.alsa-project.org/wiki/ASoC
TFT (LCD) – Thin-film-transistor liquid-crystal display
fbtft_display id


File systems and storageEdit

UBIFS – Unsorted Block Image FS
SquashFS – a compressed read-only FS with low overhead
drivers/mtd srcMemory Technology Device block device
More: YAFFS, JFFS2


MMU lessEdit

Linux was originally designed on a processor with a memory management unit (MMU). Most embedded systems do not have a MMU, as we discussed earlier (Embedded Systems/Memory) and are called microcontrollers. Microcontrollers without a MMU are cheaper consumes less power.


Benefits of using a processor with a MMU:

can isolate running "untrusted" machine code from running "critical" code, so the "untrusted" code is guaranteed (in the absence of hardware failures) not to interfere with the "critical" code
makes it easier for the OS to present the illusion of virtual memory
can run "normal" Linux (could also run "μClinux", but what's the point?)


μClinux – "MicroController Linux" is a version of the Linux kernel that supports Altera NIOS, ARM, Freescale M68K (including DragonBall, ColdFire, PowerQUICC and others), Hitachi H8, MIPS, and Xilinx MicroBlaze processors.

Disabling parameter CONFIG_MMU enables nommu mode.


Real-timeEdit

People use a variety of methods to combine real-time tasks with Linux:

Run the real-time tasks on a dedicated microcontroller; communicate with a (non-real-time) PC that handles non-real-time tasks. This is pretty much your only choice if you need real-time response times below 1 microsecond.
Run the real-time tasks in a "underlying" dedicated real-time operating system; run Linux as a "nested operating system" inside one low-priority task on top of the real-time operating system. Some of these systems claim real-time response times below 500 microseconds.
use a Linux kernel designed to emphasize real-time tasks, and run the real-time tasks with a high priority (perhaps even as a kernel thread).


Parameter CONFIG_PREEMPT_RT enables real-time preemption.


SCHED_DEADLINE – scheduling policy for RT.


Examples of RT distributions:

Xenomai
RTAI
RTLinux
MontaVista Linux
Red Hat Enterprise Linux for Real Time


Further reading:

the Real-Time Linux wiki
RT-Tests
https://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-stable-rt.git
https://www.kernel.org/pub/linux/kernel/projects/rt/


Further readings about Embedded Linux:

https://elinux.org
Category:Linux-based_devices
Linux kernel interfaces
ARM support
arch/arm src, ARM Architecture doc
https://lwn.net/Kernel/Index/#Architectures-ARM
arch/arm64 src, ARM64 Architecture doc
architecture-specific initialization
Learning the vi Editor