From b83afedf43c405917d1f3b1639d317c4aad4540f Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Thu, 7 May 2020 19:06:10 +0800 Subject: [PATCH] kasli: light up ERROR LED on panic --- artiq/firmware/bootloader/main.rs | 5 +++++ artiq/firmware/runtime/main.rs | 5 +++++ artiq/firmware/satman/main.rs | 5 +++++ artiq/gateware/targets/kasli.py | 7 ++++--- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/artiq/firmware/bootloader/main.rs b/artiq/firmware/bootloader/main.rs index 39cf81c40..c698dee78 100644 --- a/artiq/firmware/bootloader/main.rs +++ b/artiq/firmware/bootloader/main.rs @@ -530,6 +530,11 @@ pub extern fn abort() { #[no_mangle] // https://github.com/rust-lang/rust/issues/{38281,51647} #[panic_implementation] pub fn panic_fmt(info: &core::panic::PanicInfo) -> ! { + #[cfg(has_error_led)] + unsafe { + board_misoc::csr::error_led::out_write(1); + } + if let Some(location) = info.location() { print!("panic at {}:{}:{}", location.file(), location.line(), location.column()); } else { diff --git a/artiq/firmware/runtime/main.rs b/artiq/firmware/runtime/main.rs index 3fc931032..b40c0d097 100644 --- a/artiq/firmware/runtime/main.rs +++ b/artiq/firmware/runtime/main.rs @@ -298,6 +298,11 @@ pub fn oom(layout: core::alloc::Layout) -> ! { pub fn panic_impl(info: &core::panic::PanicInfo) -> ! { irq::set_ie(false); + #[cfg(has_error_led)] + unsafe { + csr::error_led::out_write(1); + } + if let Some(location) = info.location() { print!("panic at {}:{}:{}", location.file(), location.line(), location.column()); } else { diff --git a/artiq/firmware/satman/main.rs b/artiq/firmware/satman/main.rs index c3a9b05d9..cb10671c6 100644 --- a/artiq/firmware/satman/main.rs +++ b/artiq/firmware/satman/main.rs @@ -648,6 +648,11 @@ pub extern fn abort() { #[no_mangle] // https://github.com/rust-lang/rust/issues/{38281,51647} #[panic_implementation] pub fn panic_fmt(info: &core::panic::PanicInfo) -> ! { + #[cfg(has_error_led)] + unsafe { + csr::error_led::out_write(1); + } + if let Some(location) = info.location() { print!("panic at {}:{}:{}", location.file(), location.line(), location.column()); } else { diff --git a/artiq/gateware/targets/kasli.py b/artiq/gateware/targets/kasli.py index 0957fcfe4..d9e09c783 100755 --- a/artiq/gateware/targets/kasli.py +++ b/artiq/gateware/targets/kasli.py @@ -110,9 +110,10 @@ class StandaloneBase(MiniSoC, AMPSoC): AMPSoC.__init__(self) add_identifier(self) - self.submodules.leds = gpio.GPIOOut(Cat( - self.platform.request("user_led", 0))) - self.csr_devices.append("leds") + if self.platform.hw_rev == "v2.0": + self.submodules.error_led = gpio.GPIOOut(Cat( + self.platform.request("error_led"))) + self.csr_devices.append("error_led") i2c = self.platform.request("i2c") self.submodules.i2c = gpio.GPIOTristate([i2c.scl, i2c.sda])