diff --git a/firmware-binaries/clock-control/src/main.rs b/firmware-binaries/clock-control/src/main.rs index 84fab9297..bd04e3e41 100644 --- a/firmware-binaries/clock-control/src/main.rs +++ b/firmware-binaries/clock-control/src/main.rs @@ -5,8 +5,6 @@ // // SPDX-License-Identifier: Apache-2.0 -use core::panic::PanicInfo; - use bittide_sys::{ callisto::{self, ControlConfig, ControlSt, ReframingState}, clock_control::{ClockControl, SpeedChange}, diff --git a/firmware-binaries/examples/hello/src/main.rs b/firmware-binaries/examples/hello/src/main.rs index 543c169d6..6ea1b6a34 100644 --- a/firmware-binaries/examples/hello/src/main.rs +++ b/firmware-binaries/examples/hello/src/main.rs @@ -45,3 +45,11 @@ fn main() -> ! { uart.send(c); } } + +#[panic_handler] +fn panic_handler(_info: &core::panic::PanicInfo) -> ! { + test_failure(); + loop { + continue; + } +} diff --git a/firmware-binaries/examples/smoltcp_client/Cargo.toml b/firmware-binaries/examples/smoltcp_client/Cargo.toml index 20dfdbcbd..195974372 100644 --- a/firmware-binaries/examples/smoltcp_client/Cargo.toml +++ b/firmware-binaries/examples/smoltcp_client/Cargo.toml @@ -12,7 +12,7 @@ authors = ["Google LLC"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -bittide-sys = { path = "../../../firmware-support/bittide-sys" } +bittide-sys = { path = "../../../firmware-support/bittide-sys", features = ["panic_handler_log"]} riscv-rt = "0.11.0" riscv = "^0.10" heapless = { version = "0.8", default-features = false} diff --git a/firmware-binaries/test-cases/axi_stream_self_test/Cargo.toml b/firmware-binaries/test-cases/axi_stream_self_test/Cargo.toml index e01415b97..091e8c5fd 100644 --- a/firmware-binaries/test-cases/axi_stream_self_test/Cargo.toml +++ b/firmware-binaries/test-cases/axi_stream_self_test/Cargo.toml @@ -13,5 +13,5 @@ authors = ["Google LLC"] [dependencies] riscv-rt = "0.11.0" -bittide-sys = { path = "../../../firmware-support/bittide-sys" } +bittide-sys = { path = "../../../firmware-support/bittide-sys", features = ["panic_handler_log"]} ufmt = "0.2.0" diff --git a/firmware-binaries/test-cases/axi_stream_self_test/src/main.rs b/firmware-binaries/test-cases/axi_stream_self_test/src/main.rs index 6174e24d5..d04c28db6 100644 --- a/firmware-binaries/test-cases/axi_stream_self_test/src/main.rs +++ b/firmware-binaries/test-cases/axi_stream_self_test/src/main.rs @@ -5,8 +5,6 @@ // // SPDX-License-Identifier: Apache-2.0 -use ufmt::uwriteln; - use bittide_sys::axi::self_test::self_test; use bittide_sys::axi::{AxiRx, AxiTx}; use bittide_sys::uart::Uart; diff --git a/firmware-binaries/test-cases/capture_ugn_test/Cargo.toml b/firmware-binaries/test-cases/capture_ugn_test/Cargo.toml index 8a245bca3..3bb0734dd 100644 --- a/firmware-binaries/test-cases/capture_ugn_test/Cargo.toml +++ b/firmware-binaries/test-cases/capture_ugn_test/Cargo.toml @@ -13,5 +13,5 @@ authors = ["Google LLC"] [dependencies] riscv-rt = "0.11.0" -bittide-sys = { path = "../../../firmware-support/bittide-sys" } +bittide-sys = { path = "../../../firmware-support/bittide-sys", features = ["panic_handler_log"]} ufmt = "0.2.0" diff --git a/firmware-binaries/test-cases/dna_port_e2_test/Cargo.toml b/firmware-binaries/test-cases/dna_port_e2_test/Cargo.toml index 9861b9733..050bed1e4 100644 --- a/firmware-binaries/test-cases/dna_port_e2_test/Cargo.toml +++ b/firmware-binaries/test-cases/dna_port_e2_test/Cargo.toml @@ -13,5 +13,5 @@ authors = ["Google LLC"] [dependencies] riscv-rt = "0.11.0" -bittide-sys = { path = "../../../firmware-support/bittide-sys" } +bittide-sys = { path = "../../../firmware-support/bittide-sys", features = ["panic_handler_log"]} ufmt = "0.2.0" diff --git a/firmware-binaries/test-cases/time_self_test/Cargo.toml b/firmware-binaries/test-cases/time_self_test/Cargo.toml index b31de80a6..06690d620 100644 --- a/firmware-binaries/test-cases/time_self_test/Cargo.toml +++ b/firmware-binaries/test-cases/time_self_test/Cargo.toml @@ -13,5 +13,5 @@ authors = ["Google LLC"] [dependencies] riscv-rt = "0.11.0" -bittide-sys = { path = "../../../firmware-support/bittide-sys" } +bittide-sys = { path = "../../../firmware-support/bittide-sys", default-features = false } ufmt = "0.2.0" diff --git a/firmware-support/bittide-sys/Cargo.toml b/firmware-support/bittide-sys/Cargo.toml index 28c1d323c..03aca01ae 100644 --- a/firmware-support/bittide-sys/Cargo.toml +++ b/firmware-support/bittide-sys/Cargo.toml @@ -14,6 +14,7 @@ resolver = "2" [features] default = [] +panic_handler_log = [] [dependencies] fdt = "0.1.0" diff --git a/firmware-support/bittide-sys/src/uart/log.rs b/firmware-support/bittide-sys/src/uart/log.rs index 1f06f427a..9a464f2ef 100644 --- a/firmware-support/bittide-sys/src/uart/log.rs +++ b/firmware-support/bittide-sys/src/uart/log.rs @@ -7,11 +7,11 @@ use crate::{time, uart}; // compatible with (dependencies of) the log crate. use core::fmt::Write; use log::LevelFilter; + use core::panic::PanicInfo; use log::error; use ufmt::uwriteln; - /// A global logger instance to be used with the `log` crate. /// /// Use `set_logger` to set the `Uart` instance to be used for logging. @@ -92,8 +92,8 @@ impl log::Log for UartLogger { unsafe impl core::marker::Send for UartLogger {} unsafe impl core::marker::Sync for UartLogger {} -#[panic_handler] -fn panic_handler(info: &PanicInfo) -> ! { +#[cfg_attr(feature = "panic_handler_log", panic_handler)] +pub fn panic_handler(info: &PanicInfo) -> ! { unsafe { match LOGGER.uart { Some(ref mut uart) => { diff --git a/host-tools/callisto-lib/Cargo.toml b/host-tools/callisto-lib/Cargo.toml index 6df484b8b..0054fa517 100644 --- a/host-tools/callisto-lib/Cargo.toml +++ b/host-tools/callisto-lib/Cargo.toml @@ -10,7 +10,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -bittide-sys = { path = "../../firmware-support/bittide-sys" } +bittide-sys = { path = "../../firmware-support/bittide-sys", default-features = false, features = []} [lib] crate-type = ["staticlib"]