#dtb #pl011 #arm #debugging #no-std #earlycon

no-std dtb-early-console

Init early console from device tree, mostly for Arm

1 unstable release

Uses new Rust 2024

new 0.1.0 Mar 19, 2025

#1648 in Embedded development

MIT license

12KB
288 lines

DTB Early console

Check, Build and Test

A easy way to use early console in ARM.

Get the debug uart address from dtb, and some uart driver are supported.

supported uart

  • 8250 and 16550
  • pl011
  • aux_mini (raspi 4b)

example

use core::ptr::NonNull;

// your dtb address
let dtb_addr = 0usize as *mut u8

fn phys_to_virt(addr: usize) -> *mut u8 { 
    // phys addr to virt addr logic
    addr as *mut u8
}

if let Some((mut tx, _rx)) = dtb_early_console::init(NonNull::new(dtb_addr).unwrap(), phys_to_virt) {
    let _ = tx.write_str_blocking("Hello, world!\n");
}

test

cargo install ostool
# test with qemu
cargo test -p hello --test test -- --show-output
# test with uboot
cargo test -p hello --test test -- --show-output --uboot

Dependencies

~135KB