Skip to main content

Static analysis tool that catches hardware-level bugs in Linux Device Tree Source (DTS) files

Project description

socc — SoC Device-Tree Consistency Checker

PyPI Python License: MIT

socc is a static-analysis tool that catches hardware-level bugs in Linux Device Tree Source (DTS) files — the kind that pass dtc and dt-schema validation but still destroy your board at runtime.

If you have ever spent a week chasing a suspend-resume panic caused by a wrong power-supply phandle, or a silent DMA hang caused by a copy-pasted channel index that exceeded the controller's physical limit, socc is for you.

$ socc check board.dts --soc rk3588
[FATAL]  PD-001  Power domain crossing — /soc/i2c@fe2b0000 uses vcc_3v3 (EE domain)
                  but is connected to vcc_1v8 (AO domain). System will panic on suspend.
[ERROR]  CK-003  Clock rate mismatch — spi0 requests 50 MHz from pll_cpll (max 24 MHz).
[WARN]   GP-002  GPIO conflict — gpio1_b3 assigned to both spi0 and uart2.

Table of Contents


Why socc?

Tool What it checks
dtc DTS syntax
dt-schema / dtbs_check Property types and required fields per binding
socc Whether the system is physically and electrically correct

socc operates on the semantic level: it builds an in-memory model of your power tree, clock tree, pin-mux table, and interrupt routing, then runs cross-domain constraint rules that no schema can express.

Real bugs socc catches:

Bug class Example Runtime effect
Power domain crossing AO peripheral on EE supply Suspend-resume panic
Clock rate mismatch SPI clock > PLL maximum Bus hangs, data corruption
GPIO pin conflict Two nodes mapped to same pad Silent last-write-wins
MMIO region overlap Two drivers ioremap same address Kernel memory corruption
GPIO index out of bounds gpio1 pin 35 on a 32-pin bank Kernel panic at driver probe
IRQ collision Two devices share GIC SPI 45 -EBUSY or interrupt storm
DMA channel out of bounds Channel 48 on 32-channel DMA Silent DMA failure
Power/clock cycle Regulator A requires B requires A Kernel deadlock at boot
Zombie DTS nodes 14 disabled camera nodes in BSP Bloated DTB, slow boot
Allwinner 3.3V on 1.8V IO Wrong PMIC rail to PC bank Permanent IO pad damage

Installation

pip install soc-consistency

Or install from source with development extras:

git clone https://github.com/gahingwoo/SoC-Consistency.git
cd SoC-Consistency
pip install -e ".[dev]"

Requirements: Python 3.8+, PyYAML, Click 8.0+


Quick start

# Run all rules against a DTS file
socc check board.dts --soc rk3588

# Auto-fix safe violations and write a patch
socc fix board.dts --soc rk3588 -o board.patch

# Semantic diff between two DTS / DTB files
socc smart-diff vendor.dts mainline.dts

# ── analyze group ──────────────────────────────────────────────────────────
socc analyze gc board.dts --soc rk3588          # zombie-node garbage collector
socc analyze memory board.dts                   # MMIO overlap scan
socc analyze bounds board.dts --soc rk3588      # GPIO/DMA/PWM out-of-bounds
socc analyze irq board.dts                      # IRQ collision check
socc analyze deps board.dts                     # power/clock cycle detection

# ── audit group ────────────────────────────────────────────────────────────
socc audit bindings board.dts                   # DTS binding audit
socc audit bom board.dts hardware.csv           # BOM cross-check
socc audit kernel board.dts --kernel /path/to/kernel  # kernel config audit

# ── viz group ─────────────────────────────────────────────────────────────
socc viz topology board.dts --soc rk3588        # HTML topology graph
socc viz pinmap rk3588                          # BGA pin heatmap
socc viz power-seq board.dts                    # power-rail sequencing chart

# ── sim group ─────────────────────────────────────────────────────────────
socc sim failure vcc_3v3 board.dts --soc rk3588 # FMEA blast radius
socc sim shell board.dts --soc rk3588           # interactive simulator
socc sim live-check board.dts --host 192.168.1.1 # live-board SSH audit

