Linux Kernel & Drivers
Est. read time: 2 minutes | Last updated: November 07, 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 Kernel Newbies
- Linux Device Drivers, Third Edition
- Bootlin RT/embedded Linux training materials and docs
- Bootlin has a lot of up-to-date material on things from kernel driver development to Yocto and embedded Linux building.
- The Linux Kernel’s Documentation
- The (unofficial) Linux Kernel Mailing List (LKML)
- The Linux Documentation Project
- Red Hat Developer Program
-
[Linux Performance Analysis in 60,000 Milliseconds by Netflix Technology Blog Netflix TechBlog](https://netflixtechblog.com/linux-performance-analysis-in-60-000-milliseconds-accc10403c55) -
[Netflix at Velocity 2015: Linux Performance Tools by Netflix Technology Blog Netflix TechBlog](https://netflixtechblog.com/netflix-at-velocity-2015-linux-performance-tools-51964ddb81cf)