#pl011 #dtb #earlycon #8250

no-std any-uart

Init early console from device tree, mostly for Arm

13 releases

Uses new Rust 2024

new 0.2.10 Apr 25, 2025
0.2.9 Apr 25, 2025
0.2.1 Mar 26, 2025
0.1.1 Mar 25, 2025

#345 in Hardware support

Download history 294/week @ 2025-03-21 450/week @ 2025-03-28 185/week @ 2025-04-04 23/week @ 2025-04-11 75/week @ 2025-04-18

803 downloads per month
Used in 2 crates (via sparreal-rt)

MIT license

19KB
512 lines

Any Uart

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 uart) = any_uart::init(NonNull::new(dtb_addr).unwrap(), phys_to_virt) {
    let mut tx = uart.tx.take().unwrap();
    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 --release -p hello --test test -- --show-output --uboot

Dependencies

~240KB