Click here to start
Table of contents
EMBEDDED LINUX KERNEL AND DRIVER DEVELOPMENT
Rights to copy
Best viewed with...
Hyperlinks in this document
Course prerequisites
Contents (1)
Contents (2)
Contents (3)
Contents (4)
KERNEL OVERVIEW - Linux features
Studied kernel version: 2.6
Linux key features
Supported hardware architectures
KERNEL OVERVIEW - Kernel code
Implemented in C
Programming languages in the kernel sources
Compiled with GNU C
Help gcc to optimize your code
No C library
Managing endianism
Kernel coding guidelines
KERNEL OVERVIEW - Kernel subsystems
Kernel architecture
Kernel memory constraints
I/O schedulers
KERNEL OVERVIEW - Linux versioning scheme and development process
Until 2.6 (1)
Until 2.6 (2)
Changes since Linux 2.6 (1)
Changes since Linux 2.6 (2)
Merge and bug fixing windows
More stability for the 2.6 kernel tree
No stable Linux internal API (1)
No stable Linux internal API (2)
What's new in each Linux release? (1)
What's new in each Linux release? (2)
KERNEL OVERVIEW - Legal issues
Linux license
Linux kernel licensing constraints
Advantages of GPL drivers
Advantages of in-tree kernel modules
Legal proprietary Linux drivers (1)
Legal proprietary Linux drivers (2)
KERNEL OVERVIEW - Kernel user interface
Mounting virtual filesystems
Kernel userspace interface
Userspace interface documentation
Userspace device drivers (1)
Userspace device drivers (2)
COMPILING AND BOOTING LINUX - Linux kernel sources
kernel.org
Linux sources structure (1)
Linux sources structure (2)
Linux kernel size (1)
Linux kernel size (2)
Getting Linux sources: 2 possibilities
Downloading full kernel sources
Downloading kernel source patches (1)
Downloading kernel source patches (2)
Anatomy of a patch file
Using the patch command
Applying a Linux patch
Accessing development sources (1)
Accessing development sources (2)
On-line kernel documentation
COMPILING AND BOOTING LINUX - Kernel source management tools
Cscope
Cscope screenshot
KScope
KScope screenshots (1)
KScope screenshots (2)
LXR: Linux Cross Reference
LXR screenshot
Ketchup - Easy access to kernel source trees
Ketchup examples
Practical lab - Kernel sources
COMPILING AND BOOTING LINUX - Kernel configuration
Kernel configuration
make xconfig
make xconfig screenshot
make xconfig search interface
Kernel configuration options
Corresponding .config file excerpt
make gconfig
make menuconfig
make oldconfig
make allnoconfig
Undoing configuration changes
make help
Customizing the version string
COMPILING AND BOOTING LINUX - Compiling the kernel
Compiling and installing the kernel
Compiling faster on multiprocessor hosts
Compiling faster
Kernel compiling tips
Generated files
Files created by make install
Files created by make modules_install (1)
Files created by make modules_install (2)
Compiling the kernel in a nutshell
COMPILING AND BOOTING LINUX - Linux device files
Character device files
Block drivers
Device major and minor numbers
Device file creation
Practical lab - Configuring and compiling
COMPILING AND BOOTING LINUX - Overall system startup
Linux 2.4 booting sequence
Linux 2.6 booting sequence
Linux 2.6 booting sequence with initrd
Linux 2.4 booting sequence drawbacks
Extra init ramdisk drawbacks
Initramfs features and advantages (1)
Initramfs features and advantages (2)
Initramfs features and advantages (3)
Initramfs features and advantages (4)
How to populate an initramfs
Initramfs specification file example
How to handle compressed cpio archives
How to create an initrd
Booting variants
COMPILING AND BOOTING LINUX - Bootloaders
2-stage bootloaders
x86 bootloaders
Generic bootloaders
Other bootloaders
COMPILING AND BOOTING LINUX - Kernel booting
Booting parameters
Kernel command line example
Usefulness of rootfs on NFS
NFS boot setup (1)
NFS boot setup (2)
First user-space program
/linuxrc
The init program
COMPILING AND BOOTING LINUX - Cross-compiling the kernel
Cross-compiling the kernel
Specifying a cross-compiler (1)
Specifying a cross-compiler (2)
Specifying a cross compiler (3)
Configuring the kernel
arch/arm/configs example
Using read-made config files
Cross-compiling setup
Building the kernel - cross-compiling
Cross-compiling summary
Practical lab - Cross-compiling
DRIVER DEVELOPMENT - Loadable kernel modules
Loadable kernel modules
Symbols exported to modules
Module dependencies
hello module
Module license usefulness
Possible module license strings
Compiling a module
Kernel log
Accessing the kernel log
Using the module
Understanding module loading issues
Module utilities (1)
Module utilities (2)
Module utilities (3)
Create your modules with kdevelop
DRIVER DEVELOPMENT - Module parameters
hello module with parameters
Passing module parameters
Declaring a module parameter
Declaring a module parameter array
DRIVER DEVELOPMENT - Adding sources to the kernel tree
New driver in kernel sources (1)
New driver in kernel sources (2)
How to create patches
Practical lab - Writing modules
DRIVER DEVELOPMENT - Memory management
Physical and virtual memory
kmalloc and kfree
kmalloc features
Main kmalloc flags (1)
Main kmalloc flags (2)
Related allocation functions
Available allocators
Slab caches and memory pools
Allocating by pages
Freeing pages
vmalloc
Memory utilities
Memory management - Summary
DRIVER DEVELOPMENT - I/O memory and ports
Requesting I/O ports
Reading / writing on I/O ports
Reading / writing strings on I/O ports
Requesting I/O memory
Mapping I/O memory in virtual memory
Differences with standard memory
Avoiding I/O access issues
Accessing I/O memory
/dev/mem
DRIVER DEVELOPMENT - Character drivers
Usefulness of character drivers
Creating a character driver
Declaring a character driver
Information on registered devices
dev_t data type
Allocating fixed device numbers
Dynamic allocation of device numbers
Creating device files
File operations (1)
The file structure
File operations (2)
Exchanging data with user-space (1)
Exchanging data with user-space (2)
File operations (3)
File operations specific to each open file!
File operations (4)
read operation example
write operation example
file operations definition example (3)
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 - Debugging
Debugging with printk
Debugging with /proc or /sys (1)
Debugging with /proc or /sys (2)
Debugfs
Simple debugfs example
Debugging with ioctl
Debugging with gdb
kgdb - A kernel debugger
Kernel crash analysis with kexec
SystemTap
SystemTap script example (1)
SystemTap script example (2)
Other debugging techiques
More kernel debugging tips
Practical lab - Kernel debugging
DRIVER DEVELOPMENT - Processes and scheduling
Processes
Threads
A process life
Process context
Kernel threads
Process priorities
Real-time priorities
Timeslices
When is scheduling run?
DRIVER DEVELOPMENT - Sleeping
Sleeping
How to sleep (1)
How to sleep (2)
How to sleep - Example
Waking up
Sleeping and waking up - implementation
DRIVER DEVELOPMENT - Interrupt management
Interrupt handler constraints
Registering an interrupt handler (1)
Registering an interrupt handler (2)
When to register the handler
Information on installed handlers
Total number of interrupts
The interrupt handler's job
Interrupt handler prototype
Top half and bottom half processing
top half and botton half processing (2)
Disabling interrupts
Masking out an interrupt line
Checking interrupt status
Interrupt management fun
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
Reader / writer semaphores
Spinlocks
Initializing spinlocks
Using spinlocks (1)
Using spinlocks (2)
Deadlock situations
Kernel lock validator
Alternatives to locking
Atomic variables
Atomic bit operations
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 - DMA
DMA memory constraints
Reserving memory for DMA
Memory synchronization issues
Linux DMA API
Limited DMA address range?
Coherent or streaming DMA mappings
Allocating coherent mappings
DMA pools (1)
DMA pools (2)
Setting up streaming mappings
DMA streaming mapping notes
DMA summary
DRIVER DEVELOPMENT - New device model
Device Model features (1)
Device model features (2)
sysfs
sysfs tools
Device Model references
ETHERNET OVER USB
Ethernet over USB (1)
Ethernet over USB (2)
Ethernet over USB (3)
ADVICE AND RESOURCES - Getting help and contributions
Solving issues
Getting help
Getting contributions
Encouraging contributions
ADVICE AND RESOURCES - Bug report and patch submission
Reporting Linux bugs
How to submit Linux patches
How to become a kernel developer?
ADVICE AND RESOURCES - References
Specific training materials
Information sites (1)
Information sites (2)
Useful reading (1)
Useful reading (2)
Useful reading (3)
Useful reading (4)
Useful on-line resources
Embedded Linux Wiki
ARM Linux resources
International conferences
International conferences (2)
ADVICE AND RESOURCES - Last advice
Use the Source, Luke
ANNEXES - Quiz answers
Quiz answers
ANNEXES: Kernel sources
Checking the integrity of sources
ANNEXES - Slab caches and memory pools
Slab caches
Slab cache API (1)
Slab cache API (2)
Slab cache API (3)
Memory pools
Memory pool API (1)
Memory pool API (2)
Memory pool implementation
Memory pools using slab caches
ANNEXES - Init runlevels
System V init runlevels (1)
System V init runlevels (2)
init scripts
/etc/init.d
Handling init scripts by hand
Init runlevels - Useful links
Training labs
Related documents
How to help
Thanks
Free Electrons services
Author:
Free Electrons
E-mail:
info@free-electrons.com
Homepage:
http://free-electrons.com/