Rust crate for Flattened Devicetree parsing

LoGin 9862813020 feat(node): iter `interrupts-extended` field (#1) 7 ヶ月 前
.github d10864d039 Add various badges to README 3 年 前
dtb 2319fd3374 feat: split optional parameters from stdin- and stdout-path 1 年間 前
dts 2319fd3374 feat: split optional parameters from stdin- and stdout-path 1 年間 前
examples 2319fd3374 feat: split optional parameters from stdin- and stdout-path 1 年間 前
src 9862813020 feat(node): iter `interrupts-extended` field (#1) 7 ヶ月 前
.gitignore 152f8787d1 Initial commit 3 年 前
Cargo.toml e9755587c9 chore: Bump minor version in preparation for breaking changes 1 年間 前
LICENSE 152f8787d1 Initial commit 3 年 前
README.md 2319fd3374 feat: split optional parameters from stdin- and stdout-path 1 年間 前
rustfmt.toml 152f8787d1 Initial commit 3 年 前

README.md

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);
        }
    }
}