Commands

Top-level

Command Description
socc check Run all rules — output violations by severity
socc fix Auto-generate a DTS patch for safe-to-fix violations
socc autofix Apply fixes in-place
socc diff Show violations introduced between two DTS versions
socc smart-diff Semantic DTS/DTB diff (ignores labels/phandles/ordering)
socc explain Explain a rule code in plain English with fix examples
socc rules List all enabled rules with IDs and descriptions
socc init Create a .socc.yaml config scaffold
socc version Print version and environment information
socc self-update Upgrade to the latest release from PyPI

socc check options

socc check board.dts --soc rk3588 \
     --min-severity warning \
     --format json \
     -o report.json
Option Description
--soc Target SoC (rk3588, sun50i-h616, imx8mp, …)
--min-severity Filter: info | warning | error | fatal
--format Output: text (default) | json | html | sarif
--netlist Cross-check against a KiCad or CSV netlist
--enable / --disable Toggle specific rule codes
-o Write output to file

socc audit — compatibility & BOM

socc audit COMMAND [OPTIONS] ...
Subcommand Old flat name Description
socc audit bindings socc audit DTS binding audit against mainline kernel
socc audit bom socc audit-bom Cross-check BOM CSV against DTS peripherals
socc audit kernel socc audit-kernel Validate DTS-enabled devices against kernel config
socc audit amp socc amp-audit AMP (Linux + RTOS) resource conflict detection
socc audit matrix socc matrix-audit Multi-SKU supply-chain variant matrix audit
socc audit cross-check socc cross-check Bootloader vs. kernel DTS skew detection
socc audit overlay socc overlay-check Validate a DT overlay against its base DTS
socc audit netlist socc crosscheck Cross-validate DTS pinctrl against PCB netlist

socc analyze — static analysis

socc analyze COMMAND [OPTIONS] DTS_FILE
Subcommand Old flat name Description
socc analyze memory socc check-memory Sweep-line MMIO overlap scanner
socc analyze deps socc check-deps Power/clock dependency cycle detector
socc analyze bounds socc check-bounds GPIO/DMA/PWM physical-bounds auditor
socc analyze irq socc check-irq IRQ collision and reserved-PPI checker
socc analyze gc socc gc Zombie-node garbage collector

socc analyze gc

Vendor BSPs ship Device Trees with dozens of disabled nodes for unsupported board variants. gc identifies unreferenced dead-code nodes and estimates DTB savings.

socc analyze gc rockchip-rk3588-evb.dts
SOCC DTS ZOMBIE-NODE GARBAGE COLLECTOR
  Alive nodes   : 47
  Zombie nodes  : 14
  Est. DTB savings: 8732 bytes (~8.5 KiB)

socc analyze bounds

Catches copy-paste GPIO/DMA/PWM index errors that compile fine but panic at driver probe:

socc analyze bounds board.dts --soc rk3588
[FATAL] BND-001  /leds/user-led1
    gpios = ['&gpio4', 35, 0]  — pin 35 is out of range for gpio4 (max: 31)

socc analyze irq

Detects two active devices sharing the same non-shared GIC SPI line:

socc analyze irq board.dts
[CRITICAL] IRQ-C01  GIC SPI IRQ 45 claimed by spi0 and uart0 simultaneously.

socc analyze memory

O(n log n) sweep-line detects every class of reg address-space collision:

Rule Description
MM-001 Identical window — duplicate node
MM-002 Full containment — one region inside another
MM-003 Partial overlap — silent memory corruption
MM-004 Zero-size region
MM-005 Suspiciously large region (> 512 MiB)

socc analyze deps

Builds directed power/clock graphs and runs DFS cycle detection:

Rule Description
DG-CP01 Cycle in power dependency graph — kernel deadlock at boot
DG-CK01 Cycle in clock dependency graph
DG-OP01 Regulator references non-existent parent rail
DG-OK01 Clock references non-existent parent

socc generate — artifacts

