forked from M-Labs/artiq
1
0
Fork 0

kasli: light up ERROR LED on panic

This commit is contained in:
Sebastien Bourdeauducq 2020-05-07 19:06:10 +08:00
parent 4982fde898
commit b83afedf43
4 changed files with 19 additions and 3 deletions

View File

@ -530,6 +530,11 @@ pub extern fn abort() {
#[no_mangle] // https://github.com/rust-lang/rust/issues/{38281,51647} #[no_mangle] // https://github.com/rust-lang/rust/issues/{38281,51647}
#[panic_implementation] #[panic_implementation]
pub fn panic_fmt(info: &core::panic::PanicInfo) -> ! { 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() { if let Some(location) = info.location() {
print!("panic at {}:{}:{}", location.file(), location.line(), location.column()); print!("panic at {}:{}:{}", location.file(), location.line(), location.column());
} else { } else {

View File

@ -298,6 +298,11 @@ pub fn oom(layout: core::alloc::Layout) -> ! {
pub fn panic_impl(info: &core::panic::PanicInfo) -> ! { pub fn panic_impl(info: &core::panic::PanicInfo) -> ! {
irq::set_ie(false); irq::set_ie(false);
#[cfg(has_error_led)]
unsafe {
csr::error_led::out_write(1);
}
if let Some(location) = info.location() { if let Some(location) = info.location() {
print!("panic at {}:{}:{}", location.file(), location.line(), location.column()); print!("panic at {}:{}:{}", location.file(), location.line(), location.column());
} else { } else {

View File

@ -648,6 +648,11 @@ pub extern fn abort() {
#[no_mangle] // https://github.com/rust-lang/rust/issues/{38281,51647} #[no_mangle] // https://github.com/rust-lang/rust/issues/{38281,51647}
#[panic_implementation] #[panic_implementation]
pub fn panic_fmt(info: &core::panic::PanicInfo) -> ! { 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() { if let Some(location) = info.location() {
print!("panic at {}:{}:{}", location.file(), location.line(), location.column()); print!("panic at {}:{}:{}", location.file(), location.line(), location.column());
} else { } else {

View File

@ -110,9 +110,10 @@ class StandaloneBase(MiniSoC, AMPSoC):
AMPSoC.__init__(self) AMPSoC.__init__(self)
add_identifier(self) add_identifier(self)
self.submodules.leds = gpio.GPIOOut(Cat( if self.platform.hw_rev == "v2.0":
self.platform.request("user_led", 0))) self.submodules.error_led = gpio.GPIOOut(Cat(
self.csr_devices.append("leds") self.platform.request("error_led")))
self.csr_devices.append("error_led")
i2c = self.platform.request("i2c") i2c = self.platform.request("i2c")
self.submodules.i2c = gpio.GPIOTristate([i2c.scl, i2c.sda]) self.submodules.i2c = gpio.GPIOTristate([i2c.scl, i2c.sda])