Course Code: ldd
Duration: 35 hours

Prerequisites:

  • Basic familiarity with using a GNU/Linux system as an end user
  • Basic familiarity with a command line shell
  • Basic knowledge of user space / application development
  • Intermediate C programming knowledge
  • Should have attended Embedded GNU/Linux Systems Architecture before (strongly recommended!) and/or have a good understanding of the topics outlined there

Overview:

Description

This 5-day training class uses hands-on exercises combined with instruction to illustrate the concepts of GNU/Linux kernel internals and device driver development. It is designed to bring you quickly up to speed. We describe processes, concepts and commands necessary to write GNU/Linux device drivers through a combination of theory and on-the-job training.

Don't reinvent the wheel, but learn from an experienced trainer and take home a working knowledge and the ability to use it effectively in your own embedded development project.

Who should attend?

People with interest in or tasked with the development or evaluation of developing GNU/Linux device drivers like software engineers, field engineers, (project) managers, hardware engineers.

Course Outline:

Introduction

  • quick history of GNU/Linux
  • licensing
  • kernel versioning
  • release cycle
  • kernel trees
  • mainline
  • kernel vs. user space
  • mechanism vs. policy
  • kernel driver alternatives
  • RTOS vs. Linux

Memory Management

  • Virtual memory vs. physical memory
  • memory allocation in kernel
  • pages
  • zones
  • API
  • slab

Kernel Patch

  • life cycle
  • git
  • kernel source
  • create patch
  • check patch
  • fix patch
  • ship patch
  • audited code

Kernel Modules

  • get kernel sources
  • configure/build/install
  • device drivers (statically linked, loaded at runtime)
  • init/exit
  • licensing
  • EXPORT SYMBOL GPL
  • out of tree makefile
  • module-init-tools
  • module in kernel tree
  • Kconfig
  • parameter passing
  • sparse

Char Drivers

  • architecture
  • user/kernel interface
  • I/O subsystem
  • VFS
  • sysfs (devices, bus, drivers, classes),
  • kobject/ktype/kset
  • linux kernel driver model
  • device files
  • char driver

    • initialization
    • registration
    • open, release
    • cdev, cdev add, cdev del,...
    • major/minor numbers
    • udev, udevmonitor, udevadm

Advanced Charachter Driver Operations

  • ioctl
  • unlocked ioctl
  • compat ioctl
  • user space API
  • kernel space API
  • process lifecycle
  • sleeping/blocking
  • sleeping/waking up
  • wait queue
  • thundering herd
  • poll/select

Kernel Debugging

  • debugging
  • debugging the kernel

    • binary search with git
    • debug support from kernel
    • printk syslogd, klogd, loglevels, rate limit, debug levels, debug selective subsystems
    • debugging by querying debugfs
    • oops debugging, asserting oops
    • Magic SysRq Key
    • kgdb/kdb
    • JTAG

Tracing

  • gcov
  • lcov
  • oprofile
  • ftrace

    • nop tracer
    • function tracer
    • sched switch tracer
    • function graph tracer
    • dynamic tracer
  • trace-cmd/kernelshark
  • perf
  • LTTng

Interrupts

  • interrupts vs. polling
  • interrupt
  • program sections
  • reentrancy
  • events
  • interrupt handler
  • shared interrupt handler
  • interrupt flow
  • interrupt control

Deferring Work

  • top/bottom halves
  • softirqs
  • tasklets
  • work queues
  • threaded interrrupts

Concurrency

  • critical region/section
  • atomic
  • race condition
  • synchronization
  • locking
  • locking solutions
  • deadlock
  • contention
  • what to lock?
  • what can be used?

    • atomic operations
    • spin locks
    • reader-writer spin locks
    • semaphore
    • binary semaphore
    • mutex
    • reader-writer semaphore
    • completion variables
    • sequential locks
    • disable preemption
    • orderig and barriers

Time

  • HZ
  • Jiffies
  • big/small delays
  • kernel timers

Hardware I/O

  • I/O Ports
  • I/O Memory
  • How to deal with side effects accessing registers?

User-Kernel Communication

  • put(get)_user()
  • copy to(from)_user()
  • Kernel I/O
  • memory mapping
  • procfs
  • sysfs
  • debugfs
  • relayfs
  • netlink
  • ioctl

Portability

  • word size
  • opaque types
  • signed/unsigned char
  • data alignment
  • integral promotion
  • code reuse
  • endianess
  • system tick
  • page size
  • instruction ordering
  • SMP/preemption/high memory

Except where otherwise noted content and this course outline are licensed under Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0).

Sites Published:

United Arab Emirates - Embedded GNU/Linux Kernel Internals and Device Drivers

Qatar - Embedded GNU/Linux Kernel Internals and Device Drivers

Egypt - Embedded GNU/Linux Kernel Internals and Device Drivers

Saudi Arabia - Embedded GNU/Linux Kernel Internals and Device Drivers

South Africa - Embedded GNU/Linux Kernel Internals and Device Drivers

Brasil - Inteiros do Kernel GNU/Linux Embarcado e Drivers de Dispositivo

Canada - Embedded GNU/Linux Kernel Internals and Device Drivers

中国 - 嵌入式GNU/Linux内核与设备驱动

香港 - Embedded GNU/Linux Kernel Internals and Device Drivers

澳門 - Embedded GNU/Linux Kernel Internals and Device Drivers

台灣 - Embedded GNU/Linux Kernel Internals and Device Drivers

USA - Embedded GNU/Linux Kernel Internals and Device Drivers

Österreich - GNU/Linux-Kernel-Internals und Gerätetreiber im Embedded-Bereich

Schweiz - GNU/Linux-Kernel-Internals und Gerätetreiber im Embedded-Bereich

