Registry / data / pydevicetree

pydevicetree

JSON →
library0.0.13pypypi✓ verified 86d ago

A Python library for parsing and manipulating Devicetree Source v1 (DTS) files. Current version 0.0.13, released on 2026-01-12. Maintained primarily by SiFive; releases are infrequent with minor fixes and improvements.

pip install pydevicetree
INSTALL
IMPORT
SIG · PYDEVICETREE
P
pydevicetree
datapythonv0.0.13
Install
1.7s avg
Import
15ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.0.13 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.014s · 18.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.7s · import 0.016s · 19MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Devicetree
from pydevicetree import Devicetree
Main class for representing an entire devicetree.
Node
from pydevicetree import Node
Represents a single node in the tree.
PropertyValue
from pydevicetree import PropertyValue
Base class for property values.
RegArray
from pydevicetree import RegArray
Represents the 'reg' property array.
RangeArray
from pydevicetree import RangeArray
Represents the 'ranges' property array.

Parse a DTS string, access properties, and manipulate nodes.

from pydevicetree import Devicetree, Node # Parse a DTS file from string dts_text = """/dts-v1/; / { compatible = "example,board"; memory@80000000 { device_type = "memory"; reg = <0x0 0x80000000 0x0 0x40000000>; }; }; """ tree = Devicetree.from_dts(dts_text) print(tree.root.compatible) # 'example,board' mem_node = tree.root.children['memory@80000000'] print(mem_node.reg) # RegArray(...) # Create and add a new node new_node = Node('serial@10000000', parent=tree.root) new_node.add_property('compatible', 'ns16550') tree.root.add_child(new_node) print(tree.to_dts())
Debug
Known issues
gotchaProperty names in DTS are case-sensitive. Ensure exact case when accessing via node.properties dict.
fix
Use the exact name as in the DTS source, e.g., node.properties['compatible'] not 'Compatible'.
affects: >=0.0.1
gotchaThe 'reg' property is returned as a RegArray object, not a raw list. Convert using .as_size_address_pairs() or .get_reg_tuple().
fix
Use reg_array.as_size_address_pairs() to get list of (address, size) tuples.
affects: >=0.0.6
breakingIn v0.0.12, merging nodes now reparents children. If you manually assign child nodes to multiple parents, they may be moved unexpectedly.
fix
Ensure each child node has only one parent, or use deep copies before merging.
affects: >=0.0.12
gotchaThe library only supports DTS v1. Using /dts-v1/; header is required; older styles are not parsed.
fix
Ensure DTS input starts with '/dts-v1/;'.
affects: >=0.0.1
Errors
Common errors & fixes
pydevicetree.exceptions.ParseException: Expected <class 'pydevicetree.parser.Parser'>
Invalid DTS syntax or missing /dts-v1/; header.
fix
Check your DTS input for syntax errors and ensure it starts with '/dts-v1/;'.
AttributeError: 'str' object has no attribute 'value'
Trying to access .value on a property that is not a PropertyValue object (e.g., string property).
fix
Use node.properties['propname'].value for PropertyValue; for plain strings, use node.properties['propname'] directly (it is already a string).
KeyError: 'compatible'
Accessing a property that does not exist on the node.
fix
Check if the property exists: if 'compatible' in node.properties: ...
ImportError: cannot import name 'Devicetree' from 'pydevicetree'
Installed an older version (<0.0.3) where Devicetree was not exposed at top level.
fix
Upgrade to latest: pip install --upgrade pydevicetree
Upgrade
Version history
0.0.13latest on PyPI · released Jul 21, 2023
Audit
Dependencies
pyparsingrequiredUsed internally for parsing DTS text.
Agent activity
5 hits · last 30 days
node
4
Resources
pydevicetree — pip install pydevicetree · libregistry