Joint ICTP-IAEA School on
Zynq-7000 SoC and its
Applications for Nuclear
and Related Instrumentation
Introduction to Embedded Linux
Fernando Rincón
fernando.rincon@uclm.es
Smr3143 – ICTP & IAEA (Aug. & Sept. 2017)
Contents
● Embedded OS
● Embedded Linux
● Linux Architecture
Introduction to Petalinux Smr3143 – ICTP & IAEA (Aug. & Sept. 2017) 2
Embedded OS
● Embedded systems usually perform very simple tasks
– Monitor status of sensors
– React to events following simple rules
● Move motors
● Activate relays
● Send data
● …
● Complex applications may have more requirements
– Concurrent execution
– Real-time management
– Resource multiplexion
– Advanced communication mechanisms
● Purpose of the OS → Release the user from those complex tasks
Introduction to Petalinux Smr3143 – ICTP & IAEA (Aug. & Sept. 2017) 3
Desktop vs Embedded
● Main diferences
– Small footprint, and tailored to the specifc need
– Custom peripheral drivers.
– Less protection mechanisms
● Even no Memory management Unit (MMU)
– Real-time
– Lack of very simplistic user-interface
– Sometimes no network connection
● Although the trend is to have everything connected
Introduction to Petalinux Smr3143 – ICTP & IAEA (Aug. & Sept. 2017) 4
Embedded OS Development
● Cross-development
– Host machine: develoment enviroment and tools
● Cross-compiler
– Diferent versions for bare-metal and OS development
● Mostly because of the linked libraries
● Ex: arm-none- vs arm-xilinx-linux
● Target root flesystem & basic libraries for compilation purposes
– Target machine:
● Bootloader
● Kernel
● Root flesystem
● Cross-platform design cycle
– Compile → test → debug
– Use of emulators
● Bootstrap process:
– Flash
– Network
– ...
Introduction to Petalinux Smr3143 – ICTP & IAEA (Aug. & Sept. 2017) 5
Why Linux?
● Low cost of ownership
● Open-source, full control and customizability
● Rich feature set
● Quality of Linux components
● Re-use of Linux components
● Big active developer community & resources
● Pool of talented embedded Linux developers
● Scalability, from embedded to the cluster
● Standard tools and run-time environment
Introduction to Petalinux Smr3143 – ICTP & IAEA (Aug. & Sept. 2017) 6
What does Linux Ofer?
● Multiple processor achitectures supported
– ARM, MIPS, PowerPC, x84, amd64, Microblaze, …
● Reduced foot print (a few MB) and fast booting times (~4 s)
● Networking:
– full support for TCP/IP, Wif, Bluetooth, USB, …
● Graphics:
– X, Frame Bufer & DRM/KMS.
– Graphical development libraries QT, Gnome, …
● Multimedia:
– Video4Linux & Gstreamer, FFMPeg, OpenCV, …
Introduction to Petalinux Smr3143 – ICTP & IAEA (Aug. & Sept. 2017) 7
What Does Linux Ofer?
● Interoperability and OS infrastructure
– Networking, fle systems, device support
– Scheduling, processes/threads, interrupt handling, interprocess
communication, symmetric multiprocessing (SMP)
● Developer familiarity
– Standard tools
– Standard run-time environment
– Application code can be prototyped on the desktop
● Scalability
– Deeply embedded → single board computers → desktop → server → cluster
● Freedom and openness
– Accessibility to modify source code
Introduction to Petalinux Smr3143 – ICTP & IAEA (Aug. & Sept. 2017) 8
Linux Components
Tools
Root File
Application Utilities User Applications
Linux Build & Development
system
GNU Cross-Compiler tool
(rootfs)
chain & Debugger
Libraries – Graphics, Video, Networking, etc.
Tool
Kernel
Linux Kernel Device Drivers Image
U-boot
Boot
Loader
First Stage Boot Loader
Hardware QEMU
Linux Build tools: PetaLinux,
Yocto, OpenEmbedded, buildroot
Other tool chains: Linaro, GCC
Board Support Package (BSP): Collection of SoC/board specific Linux
mainline
components that include Linux kernel & device drivers, boot loader and tools
Introduction to Petalinux Smr3143 – ICTP & IAEA (Aug. & Sept. 2017) 9
Anatomy of a Linux System
● User applications
– Task specifc
– Libraries
– C run time, networking,
– graphics, for example
● Kernel
– More on this soon
● Hardware
– CPU, memory
– Timer, interrupt controller, I/O
Introduction to Petalinux Smr3143 – ICTP & IAEA (Aug. & Sept. 2017) 10
Linux Kernel Architecture Overview
● System call interface (SCI)
– Function calls from user space to
kernel
● Process management
– Processes or threads
– Share the CPU between the active
threads
● Memory management
– Manages the virtual and physical
memory
● Virtual fle system
– Switching layer between the SCI
and the fle systems supported by
Linux
Introduction to Petalinux Smr3143 – ICTP & IAEA (Aug. & Sept. 2017) 11
Linux Kernel Architecture Overview
● Network stack
– Above TCP, socket layer
– Invoked through the SCI
● Device drivers
– Supports most of the common
devices
● Architecture-dependent code
(BSP)
– Processor and platform-specifc
code
Introduction to Petalinux Smr3143 – ICTP & IAEA (Aug. & Sept. 2017) 12
System Call Interface
● Contract between user space and kernel space
– Request services
– Memory, I/O
– Process management
● The standard C library is a wrapper around the system call interface
– For example, malloc() is a C library call
● Maintains a pool of memory
● Calls kernel memory allocator only when that pool is exhausted
Introduction to Petalinux Smr3143 – ICTP & IAEA (Aug. & Sept. 2017) 13
Virtual Memory
Introduction to Petalinux Smr3143 – ICTP & IAEA (Aug. & Sept. 2017) 14
Linux distributions
Introduction to Petalinux Smr3143 – ICTP & IAEA (Aug. & Sept. 2017) 15