Training > IoT & Embedded Development > Developing Embedded Linux Device Drivers (LFD435)
INSTRUCTOR-LED COURSE

Developing Embedded Linux Device Drivers (LFD435)

This instructor-led course is designed to show experienced programmers how to develop device drivers for embedded Linux systems, and give them a basic understanding and familiarity with the Linux kernel. Hands-on labs with a RISC-V based emulated development target allow students to practice what is learned in class.

Who Is It For

This course is for experienced developers who need to develop device drivers for embedded Linux systems.
read less read more
What You’ll Learn

Upon mastering this material, you will be familiar with the different kinds of device drivers used under Linux, and have an introduction to many of the appropriate APIs to be used when writing a device driver. The labs for illustrating these concepts will all be performed on ARM hardware in order to get developers familiar with cross-compiling and developing drivers for an embedded target.
read less read more
What It Prepares You For

This course will prepare you to develop device drivers for embedded Linux systems.
read less read more
Course Outline
Expand All
Collapse All
Introduction
- Objectives
- Who You Are
- The Linux Foundation
- Copyright and No Confidential Information
- Linux Foundation Training
- Certification Programs and Digital Badging
- Linux Distributions
- Preparing Your System
- Things change in Linux
- Documentation and Links
Preliminaries
- Procedures
- Kernel Versions
- Kernel Sources and Use of git
- Hardware
- Staging Tree
- Labs
How to Work in OSS Projects **
- Overview on How to Contribute Properly
- Know Where the Code is Coming From: DCO and CLA
- Stay Close to Mainline for Security and Quality
- Study and Understand the Project DNA
- Figure Out What Itch You Want to Scratch
- Identify Maintainers and Their Work Flows and Methods
- Get Early Input and Work in the Open
- Contribute Incremental Bits, Not Large Code Dumps
- Leave Your Ego at the Door: Don’t Be Thin-Skinned
- Be Patient, Develop Long Term Relationships, Be Helpful
Cross-Development Toolchain
- The Compiler Triplet
- Built-in Linux Distribution Cross Compiler
- Linaro
- CodeSourcery
- crosstool-ng
- Buildroot
- OpenEmbedded
- Yocto Project
- Labs
QEMU
- What is QEMU?
- Why use QEMU?
- Emulated Architectures
- Image Formats
- Labs
Booting a Target Development Board from uSD
- Why do we use uSD cards?
- Getting SW onto a uSD card
- Booting from flash
- Why is using uSD cards a bad idea?
- Labs
Booting a Target Development Board over Ethernet
- Using virtual Hardware
- An easier way to develop
- The Boot Sequence using TFTP and NFSroot
- Objectives of the Lab
- Labs
Kernel Configuration, Compilation, Booting
- Configuring the Kernel for the Development Board
- Labs
Device Drivers
- Types of Devices
- Mechanism vs. Policy
- Avoiding Binary Blobs
- Power Management
- How Applications Use Device Drivers
- Walking Through a System Call Accessing a Device
- Error Numbers
- printk()
- devres: Managed Device Resources
- Labs
Modules and Device Drivers
- The module driver() Macros
- Modules and Hot Plug
- Labs
Memory Management and Allocation
- Virtual and Physical Memory
- Memory Zones
- Page Tables
- kmalloc()
- get free pages()
- vmalloc()
- Slabs and Cache Allocations
- Labs
Character Devices
- Device Nodes
- Major and Minor Numbers
- Reserving Major/Minor Numbers
- Accessing the Device Node
- Registering the Device
- udev
- dev printk() and Associates
- file operations Structure
- Driver Entry Points
- The file and inode Structures
- Miscellaneous Character Drivers
- Labs
Kernel Features
- Components of the Kernel
- User-Space vs. Kernel-Space
- What are System Calls?
- Available System Calls
- Scheduling Algorithms and Task Structures
- Process Context
- Labs
Transferring Between User and Kernel Space
- Transferring Between Spaces
- put(get) user() and copy to(from) user()
- Direct Transfer: Kernel I/O and Memory Mapping
- Kernel I/O
- Mapping User Pages
- Memory Mapping
- User-Space Functions for mmap()
- Driver Entry Point for mmap()
- Accessing Files from the Kernel
- Labs
Platform Drivers
- What are Platform Drivers?
- Main Data Structures
- Registering Platform Devices
- An Example
- Hardcoded Platform Data
- The New Way: Device Trees
- Labs
Device Trees
- What are Device Trees?
- What Device Trees Do and What They Do Not Do
- Device Tree Syntax
- Device Tree Walk Through
- Device Tree Bindings
- Device Tree support in Boot Loaders
- Using Device Tree Data in Drivers
- Coexistence and Conversion of Old Drivers
- Labs
Interrupts and Exceptions
- What are Interrupts and Exceptions?
- Exceptions
- Asynchronous Interrupts
- MSI
- Enabling/Disabling Interrupts
- What You Cannot Do at Interrupt Time
- IRQ Data Structures
- Installing an Interrupt Handler
- Labs
Timing Measurements
- Kinds of Timing Measurements
- Jiffies
- Getting the Current Time
- Clock Sources
- Real Time Clock
- Programmable Interval Timer
- Time Stamp Counter
- HPET
- Going Tickless
Kernel Timers
- Inserting Delays
- What are Kernel Timers?
- Low Resolution Timer Functions
- Low Resolution Timer Implementation
- High Resolution Timers
- Using High Resolution Timers
- Labs
ioctls
- What are ioctls?
- Driver Entry point for ioctls
- Defining ioctls
- Labs
Unified Device Model and sysfs
- Unified Device Model
- Basic Structures
- Real Devices
- sysfs
- kset and kobject examples
- Labs
Firmware
- What is Firmware?
- Loading Firmware
- Labs
Sleeping and Wait Queues
- What are Wait Queues?
- Going to Sleep and Waking Up
- Going to Sleep Details
- Exclusive Sleeping
- Waking Up Details
- Polling
- Labs
Interrupt Handling: Deferrable Functions and User Drivers
- Top and Bottom Halves
- Softirqs
- Tasklets
- Work Queues
- New Work Queue API
- Creating Kernel Threads
- Threaded Interrupt Handlers
- Interrupt Handling in User-Space
- Labs
Hardware I/O
- Memory Barriers
- Allocating and Mapping I/O Memory
- Accessing I/O Memory
Direct Memory Access (DMA)**
- What is DMA?
- DMA Directly to User
- DMA and Interrupts
- DMA Memory Constraints
- DMA Masks
- DMA API
- DMA Pools
- Scatter/Gather Mappings
- Labs
Memory Technology Devices (Flash Memory Filesystems)
- What are MTD Devices?
- NAND vs. NOR vs. eMMC
- Driver and User Modules
- Flash Filesystems
USB Drivers
- What is USB?
- USB Topology
- Terminology
- Endpoints
- Descriptors
- USB Device Classes
- USB Support in Linux
- Registering USB Device Drivers
- Moving Data
- Example of a USB Driver
- Labs
Closing and Evaluation Survey
- Evaluation Survey
Kernel Architecture I
- UNIX and Linux **
- Monolithic and Micro Kernels
- Object-Oriented Methods
- Main Kernel Components
- User-Space and Kernel-Space
Kernel Programming Preview
- Task Structure
- Memory Allocation
- Transferring Data between User and Kernel Spaces
- Object-Oriented Inheritance - Sort Of
- Linked Lists
- Jiffies
- Labs
Modules
- What are Modules?
- A Trivial Example
- Compiling Modules
- Modules vs Built-in
- Module Utilities
- Automatic Module Loading
- Module Usage Count
- Module Licensing
- Exporting Symbols
- Resolving Symbols **
- Labs
Kernel Architecture II
- Processes, Threads, and Tasks
- Kernel Preemption
- Real Time Preemption Patch
- Labs
Kernel Configuration and Compilation
- Installation and Layout of the Kernel Source
- Kernel Browsers
- Kernel Configuration Files
- Kernel Building and Makefiles
- initrd and initramfs
- Labs
Kernel Style and General Considerations
- Coding Style
- Using Generic Kernel Routines and Methods
- Making a Kernel Patch
- sparse
- Using likely() and unlikely()
- Writing Portable Code, CPU, 32/64-bit, Endianness
- Writing for SMP
- Writing for High Memory Systems
- Power Management
- Keeping Security in Mind
- Labs
Race Conditions and Synchronization Methods
- Concurrency and Synchronization Methods
- Atomic Operations
- Bit Operations
- Spinlocks
- Seqlocks
- Disabling Preemption
- Mutexes
- Semaphores
- Completion Functions
- Read-Copy-Update (RCU)
- Reference Counts
- Labs
Memory Addressing
- Virtual Memory Management
- Systems With and Without MMU and the TLB
- Memory Addresses
- High and Low Memory
- Memory Zones
- Special Device Nodes
- NUMA
- Paging
- Page Tables
- page structure
- Labs
Memory Allocation
- Requesting and Releasing Pages
- Buddy System
- Slabs and Cache Allocations
- Memory Pools
- kmalloc()
- vmalloc()
- Early Allocations and bootmem()
- Memory Defragmentation
- Labs

