Click here to start
Table of contents
EMBEDDED LINUX KERNEL AND DRIVER DEVELOPMENT
Contents
DRIVER DEVELOPMENT - Loadable kernel modules
hello module
Hello module explanations
Symbols exported to modules
Symbols exported to modules (2)
Module license
Compiling a module
Compiling an out-of-tree module
Compiling an out-of-tree module (2)
Modules and kernel version
New driver in kernel sources (1)
New driver in kernel sources (2)
How to create patches
hello module with parameters
Declaring a module parameter
Practical lab - Writing modules
DRIVER DEVELOPMENT - Memory management
Physical and virtual memory
Virtual memory organization: 1GB/3GB
Physical / virtual memory mapping
Accessing more physical memory
Accessing even more physical memory
Notes on user-space memory
Back to kernel memory
Allocators in the kernel
Page allocator
Page allocator API
Page allocator flags
SLAB allocator
SLAB allocator (2)
Different SLAB allocators
kmalloc allocator
kmalloc API
kmalloc API (2)
vmalloc allocator
Kernel memory debugging
EMBEDDED LINUX DRIVER DEVELOPMENT - Useful general-purpose kernel APIs
Memory/string utilities
Linked lists
Linked lists example
DRIVER DEVELOPMENT - I/O memory and ports
Port I/O vs. Memory-Mapped I/O
MMIO vs PIO
Requesting I/O ports
Reading / writing strings on I/O ports
Requesting I/O memory
Mapping I/O memory in virtual memory
ioremap()
Accessing MMIO devices - The "old" style
New API for mixed accesses
Avoiding I/O access issues
/dev/mem
Practical lab - I/O memory and ports
DRIVER DEVELOPMENT - Character drivers
Usefulness of character drivers
Creating a character driver
Implementing a character driver
File operations
open() and release()
read() and write()
write()
Exchanging data with user-space (1)
Exchanging data with user-space (2)
Exchanging data with user-space (3)
read operation example
write operation example
unlock_ioctl()
ioctl() example: kernel side
ioctl() example: application side
file operations definition example (3)
dev_t data type
Registering device numbers (1)
Registering device numbers (2)
Information on registered devices
Character device registration
Character device registration (2)
Character driver unregistration
Linux error codes
Char driver example summary
Char driver example summary (2)
Character driver summary
Practical lab - Character drivers
DRIVER DEVELOPMENT - Processes and scheduling
Process, thread ?
Process, thread: kernel point of view
A process life
Process context
DRIVER DEVELOPMENT - Sleeping
Sleeping
How to sleep (1)
How to sleep (2)
How to sleep - Example
Waking up
Exclusive vs. non-exclusive
Sleeping and waking up - implementation
DRIVER DEVELOPMENT - Interrupt management
Registering an interrupt handler (1)
Registering an interrupt handler (2)
Interrupt handler constraints
Information on installed handlers
Interrupt handler prototype
The interrupt handler's job
Top half and bottom half processing (1)
Tasklets
Interrupt management summary
Practical lab - Interrupts
DRIVER DEVELOPMENT - Concurrent access to sources
Sources of concurrency issues
Avoiding concurrency issues
Concurrency protection with locks
Linux mutexes
locking and unlocking mutexes
Spinlocks
Initializing spinlocks
Using spinlocks
Spinlock example
Deadlock situations
Kernel lock validator
Alternatives to locking
Atomic variables
Atomic bit operations
Practical lab - Locking
DRIVER DEVELOPMENT - Debugging
Debugging with printk
Debugging with /proc or /sys (1)
Debugfs
Simple debugfs example
Debugging with ioctl
Using Magic SysRq
kgdb - A kernel debugger
Using kgdb
Using kgdb (2)
Debugging with a JTAG interface
More kernel debugging tips
SystemTap
SystemTap script example (1)
SystemTap script example (2)
Kernel crash analysis with kexec/kdump
Kernel markers
LTTng
LTTV
Practical lab - Kernel debugging
DRIVER DEVELOPMENT - mmap
Process VMA (1)
Process VMA (2)
mmap overview
How to implement mmap - User space
How to implement mmap - Kernel space
remap_pfn_range()
Simple mmap implementation
devmem2
mmap summary
DRIVER DEVELOPMENT - Kernel architecture for device drivers
Kernel and device drivers
Kernel and device drivers (2)
Kernel frameworks
Frameworks
Example: framebuffer framework
Framebuffer driver skeleton
Framebuffer driver skeleton (2)
Framebuffer driver skeleton (3)
Device Model and Bus Infrastructure
Unified device model
Bus drivers
Example: USB Bus
Example: USB bus (2)
Example of device driver
Device identifiers
Instanciation of usb_driver
Driver (un)registration
At initialization
When a device is detected
Probe method
Probe method example
The model is recursive
sysfs
Platform devices
Implementation of the platform driver
Platform device instantiation (1)
Platform device instantiation (2)
I/O resources
Using resources
platform_data mechanism
platform_data example (1)
platform_data example (2)
Driver-specific data structure
Driver-specific data structure examples
Link between structures (1)
Link between structures (2)
Link between structures (3)
Example of another non-dynamic bus : SPI
SPI components
SPI AT91 SoC code
SPI AT91 SoC code (2)
AT91RM9200DK board code for SPI
References