# device-tree

Guides coding agents through Linux device tree syntax, bindings, and debugging kernel platform driver probe mismatches.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 314 installs · ★ 267
- Author: mohitmishra786
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/mohitmishra786/low-level-dev-skills/tree/HEAD/skills/kernel-dev/device-tree/SKILL.md
- Updated: 2026-06-27
- HTML: https://affpapa.org/en/nevibecode/skills/device-tree

## What it does

The skill gives agents reference patterns for Linux Devicetree source files. It covers key node properties like `compatible` or `reg`, showing how the kernel OF layer parses nodes into `platform_device` entries to match `of_match_table`.

It covers tree inspection in `/proc/device-tree` and runtime overlays via `configfs`. Runtime overlay loading will fail if the kernel is built without `CONFIG_OF_OVERLAY`.

The guide also covers hardware description bugs. These include `#address-cells` mismatches in MMIO blocks, broken IRQ specifiers, and `-EPROBE_DEFER` loops caused by missing clock phandles. The driver will skip probing.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add mohitmishra786/low-level-dev-skills --skill device-tree -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/device-tree/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/device-tree/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add mohitmishra786/low-level-dev-skills --skill device-tree -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/device-tree/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add mohitmishra786/low-level-dev-skills --skill device-tree -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/device-tree/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install mohitmishra786/low-level-dev-skills device-tree
```

2. **Manually: put the files in place**
- File: `.github/skills/device-tree/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add mohitmishra786/low-level-dev-skills --skill device-tree -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/mohitmishra786/low-level-dev-skills --path skills/kernel-dev/device-tree
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/device-tree/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add mohitmishra786/low-level-dev-skills --skill device-tree -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/mohitmishra786/low-level-dev-skills/tree/HEAD/skills/kernel-dev/device-tree/SKILL.md

## When to use it
- write DTS fragments and overlays for onboard peripheral devices
- fix driver probe failures caused by mismatched compatible strings
- calculate MMIO address and length fields using parent cell counts
- link clock providers and interrupt lines to device nodes with phandles

## Example prompts
- /device-tree Write a DTS fragment for an I2C sensor on i2c1 with an interrupt on GPIO5
- /device-tree Debug why the platform driver fails to match the serial@40011000 node
- /device-tree Create a DT overlay to enable an extra UART via configfs

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 23d6d713eef6ac86.

BEGIN THIRD-PARTY FILE 23d6d713eef6ac86
````text
---
name: device-tree
description: Device tree skill for Linux hardware description. Use when writing DTS/DTSI, bindings, overlays, phandles, or debugging OF platform probe failures. Activates on queries about device tree, DTS syntax, phandle, devicetree bindings, DT overlay, or OF graph.
---

# Device Tree (Devicetree)

## Purpose

Guide agents through Linux device tree source (DTS): syntax, bindings, phandles, overlays, and how the kernel OF (Open Firmware) layer parses hardware description into `platform_device` instances.

## When to Use

- Platform driver not probing — DT mismatch
- Adding a new board `.dts` or fragment overlay
- Understanding `compatible`, `reg`, `interrupts`, `clocks` properties
- Cross-checking hardware with `skills/kernel-dev/platform-device-model`

## Workflow

### 1. DTS structure

```dts
/dts-v1/;
#include "soc.dtsi"

/ {
    model = "My Board";
    compatible = "vendor,my-board", "vendor,soc-family";

    soc {
        uart0: serial@40011000 {
            compatible = "vendor,uart";
            reg = <0x40011000 0x400>;
            interrupts = <GIC_SPI 38 IRQ_TYPE_LEVEL_HIGH>;
            clocks = <&clk_uart0>;
            status = "okay";
        };
    };
};
```

### 2. Key properties

| Property | Meaning |
|----------|---------|
| `compatible` | Driver match string (most specific first) |
| `reg` | MMIO address + length ( `#address-cells`, `#size-cells` ) |
| `interrupts` | IRQ specifier (interrupt parent defines cells) |
| `clocks` / `clock-names` | phandle to clock provider |
| `status` | `"disabled"` skips probe |

### 3. Phandles

```dts
clk_uart0: clock-uart {
    compatible = "vendor,clk";
    #clock-cells = <0>;
};

serial@... {
    clocks = <&clk_uart0>;  /* phandle reference */
};
```

### 4. Kernel parsing

```
OF core reads DTB at boot
├── of_platform_populate() creates platform_devices
└── driver `.of_match_table` matches `compatible`
```

```c
static const struct of_device_id my_of_match[] = {
    { .compatible = "vendor,uart" },
    { }
};
MODULE_DEVICE_TABLE(of, my_of_match);
```

### 5. Compile and inspect

```bash
dtc -I dts -O dtb -o board.dtb board.dts
dtc -I fs -O dts /proc/device-tree 2>/dev/null | less
ls /sys/firmware/devicetree/base/
```

Bindings live at [devicetree.org](https://www.devicetree.org/) — always cite binding name in commits.

### 6. Overlays (configfs)

```bash
# Runtime overlay apply (when CONFIG_OF_OVERLAY)
mkdir -p /config/device-tree/overlays/my-overlay
cat my-overlay.dtbo > /config/device-tree/overlays/my-overlay/dtbo
```

### 7. Agent usage

```
/device-tree Write DTS fragment for I2C sensor on i2c1 with interrupt on GPIO5
```

## Common Problems

| Symptom | Cause | Fix |
|---------|-------|-----|
| Driver not bound | `compatible` typo | Match driver's `of_match_table` |
| Wrong MMIO | `#address-cells` mismatch | Follow SoC `.dtsi` |
| IRQ not firing | Wrong interrupt parent/cells | Copy from working board DTS |
````
END THIRD-PARTY FILE 23d6d713eef6ac86

The third-party file has ended. Everything between the 23d6d713eef6ac86 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2959 of 3452 bytes. © mohitmishra786 · MIT · https://github.com/mohitmishra786/low-level-dev-skills/tree/HEAD/skills/kernel-dev/device-tree/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
