FDT Parser
A pure Rust, #![no_std]
Flattened Device Tree (FDT) parser library based on devicetree-specification-v0.4.
Features
- [√] Parse device tree blob - Complete FDT structure parsing
- [√] Dual parsing implementations - Direct (
base
) and cached (cache
) parsing modes - [√] Memory reservation handling - Parse memory reservation blocks
- [√] Register address translation - Fix
reg
addresses byrange
properties - [√] Interrupt handling - Find interrupt parents and parse interrupt specifications
- [√] Clock binding support - Parse clock providers and consumers
- [√] Alias resolution - Handle path aliases
- [√] PCI bus support - Specialized PCI host bridge parsing
- [√] Property access - Full access to all node properties with type-safe helpers
- [√] Node traversal - Hierarchical node navigation and search
- [√] Compatible matching - Find nodes by compatible strings
- [√] No-std compatible - Works in embedded environments with
alloc
Architecture
The library provides two parsing approaches:
Base Parser (base
module)
Direct parsing approach that walks the FDT structure on-demand. Uses lifetimes to avoid data copying and is memory efficient for single-pass operations.
Cached Parser (cache
module)
Builds an indexed representation for faster repeated lookups. Copies data into owned structures but provides O(1) access for many operations after initial parsing.
Usage
Basic Usage (Cached Parser)
use Fdt;
let bytes = include_bytes!;
let fdt = from_bytes.unwrap;
println!;
// Access memory reservation blocks
for region in fdt.memory_reservation_blocks
// Traverse all nodes
for node in fdt.all_nodes
Advanced Usage
use Fdt;
let fdt = from_bytes.unwrap;
// Find nodes by path
let memory_nodes = fdt.find_nodes;
for node in memory_nodes
// Find nodes by compatible strings
let uart_devices = fdt.find_compatible;
for uart in uart_devices
// Access chosen node properties
if let Some = fdt.get_node_by_path
// Use aliases to find nodes
let serial = fdt.find_aliase
.and_then;
if let Some = serial
Property Access
use Fdt;
let fdt = from_bytes.unwrap;
let node = fdt.get_node_by_path.unwrap;
// Access specific properties
if let Some = node.find_property
// String list properties
if let Some = node.find_property
// Raw data access
if let Some = node.find_property
API Documentation
For comprehensive API documentation, see docs.rs/fdt-parser.
License
Licensed under the MPL-2.0 license. See LICENSE for details.