Skip to content

kernel::debug::fault

Raw UART0 fault reporter (bring-up diagnostics).

Writes directly to the UART0 TX FIFO that the ROM/bootloader already configured (115200 8N1), bypassing the Console/CONSOLE_UART path. This lets us report faults and boot markers even before — or instead of — our own UART init, so an early-boot crash is no longer a silent hang.

fn raw_dec(v: u32)

Print v in decimal (no allocation, no core::fmt) to UART0. For boot diagnostics printed before the logging subsystem exists.

fn raw_hex(v: u32)

Print v as 0xNNNNNNNN (8 hex digits, no allocation, no core::fmt) to UART0. For boot diagnostics printed before the logging subsystem exists.

fn raw_print(s: &str)

Print a raw marker string to UART0 (boot-progress bisection).

fn raw_uart_fault(tag: &str, cause: u32, epc: u32, ps: u32, vaddr: u32, a0: u32, a1: u32) -> !

Report a CPU exception over raw UART0 and halt. Called from the trap handler when a non-interrupt exception reaches it.

a0 and a1 are the faulting window’s return address and stack pointer. They matter more than they look: epc alone is useless the moment the fault is a jump through a null or garbage pointer, because the address it names is not code and addr2line has nothing to say about it. a0 is the call site, which is the question actually being asked — “who called this?”.

This was added the first time epc=0x00000036 appeared, which named an address in nobody’s function and left a blob-sized haystack.