Est. read time: 2 minutes | Last updated: May 23, 2024 by John Gentile


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

Device tree is a simple tree like data structure that can describe a non-discoverable hardware configuration to the kernel. Platform devices are created at run-time by the kernel by parsing the device tree nodes. Device nodes can carry configuration / platform data for the devices. Also allows kernel code and platform data to be decoupled.


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


Compilation & Tools


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.