mcpField
D
device-tree

device-tree

github.com/mohitmishra786Development269326 installsUpdated 18w ago
Repository

About device-tree

device-tree is a skill for agents working with Linux device tree source (DTS). It covers syntax, kernel parsing, overlays, compilation, and troubleshooting hardware-description mismatches.

Key features

  1. 01DTS 结构与关键属性
  2. 02phandle 与设备引用
  3. 03内核 OF 解析流程
  4. 04DTS 编译与检查
  5. 05配置文件系统叠加层
  6. 06常见探测问题排查

Use cases

  1. 01为新板卡编写 DTS
  2. 02排查驱动未绑定或未探测
  3. 03检查中断、时钟和 MMIO 配置

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/mohitmishra786/low-level-dev-skills --skill device-tree

After installing, type/device-treein Claude Code to confirm it loaded.

Details

From the project README

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-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
PropertyMeaning
compatibleDriver match string (most specific first)
regMMIO address + length ( #address-cells, #size-cells )
interruptsIRQ specifier (interrupt parent defines cells)
clocks / clock-namesphandle to clock provider
status"disabled" skips probe
3. Phandles
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`
static const struct of_device_id my_of_match[] = {
    { .compatible = "vendor,uart" },
    { }
};
MODULE_DEVICE_TABLE(of, my_of_match);
5. Compile and inspect
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 — always cite binding name in commits.

6. Overlays (configfs)
# 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

SymptomCauseFix
Driver not boundcompatible typoMatch driver's of_match_table
Wrong MMIO#address-cells mismatchFollow SoC .dtsi
IRQ not firingWrong interrupt parent/cellsCopy from working board DTS
Probe defer loopClock/regulator missing-EPROBE_DEFER supplier in DT
Overlay failsSymbol unresolved__fixups__ / label exports

Related Skills

  • skills/kernel-dev/platform-device-model — probe and sysfs
  • skills/kernel/device-drivers — devm_of_iomap
  • skills/baremetal/datasheet-and-refmanual-reading — HW to DT mapping
  • skills/embedded/zephyr — Zephyr devicetree (different tooling)
  • skills/kernel-dev/bus-drivers-i2c-spi — bus node children

Comments

Markdown supported