From b49fb841ced196ed7e64bfe0cd8d6450711c0d01 Mon Sep 17 00:00:00 2001 From: linuswck Date: Tue, 5 Sep 2023 14:46:31 +0800 Subject: [PATCH] Firmware: EFC enables error led when going panic --- artiq/firmware/satman/main.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/artiq/firmware/satman/main.rs b/artiq/firmware/satman/main.rs index 7c28df457..35d2922ee 100644 --- a/artiq/firmware/satman/main.rs +++ b/artiq/firmware/satman/main.rs @@ -656,6 +656,24 @@ pub extern fn main() -> i32 { } } +#[cfg(soc_platform = "efc")] +fn enable_error_led() { + let mut io_expander = board_misoc::io_expander::IoExpander::new().unwrap(); + + // Keep LEDs enabled + io_expander.set_oe(0, 1 << 5 | 1 << 6 | 1 << 7).unwrap(); + // Enable Error LED + io_expander.set(0, 7, true); + + // Keep VADJ and P3V3_FMC enabled + io_expander.set_oe(1, 1 << 0 | 1 << 1).unwrap(); + + io_expander.set(1, 0, true); + io_expander.set(1, 1, true); + + io_expander.service().unwrap(); +} + #[no_mangle] pub extern fn exception(_regs: *const u32) { let pc = mepc::read(); @@ -695,8 +713,16 @@ pub fn panic_fmt(info: &core::panic::PanicInfo) -> ! { if let Some(location) = info.location() { print!("panic at {}:{}:{}", location.file(), location.line(), location.column()); + #[cfg(soc_platform = "efc")] + { + if location.file() != "libboard_misoc/io_expander.rs" { + enable_error_led(); + } + } } else { print!("panic at unknown location"); + #[cfg(soc_platform = "efc")] + enable_error_led(); } if let Some(message) = info.message() { println!(": {}", message);