mohitmishra786/low-level-dev-skills

device-tree

Device tree skill for Linux hardware description.

Vedi sorgente
Documento Skill originale

Contenuto dal repository con titoli, esempi, codice, tabelle, link e immagini preservati.

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

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

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 — 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

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
dallo stesso repository

Altri Skills

Tutti gli Skills
mohitmishra786
Community

static-analysis

Static analysis skill for C/C++ codebases. Use when hardening code quality, triaging noisy builds, running clang-tidy, cppcheck, or scan-build, interpreting check categories, suppressing false positives, or integrating static analysis into CI. Activates on queries about clang-tidy checks, cppcheck, scan-build, compilecommands.json, code hardening, or static analysis warnings.

installazioni
1
GitHub Stars
263
Aggiornato
27 giu
mohitmishra786
Community

assembly-x86

x86-64 assembly skill for reading, writing, and debugging assembly code. Use when reading GCC/Clang assembly output, writing inline asm in C/C++, understanding the System V AMD64 ABI calling convention, or debugging register and stack state. Activates on queries about x86-64 assembly, AT&T vs Intel syntax, inline asm, calling conventions, SIMD intrinsics, or reading disassembly output from objdump or GDB.

installazioni
1
GitHub Stars
258
Aggiornato
27 giu
mohitmishra786
Community

cpp-modules

C++20 modules skill for modern C++ projects. Use when working with named modules, module partitions, header units, CMake MODULESOURCES, Clang -fmodules-ts, BMI caching issues, or migrating from headers to modules. Activates on queries about C++20 modules, import statements, module interface units, header units, or BMI files.

installazioni
1
GitHub Stars
258
Aggiornato
27 giu
mohitmishra786
Community

gcc

GCC compiler skill for C/C++ projects. Use when selecting optimization levels, warning flags, debug builds, LTO, sanitizer instrumentation, or diagnosing compilation errors with GCC. Covers flag selection for debug vs release, ABI concerns, preprocessor macros, profile-guided optimization, and integration with build systems. Activates on queries about gcc flags, compilation errors, performance tuning, warning suppression, or cross-standard compilation.

installazioni
1
GitHub Stars
258
Aggiornato
27 giu