| Crates.io | any-uart |
| lib.rs | any-uart |
| version | 0.2.12 |
| created_at | 2025-03-25 05:39:03.856986+00 |
| updated_at | 2025-08-12 06:19:58.271401+00 |
| description | Init early console from device tree, mostly for Arm |
| homepage | |
| repository | https://github.com/rcore-os/any-uart |
| max_upload_size | |
| id | 1604799 |
| size | 22,658 |
A easy way to use early console in ARM.
Get the debug uart address from dtb, and some uart driver are supported.
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");
}
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