socc generate COMMAND [OPTIONS] DTS_FILE
Subcommand Old flat name Description
socc generate qemu socc generate-qemu QEMU launch script or C machine skeleton
socc generate tests socc generate-tests Bash bring-up test script
socc generate saleae socc generate-saleae Saleae Logic 2 workspace JSON
socc generate headers socc export-headers Bare-metal C peripheral address header
socc generate diagram socc generate-diagram Mermaid / PlantUML / ASCII topology diagram
socc generate compliance socc generate-compliance ISO 26262 / IEC 61508 functional-safety report
socc generate report socc generate-report Self-contained HTML architecture report

socc viz — visualization

socc viz COMMAND [OPTIONS]
Subcommand Old flat name Description
socc viz topology socc topology Interactive HTML hardware topology graph
socc viz pinmap socc pinmap HTML BGA pin heatmap for a SoC
socc viz power-seq socc power-seq ASCII power-rail startup sequence chart

socc sim — simulation & live-board

socc sim COMMAND [OPTIONS]
Subcommand Old flat name Description
socc sim failure socc simulate failure FMEA blast-radius simulation
socc sim smoke socc simulate-smoke Physical-damage risk from DTS config errors
socc sim shell socc shell Interactive power/clock state-machine shell
socc sim live-check socc live-check SSH into a board and run consistency checks
socc sim live-probe socc live-probe Compare DTS expectations vs. physical registers
socc sim trace socc trace Trace how a node's properties change across overlays
socc sim migrate socc migrate Assist in porting a DTS to a new target SoC

socc socdef — constraint files

socc socdef COMMAND [OPTIONS]
Subcommand Old flat name Description
socc socdef validate socc validate-socdef Validate a .socdef file
socc socdef check socc check-socdef Check a DTS against a .socdef constraint file
socc socdef init socc init-socdef Generate a .socdef template for a new SoC

Supported SoCs

socc ships vendor-specific rule packs that know the hardware limits, domain topology, and common pitfalls of each family.

Vendor SoC families Notes
Rockchip RK3399, RK3568, RK3576, RK3588, RK3588S GPIO banks, power domains, CRU
Allwinner H616, H618, T507, A527 AXP PMIC sequences, 1.8V IO banks
NXP i.MX8M Plus, i.MX8M Mini CCM, IOMUXC, power gating
Qualcomm SDM845, SM8550 GCC node dependency
Generic any ARM/ARM64 GIC, GPIO, DMA, PWM, IRQ rules

Adding a new SoC requires only a YAML hardware-constraint file:

# data/soc/rockchip/rk3588.yaml
name: rk3588
hardware_limits:
  gpio0: {pins: 32}
  gpio4: {pins: 32}
  dmac0: {channels: 32}
  pwm:   {channels: 16}
power_domains:
  - name: vcc_5v0
    children: [vcc_3v3, vcc_1v8]

CI / CD integration

Drop socc into any pipeline:

# GitHub Actions
- name: Check DTS consistency
  run: |
    pip install soc-consistency
    socc check board.dts --soc rk3588 --min-severity error --format sarif -o socc.sarif

socc exits 0 on success, non-zero when violations at or above --min-severity are found.

A ready-made GitHub Actions workflow with OIDC Trusted Publishing is included at .github/workflows/publish.yml.


Upgrading from pre-1.1

All flat command names continue to work unchanged (they are registered as hidden aliases). No scripts need to be updated.

Pre-1.1 command 1.1+ equivalent
socc gc socc analyze gc
socc check-memory socc analyze memory
socc check-bounds socc analyze bounds
socc check-irq socc analyze irq
socc check-deps socc analyze deps
socc audit socc audit bindings
socc audit-bom socc audit bom
socc amp-audit socc audit amp
socc cross-check socc audit cross-check
socc generate-qemu socc generate qemu
socc generate-diagram socc generate diagram
socc export-headers socc generate headers
socc topology socc viz topology
socc pinmap socc viz pinmap
socc power-seq socc viz power-seq
socc shell socc sim shell
socc live-check socc sim live-check
socc simulate-smoke socc sim smoke
socc simulate failure NODE DTS socc sim failure NODE DTS
socc migrate socc sim migrate
socc validate-socdef socc socdef validate
socc check-socdef socc socdef check

