libfdt-rs

Crates.iolibfdt-rs
lib.rslibfdt-rs
version0.0.2
created_at2025-07-23 03:49:18.375498+00
updated_at2025-07-23 04:34:26.200738+00
descriptionA library for handling FDT binaries based on libfdt.
homepage
repositoryhttps://github.com/rmalmain/libfdt-rs
max_upload_size
id1764332
size430,142
Romain Malmain (rmalmain)

documentation

README

libfdt-rs

libfdt-rs is a library for handling FDT binaries. It uses libfdt under the hood.

Zero-copy

As much as possible, the library avoids copying data. Nodes and properties are cheap references into the FDT binary in memory. Lifetime is property handled, avoiding some pitfalls met while manipulating FDT binaries.

Devicetree compliant

This crates aims at being compliant with the devicetree specification as much as possible.

This crate officially supports the devicetree specification v0.4.

Linux special properties

The crate handles special properties used by the Linux kernel. It makes it easy to retrieve phandle links between subnodes, as detected by the Linux kernel.

no_std compatible

The crate is fully compatible with no_std.

Example code

Here is a short example, printing all the subnodes and the properties of the root node.

use std::fs;
use libfdt_rs::Fdt;

fn main() {
    let fdt_bin = fs::read("dtb/zuma-a0-foplp.dtb").unwrap();
    let fdt = Fdt::new(fdt_bin.into_boxed_slice()).unwrap();
    let root_node = fdt.get_node("/").unwrap();

    for subnode in root_node.subnodes_iter() {
        println!("subnode:?");
    }

    for property in root_node.properties_iter() {
        println!("subnode:?");
    }
}

DTB samples

Commit count: 0

cargo fmt