Embedded Linux System Internals – Batch 2
Duration
5 days
Pre-requisites
Embedded programming in C or C++, Knowledgeable in Realtime operating systems
Hands-on hardware specifics
Boundary Systems Nitrogen 8M (IMX 8 based) boards
Linux software version
3.18 up to 4.4
Learning Objectives
• To understand the configuration and build procedures associated with the kernel, root file system and
device tree
• To understand the multistage boot initialization sequence of Arm based embedded Linux system
• To understand the management of Virtual address space resource in Linux kernel
• To understand the management of memory resource in Linux kernel
• To understand the interrupt handling, event handling and synchronization mechanisms in Linux
• To understand the Linux device and driver model and its visibility through sysfs
• To understand the Linux kernel sub system infrastructure that supports a program execution
• To understand the management of CPU resource in Linux kernel
• To understand the management of File System and File resources in Linux kernel
• To understand the use of /proc and /sys entries as diagnostic aids in Linux kernel and driver debugging
Course Outline
Day 1
1. Configuration and Build
Kernel Configuration
Root file systems
Jffs2
Cramfs
Initramfs
Device Tree
Device tree entries overview
Building device tree blob
2. Boot Initialization
Boot loader stages
U-boot
Kernel boot parameters
Linux kernel boot initialization
/sbin/init, init process and the scripts that are processed by init
Minor Exercise
1. Write a device tree entry for UART and build the device tree blob
Major Exercise:
1. Configure and build the kernel, root file system and device tree using build root and bring up Linux on the Nitrogen 8M board
Day 2 and 3
1. Virtual Address Space Management in Linux
Virtual address translation schema
Kernel virtual address space
Kernel address space mapping
Fixed mapping
Dynamic mapping
vmalloc
ioremap
kmap
Task virtual address space
2. Memory management in Linux
Physical memory allocation
Buddy allocation
__get_free_pages
Zones
GFP Masks
kmalloc
SLAB and SLUB allocations
kmem_cache_init
kmem_cache_create
kmem_cache_alloc
kmem_cache_free
kmem_cache_destroy
3. Event handling and synchronization in Linux
Interrupt generation at hardware level (GPIO programming)
Interrupt reporting (Interrupt controller configuration/programming)
Interrupt Capturing at kernel level
Interrupt handling mechanisms (Interrupt Bottom Half handling)
softirq
Tasklets
Worker threads
Threaded irq handling
Uevent and its delivery to user space through netlink socket
Kernel Synchronization
Use of Atomic updates and increments
Semaphores
Spinlocks
Minor Exercises:
1. Write a kernel module that would generate a pseudo kernel space event which gets delivered to the user space udev process.
2. Write appropriate udev rules to handle such an event to load a pseudo driver module.
3. Write a pseudo driver module that registers an interrupt handler function and allocates buffer for data transfer
4. Write an interrupt handler function that organizes a bottom half handling through any one of the bottom half handling mechanisms.
5. Write a pseudo bottom half handler function that does buffer handling
4. Devices and their drivers in Linux
The Linux Device Model
Platform devices
Bus devices
Linux Driver Model
Device Registration
struct device and its role in kernel space device registration.
Driver Registration
Device Probe function
Sysfs entries
Device registration in devtmpfs file system mounted on /dev
Major Exercise:
1. Make suitable entries in device tree for the UART device in the Nitrogen 8M board, write a simple
UART driver, build it as a kernel module and also as a built-in driver. Test the diver functionality
through a test application.
Day 4 and 5
1. Program Execution in Linux
struct vm_area_struct
struct page
struct mm_struct
page tables
2. CPU management in Linux
Scheduling Framework in Linux
SCHED_FIFO
SCHED_RR
SCHED_OTHER
CFS
Multicore per-cpu resources in the kernel
cgroup and its use
3. File System and File management in Linux
Virtual File System
Page cache
File System views
/proc
/sys
/devtmpfs
/tmpfs
4. Debugging
Kernel data structure state published through /proc
Device and driver data structure state published through /sys
Minor Exercise:
1. Write a kernel module that does a page table walk for a specific process and dumps the physical page base addresses mapped to the Virtual Frame Numbers.
2. Create cgroup entries and study its effect
3. Study of /proc entries
4. Study of /sys entries