Linux Kernel & Drivers
Est. read time: 2 minutes | Last updated: August 29, 2024 by John Gentile
Contents
Device Drivers
Device drivers play an important role in computer systems as a software layer between hardware devices and applications; they abstract away hardware specific details and present a standardized interface to user software to allow portable & more functional code. Drivers are meant to provide a generic mechanism for different upper-level to consistently access a type of device and further define a policy usage; for instance, one can write portable sockets code for a wide variety of disparate networking hardware due to generic network device drivers in the kernel. Since different applications or users may want different things from a device at different times (or even multiple things at the same time), it’s best to keep a driver as generic and open as possible and focus mainly on providing flexible access to hardware while striking a balance with simplicity. How a driver or hardware is inevitably used should be up to an application.
Linux device drivers are also modular (referred to commonly as kernel modules) in that they can be built separately from the OS kernel itself and plugged in (and out) at a later time when needed.
Device Trees
Tools
device-tree-compiler
can be used to both compile, and decompile, device trees.
- Decompile DTB:
$ dtc -I dtb -O dts my_dt_blob.dtb -o decompiled_dtb.dts
DT References
Filesystem
- Filesystem Hierarchy Standard is a currently updated standard for Unix distributions on certain file/directories and their meanings.
Compilation & Tools
Debugging
- For JTAG (and ARM SWD, etc.) debugging, see OpenOCD
Vim YCM Completion
Since YouCompleteMe and some other tools rely on the clang compile_commands.json
that usually is fed by CMake, and we don’t care about protablility or CMake since this is for the Linux kernel, we can generate the JSON file to aid in development of kernel code (e.g. parse kernel headers and have proper flags) by using Bear: install bear
and then run $ bear make
to generate a compile_commands.json
from the make process.
References
- Linux Device Drivers, Third Edition
- Bootlin RT/embedded Linux training materials
- Getting Kernel Sources- CentOS 7
- Building Kernel Module- CentOS 7
- The Linux Kernel’s Documentation
- The (unofficial) Linux Kernel Mailing List (LKML)
- The Linux Documentation Project
- Linux Kernel Newbies
- Red Hat Developer Program