** These sections may be considered in part or in whole as optional. They contain either background reference material, specialized topics, or advanced subjects. The instructor may choose to cover or not cover them depending on classroom experience and time constraints.
Prerequisites
To make the most of this course, you must have:

Knowledge of basic kernel interfaces and methods such as how to write, compile, load and unload modules, use synchronization primitives, and the basics of memory allocation and management, such as is provided by LFD420 (Kernel Internals and Development). Pre-class preparation material will be provided before class.

Reviews
Oct 2022
I am so glad we spent a lot of time on the device tree chapter, as I needed that for my job.
Oct 2022
The instructor had many relevant and useful anecdotes about current Linux kernel developers, and a history of why some things in Linux are the way they are.
Oct 2022
Instructor was very knowledgeable, he answered my questions fully, and was very helpful.
Oct 2022
I enjoyed the labs the most. They helped me learn so much, and I actually grasped a few concepts well considering it was my first time. I enjoyed working through them.
Oct 2022
The instructor was kind and informative, and spoke very well.
Oct 2022
Doing the labs, because I got everything working in dedicated time.
Sep 2022
It introduced me to a lot of topics in driver development that I was not familiar with.
Sep 2022
Tom did a great job answering my random questions, or anything I asked for more detail on. He's clearly super knowledgeable, and yet is still able to communicate these concepts to folk who are very new in this area, like myself.
Sep 2022
Hands on content was great, it provided a mechanism for accountability, and for me to dedicate myself to learning the topics.
Sep 2022
I got a good understanding of device drivers, and a good list of reference links in case I am stuck with something. The instructor was able to keep the class very engaged as well.
Sep 2022
The lab-provided solutions are super helpful, both to learn by doing, and to have reference material for the future.
Aug 2022
I learned a lot about the "gotchas" of Linux driver development. I feel like I can go back, do the exercises later, and get a good understanding.
Aug 2022
The instructor is very knowledgeable and experienced about the topics. The material is vast, and covers a lot of concepts. I also liked the labs a lot.
Aug 2022
First and foremost - having actual examples! Rather than just talking about the concepts involved, having actual code to look at was great. The instructor also did a good job tailoring certain things to the class - shifting things around based on student experience and/or interest. Finally, I really appreciate the fact that the labs are going to be available outside of the class itself, since we didn't get to explore so many of them during the class, and I'd like to be able to do so independently.
Aug 2022
Gaining a better understanding of drivers, and learning where to look to get more in depth information.
Aug 2022
I think everything was great and astonishing. Every question I asked was answered in great detail. The exercises were very well prepared, we appreciate that, because it is the basis upon which we can start building our professional work. The knowledge of the instructor, and the willingness to answer our questions. The training manual was very well written. Adrian answered my questions, even if they were late in the night, and close to the beginning of the course. The slides had lots of images and visual information.