diff --git a/kernel/src/arch/riscv/panic.rs b/kernel/src/arch/riscv/panic.rs index 00d9ccb2a..7d44c78e7 100644 --- a/kernel/src/arch/riscv/panic.rs +++ b/kernel/src/arch/riscv/panic.rs @@ -5,24 +5,27 @@ use core::panic::PanicInfo; #[panic_handler] fn handle_panic(_arg: &PanicInfo) -> ! { println!("PANIC in PID {}: {}", crate::arch::current_pid(), _arg); - use crate::platform::precursor::lcdpanic::ErrorWriter; - use core::fmt::Write; - if let Ok(mut writer) = ErrorWriter::new() { - writeln!( - writer, - "PANIC in PID {}: {}", - crate::arch::current_pid(), - _arg - ) - .ok(); - let process = crate::arch::process::Process::current(); - writeln!(writer, "Current thread: {}", process.current_tid()).ok(); - writeln!( - writer, - "{}", - crate::arch::process::Process::current().current_thread() - ) - .ok(); + #[cfg(any(feature = "precursor", feature = "renode"))] + { + use crate::platform::precursor::lcdpanic::ErrorWriter; + use core::fmt::Write; + if let Ok(mut writer) = ErrorWriter::new() { + writeln!( + writer, + "PANIC in PID {}: {}", + crate::arch::current_pid(), + _arg + ) + .ok(); + let process = crate::arch::process::Process::current(); + writeln!(writer, "Current thread: {}", process.current_tid()).ok(); + writeln!( + writer, + "{}", + crate::arch::process::Process::current().current_thread() + ) + .ok(); + } } loop { arch::idle();