#device-tree #dt

no-std fdt

A pure-Rust #![no_std] crate for parsing Flattened Devicetrees

8 releases

0.2.0-alpha2 Apr 24, 2026
0.2.0-alpha1 Jan 11, 2026
0.1.5 Feb 5, 2023
0.1.4 Jul 31, 2022
0.0.1 Mar 15, 2018

#36 in Embedded development

Download history 14552/week @ 2026-04-18 12964/week @ 2026-04-25 15336/week @ 2026-05-02 19992/week @ 2026-05-09 17897/week @ 2026-05-16 20981/week @ 2026-05-23 20750/week @ 2026-05-30 20762/week @ 2026-06-06 20188/week @ 2026-06-13 20351/week @ 2026-06-20 25352/week @ 2026-06-27 28834/week @ 2026-07-04 22287/week @ 2026-07-11 27464/week @ 2026-07-18 25673/week @ 2026-07-25 27979/week @ 2026-08-01

108,516 downloads per month
Used in 9 crates (6 directly)

MPL-2.0 license

255KB
4.5K SLoC

fdt

A pure-Rust #![no_std] crate for parsing Flattened Devicetrees, with the goal of having a very ergonomic and idiomatic API.

crates.io Documentation Build

License

This crate is licensed under the Mozilla Public License 2.0 (see the LICENSE file).

Example

static MY_FDT: &[u8] = include_bytes!("../dtb/test.dtb");

fn main() {
    let fdt = fdt::Fdt::new(MY_FDT).unwrap();

    println!("This is a devicetree representation of a {}", fdt.root().model());
    println!("...which is compatible with at least: {}", fdt.root().compatible().first());
    println!("...and has {} CPU(s)", fdt.cpus().count());
    println!(
        "...and has at least one memory location at: {:#X}\n",
        fdt.memory().regions().next().unwrap().starting_address as usize
    );

    let chosen = fdt.chosen();
    if let Some(bootargs) = chosen.bootargs() {
        println!("The bootargs are: {:?}", bootargs);
    }

    if let Some(stdout) = chosen.stdout() {
        println!("It would write stdout to: {}", stdout.node().name);
    }

    let soc = fdt.find_node("/soc");
    println!("Does it have a `/soc` node? {}", if soc.is_some() { "yes" } else { "no" });
    if let Some(soc) = soc {
        println!("...and it has the following children:");
        for child in soc.children() {
            println!("    {}", child.name);
        }
    }
}

No runtime deps

Features