Rules reference

Run socc rules to list all active rules. The full reference is in docs/rules.md.

Quick overview by domain:

Prefix Domain
PD- Power domain integrity
CK- Clock tree consistency
GP- GPIO pin-mux conflicts
MM- MMIO address-map overlaps
BND- Physical resource bounds
IRQ- Interrupt routing
DG- Dependency graph cycles
TH- Thermal zone configuration
BW- Bus bandwidth budget
SEC- Security / TrustZone constraints

Architecture

socc/
├── commands/          CLI command packages (new in 1.1)
│   ├── core.py        Top-level commands: check, fix, rules, diff, …
│   ├── audit_cmds.py  socc audit  — bindings, bom, kernel, amp, …
│   ├── analyze_cmds.py socc analyze — memory, bounds, irq, deps, gc
│   ├── generate_cmds.py socc generate — qemu, headers, diagram, …
│   ├── viz_cmds.py    socc viz    — topology, pinmap, power-seq
│   ├── sim_cmds.py    socc sim    — failure, smoke, shell, live-check, …
│   ├── socdef_cmds.py socc socdef — validate, check, init
│   └── _shared.py     Shared helpers: SoC lists, registry, helpers
├── parser/            DTS → IR model (tokenizer + parser + mapper)
├── model/             Dataclasses: SoC, PowerTree, ClockTree, IRNode
├── rules/             Rule registry + vendor rule packs
│   ├── common/        GIC, GPIO, DMA, MMIO rules
│   └── rockchip/      Rockchip-specific power/clock/bus rules
├── engine/            Rule executor + violation aggregator
├── memmap.py          MMIO sweep-line overlap scanner
├── depgraph.py        Power/clock cycle detector (DFS)
├── smartdiff.py       Semantic DTS/DTB differ
├── gc.py              Zombie-node garbage collector
├── bounds.py          Physical resource bounds auditor
├── irqcheck.py        IRQ collision & routing checker
├── autofix.py         DTS patch generator
├── report.py          HTML report renderer
└── cli.py             Click group assembler (152 lines) + backward aliases

The IR model is intentionally decoupled from the parser: you can load a SoC model from a DTS file, a YAML hardware description, or build one programmatically for testing.


Contributing

git clone https://github.com/gahingwoo/SoC-Consistency.git
cd SoC-Consistency
pip install -e ".[dev]"
pytest tests/ -q

Rule contributions are welcome. Each rule is a single Python class inheriting BaseRule; see docs/development.md for the five-minute guide.


License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

soc_consistency-1.1.0.tar.gz (222.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

soc_consistency-1.1.0-py3-none-any.whl (272.0 kB view details)

Uploaded Python 3

File details

Details for the file soc_consistency-1.1.0.tar.gz.

File metadata

  • Download URL: soc_consistency-1.1.0.tar.gz
  • Upload date:
  • Size: 222.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for soc_consistency-1.1.0.tar.gz
Algorithm Hash digest
SHA256 df0535f688aa473e7ea8efa39287b3ec34f7e7ffdf6624d342ac2595f3de0066
MD5 29ac770d8f04feaa350ef6cd6eaed9a3
BLAKE2b-256 22035c8cf4730bf7a1f984ec92611897e25888622729eb27329723567f5fdb95

See more details on using hashes here.

Provenance

The following attestation bundles were made for soc_consistency-1.1.0.tar.gz:

Publisher: publish.yml on gahingwoo/SoC-Consistency

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file soc_consistency-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: soc_consistency-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 272.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for soc_consistency-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5765b58a489dddc05ae4d9c7b5449f9089f8079290dc0ea689ec2071e401895d
MD5 13c158e59df7f82668fded4c7feec864
BLAKE2b-256 f92da9565fc3bb8d7aeab498e559d70f2b0e5fa67dec667883df5b2f65c2ec90

See more details on using hashes here.

Provenance

The following attestation bundles were made for soc_consistency-1.1.0-py3-none-any.whl:

Publisher: publish.yml on gahingwoo/SoC-Consistency

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page