20 unstable releases (3 breaking)

new 0.4.2 Dec 5, 2024
0.4.1 Nov 16, 2024
0.3.11 Nov 14, 2024
0.3.8 Oct 31, 2024
0.1.0 Oct 18, 2024

#275 in Embedded development

Download history 103/week @ 2024-10-12 321/week @ 2024-10-19 1422/week @ 2024-10-26 375/week @ 2024-11-02 140/week @ 2024-11-09 257/week @ 2024-11-16 52/week @ 2024-11-23 144/week @ 2024-11-30

611 downloads per month
Used in 5 crates (2 directly)

MPL-2.0 license

44KB
1K SLoC

FDT Parser

Build & Check CI Latest version Documentation License

Base on devicetree-specification-v0.4

Advance features

  • Parse device tree blob
  • Fix reg address by range
  • Find interrupt parent
  • Find clocks
  • Handle aliases
  • PCI bus

Usage

use fdt_parser::Fdt;

let bytes = include_bytes!("../../dtb/bcm2711-rpi-4-b.dtb");

let fdt = Fdt::from_bytes(bytes).unwrap();
println!("version: {}", fdt.version());
for region in fdt.memory_reservation_block() {
    println!("region: {:?}", region);
}

for node in fdt.all_nodes() {
    let space = " ".repeat((node.level - 1) * 4);
    println!("{}{}", space, node.name());

    if let Some(cap) = node.compatible() {
        println!("{} -compatible: ", space);
        for cap in cap {
            println!("{}     {:?}", space, cap);
        }
    }

    if let Some(reg) = node.reg() {
        println!("{} - reg: ", space);
        for cell in reg {
            println!("{}     {:?}", space, cell);
        }
    }
}

No runtime deps