
Recall first from Building a kernel defconfig
- The kernel build consumes the resolved .config, which includes Kconfig defaults and dependency decisions.
- A platform symbol can enable infrastructure and make additional driver choices available.
- Drivers needed before modules are accessible must be built in.
Trace a compatible string to its driver
4 min readA defconfig is only useful if it enables the drivers your board's nodes name. This lesson answers how to go from a compatible string to a Kconfig symbol, and where SoC code ends and board device tree begins.
On a Raspberry Pi 4, the on-chip I2C controller nodes in bcm2711.dtsi carry the compatible list "brcm,bcm2711-i2c", "brcm,bcm2835-i2c": the BCM2711 name first and the older BCM2835 identifier as a fallback. The driver's match table lists both strings. The older identifier describes a controller interface that the existing driver supports. The board's product name and the SoC's model number alone would make poor search terms for this driver. The kernel documentation describes how a compatible property can express compatibility with an earlier implementation.
Use the source checkout for the kernel you intend to build. The kernel running your Ubuntu terminal can be a different build, especially in WSL2. A search of your target checkout answers which drivers and configuration rules are available to your build. Run these commands from the root of a Linux 6.8 Git checkout on Ubuntu 24.04.
git grep -n -F 'brcm,bcm2835-i2c' -- arch/arm arch/arm64 drivers Documentation/devicetree/bindings
git grep -n -F 'of_match_table' -- drivers/i2c/busses/i2c-bcm2835.c
git grep -n -F 'i2c-bcm2835.o' -- drivers/i2c/busses/Makefile
git grep -n -A 12 '^config I2C_BCM2835$' -- drivers/i2c/busses/Kconfig
The first search serves three purposes. The device tree occurrences show where the hardware description uses the string. The binding describes the hardware interface and which properties describe it. The driver occurrence is the candidate to investigate. In drivers/i2c/busses/i2c-bcm2835.c, the string appears in the driver's of_device_id table. The driver's .of_match_table refers to that table. Follow that reference when reading the file. A string in a comment, binding example, or a table used by unrelated code gives different evidence from an entry in the table the driver actually registers.
The Makefile rule associates i2c-bcm2835.o with CONFIG_I2C_BCM2835. The declaration in drivers/i2c/busses/Kconfig is config I2C_BCM2835. Kconfig declarations use the bare symbol name, and Kbuild rules and .config use its CONFIG_ form. This gives you an exact symbol to look up in a configuration interface or to check in the resolved configuration. In a Linux v6.12 tree the declaration is a tristate with depends on ARCH_BCM2835 || ARCH_BRCMSTB || COMPILE_TEST and depends on COMMON_CLK, so the platform symbol from the previous lesson is what makes the driver selectable. The Makefile line is obj-$(CONFIG_I2C_BCM2835) += i2c-bcm2835.o.
The filenames in this example make the search straightforward. Some drivers build a composite object from several source files. If a search for your source file's object leads to a line that adds it to a composite object, look up where the composite object enters an obj-$(CONFIG_...) list. Also check the parent Makefile when it controls whether Kbuild visits the directory. The configuration name may describe a controller family, so use the build rules to confirm it even when a menu entry sounds plausible.
Start with the compatible list on the peripheral you actually want to enable. A node can list a specific compatible first and then a more general fallback. Search each string exactly and use the binding to confirm that any fallback is valid for that hardware. If you are looking at an I2C device soldered to the board, its node and its parent controller node describe two different devices. The controller symbol builds the code for the bus controller. The child compatible can lead to a separate driver in a different subsystem. Record which node you started from along with the symbol you found.
Check what the target configuration can build
3 min readFinding I2C_BCM2835 tells you what to ask Kconfig for. The Kconfig entry tells you what requests are possible. Read the symbol's type and any depends on expression. Then check the enclosing conditions, including the Kconfig file that sources the driver's file. In the example, I2C_BCM2835 is a tristate, and the enclosing I2C subsystem condition applies to the bus driver. You can find that context in drivers/i2c/Kconfig.
git grep -n -E '^(menuconfig I2C|if I2C|source "drivers/i2c/busses/Kconfig")' -- drivers/i2c/Kconfig
A tristate symbol can resolve to y, m, or n. For this driver's build rule, y includes the object in the built-in kernel, m builds a module when module support is enabled, and n omits it. Dependencies limit the values a symbol can take. If I2C is disabled, its enclosing condition prevents you from enabling the controller in the normal configuration interface. If I2C is a module and the other requirements are met, this controller can be a module too. To build the controller into the kernel, the enclosing I2C condition also needs to allow y.
Some symbols also carry architecture conditions or require another subsystem. Read the whole expression, including alternatives joined by ||. A select line has the opposite direction from depends on. It names another symbol that the current symbol can force on, subject to the select expression. When a driver option is unavailable, start by examining its dependencies and enclosing conditions. A list of symbols it selects answers a different question.
In menuconfig, / searches for a symbol and displays information about its location and dependencies. Use the interface for the target architecture and the same build configuration directory you used in the previous lesson. On an x86 Ubuntu host, the host configuration and the intended ARM64 configuration can expose different options. Once Kconfig has resolved the configuration, inspect the .config for the target build. From the directory that contains that file, you can run:
grep -E '^(CONFIG_I2C=|CONFIG_I2C_BCM2835=|# CONFIG_I2C is not set$|# CONFIG_I2C_BCM2835 is not set$)' .config
Read an assignment as the effective value for that build. A # CONFIG_... is not set line indicates a disabled option. If the driver symbol is absent, return to the target Kconfig view and check whether its definition is available under the current conditions. This check matters because the input defconfig states requested settings and can omit settings that Kconfig supplies by default. Kconfig also evaluates dependencies before it writes the resolved result.
The device tree and the configuration answer separate questions about the same hardware. For the Pi controller, you need the controller code in a usable build form and a board description that makes that controller available where it is used. A board node can set the controller's status to "okay" while the kernel configuration omits the driver. The Makefile and resolved .config let you settle the build question directly.
Decide where the hardware description belongs
4 min readThink about what would change if you placed the same SoC on a second board. A controller's register block placement and its interrupt connection inside the SoC come from the chip design. Those facts belong in the shared SoC device tree description when the binding represents them as DT properties. The code that accesses the registers and implements controller operations belongs in a reusable kernel driver. SoC support can therefore include both C code and shared .dtsi files. The hardware's scope determines where the change belongs.
The board DTS describes how the manufacturer uses the available hardware. It can enable an inherited controller, choose pin states for the pins routed on that board, and describe a device connected to the bus, including its address and any board-specific supply wiring required by the binding. On another board using the same SoC, that controller might be unused or connected to a different device. Both boards can inherit the same description of the controller's registers and interrupt. A board DTS can also inherit descriptions shared across a family of boards.
Revisit M4/S01A when you encounter older ARM32 source. On platforms that use DT_MACHINE_START, the macro declares a machine descriptor. Its dt_compat list is compared with the compatible property at the root of the device tree during early machine selection. A descriptor can serve a SoC family and supply machine-specific setup callbacks. The peripheral compatible you traced earlier is on the controller node. That string describes the peripheral interface and is read in a separate context from root machine selection.
Modern ARM64 device tree platforms use generic architecture setup and have no traditional per-board C file selected by DT_MACHINE_START. The root compatible still identifies the board and can identify its SoC. Reusable drivers and platform-specific support code still exist. For a board using an already supported controller and its providers, the board DTS is where you describe whether and how the circuit uses that controller. The distinction matters when browsing older ARM32 examples, where finding a machine descriptor can look like a required step in adding a board.
Going deeperExplore the mechanism
Before estimating a new board port, check support in the kernel revision you plan to use. Start with another board using the same SoC, if one is present. Follow its DTS includes to see whether the shared SoC description contains the controllers you need. For each controller, check the binding, the driver's supported compatibles, and the Kconfig rules. Follow the controller's required clocks, resets, pin control and power domains to their providers where applicable. Finding a controller driver establishes support for its documented interface. The provider checks establish whether the target tree can describe and control the resources that instance needs.
If those pieces exist and the differences are board wiring, the hardware-description changes can stay in board DT. For example, enabling an inherited I2C controller and describing a supported device newly wired to that bus can use existing bindings and drivers. You may still need to enable a driver in your build configuration. If the target tree supports the controller interface but lacks the shared node for a particular instance, the change may be a shared SoC DT addition using the existing binding and driver. The register and interrupt facts for that instance should then be available to other boards using the same SoC.
If the silicon requires behavior the kernel lacks, identify the exact hardware block before editing the board DTS. Suppose the controller's register interface is already supported, but its required clock comes from a new clock controller that the target tree cannot drive. The board still needs its DT description, and the missing reusable support belongs with the clock driver and its binding as applicable. A changed controller register interface can similarly require driver support and a compatible that identifies the new interface. Use an existing fallback only if the hardware actually supports the interface it promises.
Record the missing piece and check it against the tree where you intend to maintain the port. Support present in a vendor kernel and absent from your target upstream revision changes the scope of the work. The task may involve bringing in existing support or developing a reusable change with the relevant subsystem. This distinction can be made before starting the board DTS, using the source, the binding, and the hardware documentation.
Use the practice pack to trace the Raspberry Pi 4 controller from source and classify the changes a second board would need. For each conclusion, name the file or hardware fact that supports it. That gives you a short record you can review when the configuration, the board description, and the hardware seem to disagree.
The next lesson, How a driver binds and defers, follows the device and driver at runtime. It answers what happens after the kernel has the driver code and the device tree describes the hardware, including what happens when a required provider is still unavailable.
Key takeaways
- The driver match table identifies the hardware a driver supports, and Kbuild identifies the configuration symbol that builds it
- The target kernel configuration determines the effective value of a driver symbol
- SoC device trees describe shared on-chip hardware, while board device trees describe how each board uses it
- Older ARM32 platforms can match root compatibles against machine descriptors, while modern ARM64 device tree platforms use generic architecture setup
Reflect
- Explain to a colleague, in two sentences: trace a device tree compatible through a driver match table and Kbuild rule to a Kconfig symbol
- Which objective are you least sure about? Re-read that section, then do its exercise in the practice pack.
- What surprised you when you ran the commands yourself?
On a real board
Repeat the key commands on your Raspberry Pi or lab board over SSH or the serial console. Note anything that behaves differently from your PC, such as missing tools, a BusyBox shell or a read-only filesystem.
References and further reading
- Kernel documentationLinux and the Devicetree: platform identification and device population
- Kernel documentationKbuild Makefiles: object lists and composite objects
- Kernel documentationKconfig language: dependencies and tristate symbols
Official documentation first. Links checked when the lesson was published.