Deutschland - GNU/Linux-Kernel-Internals und Gerätetreiber im Embedded-Bereich

Czech Republic - Interní struktury jádra GNU/Linuxu a ovladače zařízení

Denmark - Embedded GNU/Linux Kernel Internals and Device Drivers

Estonia - Embedded GNU/Linux Kernel Internals and Device Drivers

Finland - Embedded GNU/Linux Kernel Internals and Device Drivers

Greece - Εσώτερο Λειτουργικό των Πυρήνων GNU/Linux και Οδηγοί Συσκευών

Magyarország - Beágyazott GNU/Linux Kernel Belső Működése és Eszközmeghajtók

Ireland - Embedded GNU/Linux Kernel Internals and Device Drivers

Luxembourg - Embedded GNU/Linux Kernel Internals and Device Drivers

Latvia - Embedded GNU/Linux Kernel Internals and Device Drivers

España - Integridad Interna del Núcleo GNU/Linux y Controladores de Dispositivo

Italia - Interne del kernel GNU/Linux e driver di dispositivo

Lithuania - Embedded GNU/Linux Kernel Internals and Device Drivers

Nederland - Internals van de Embedded GNU/Linux-kernel en apparaatstuurprogramma's

Norway - Interne deler og enhetsdrivere i innebygd GNU/Linux

Portugal - Inteiros do Kernel GNU/Linux Embarcado e Drivers de Dispositivo

România - Internele Kernel-ului GNU/Linux și Driver-e de Dispozitive

Sverige - Interna funktioner i den inbäddade GNU/Linux-kärnan och enhetsdrivrutiner

Türkiye - Gömülü GNU/Linux Çekirdek İç Yapısı ve Aygıt Sürücüleri

Malta - Embedded GNU/Linux Kernel Internals and Device Drivers

Belgique - Interneurs du noyau GNU/Linux embarqué et pilotes de périphériques

France - Interneurs du noyau GNU/Linux embarqué et pilotes de périphériques

日本 - 組み込み GNU/Linux カーネル内部構造とデバイスドライバ

Australia - Embedded GNU/Linux Kernel Internals and Device Drivers

Malaysia - Embedded GNU/Linux Kernel Internals and Device Drivers

New Zealand - Embedded GNU/Linux Kernel Internals and Device Drivers

Philippines - Embedded GNU/Linux Kernel Internals and Device Drivers

Singapore - Embedded GNU/Linux Kernel Internals and Device Drivers

Thailand - Embedded GNU/Linux Kernel Internals and Device Drivers

Vietnam - Nội dung hạt nhân và trình điều khiển thiết bị GNU/Linux nhúng

India - Embedded GNU/Linux Kernel Internals and Device Drivers

Argentina - Integridad Interna del Núcleo GNU/Linux y Controladores de Dispositivo

Chile - Integridad Interna del Núcleo GNU/Linux y Controladores de Dispositivo

Costa Rica - Integridad Interna del Núcleo GNU/Linux y Controladores de Dispositivo

Ecuador - Integridad Interna del Núcleo GNU/Linux y Controladores de Dispositivo

Guatemala - Integridad Interna del Núcleo GNU/Linux y Controladores de Dispositivo

Colombia - Integridad Interna del Núcleo GNU/Linux y Controladores de Dispositivo

México - Integridad Interna del Núcleo GNU/Linux y Controladores de Dispositivo

Panama - Integridad Interna del Núcleo GNU/Linux y Controladores de Dispositivo

Peru - Integridad Interna del Núcleo GNU/Linux y Controladores de Dispositivo

Uruguay - Integridad Interna del Núcleo GNU/Linux y Controladores de Dispositivo

Venezuela - Integridad Interna del Núcleo GNU/Linux y Controladores de Dispositivo

Polska - Wewnętrzne działanie jądra GNU/Linux i sterowniki urządzeń

United Kingdom - Embedded GNU/Linux Kernel Internals and Device Drivers

South Korea - 임베디드 GNU/Linux 커널 내부 구조 및 장치 드라이버

Pakistan - Embedded GNU/Linux Kernel Internals and Device Drivers

Sri Lanka - Embedded GNU/Linux Kernel Internals and Device Drivers

Bulgaria - Вътрешна структура на вграденото GNU/Linux ядро и драйвери за устройства

Bolivia - Integridad Interna del Núcleo GNU/Linux y Controladores de Dispositivo

Indonesia - Embedded GNU/Linux Kernel Internals and Device Drivers

Kazakhstan - Embedded GNU/Linux Kernel Internals and Device Drivers

Moldova - Internele Kernel-ului GNU/Linux și Driver-e de Dispozitive

Morocco - Embedded GNU/Linux Kernel Internals and Device Drivers

Tunisia - Embedded GNU/Linux Kernel Internals and Device Drivers

Kuwait - Embedded GNU/Linux Kernel Internals and Device Drivers

Oman - Embedded GNU/Linux Kernel Internals and Device Drivers

Slovakia - Embedded GNU/Linux Kernel Internals and Device Drivers

Kenya - Embedded GNU/Linux Kernel Internals and Device Drivers

Nigeria - Embedded GNU/Linux Kernel Internals and Device Drivers

Botswana - Embedded GNU/Linux Kernel Internals and Device Drivers

Slovenia - Embedded GNU/Linux Kernel Internals and Device Drivers

Croatia - Embedded GNU/Linux Kernel Internals and Device Drivers

Serbia - Embedded GNU/Linux Kernel Internals and Device Drivers

Bhutan - Embedded GNU/Linux Kernel Internals and Device Drivers

Nepal - Embedded GNU/Linux Kernel Internals and Device Drivers

Uzbekistan - Embedded GNU/Linux Kernel Internals and Device Drivers

US Government - Embedded GNU/Linux Kernel Internals and Device Drivers