diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 470d392..75c411e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: - run: cargo fmt --all -- --check - run: cargo check - + - run: cargo check --all-features - run: cargo clippy --all-features -- -D warnings compile: diff --git a/Cargo.toml b/Cargo.toml index 29f71d0..c1dd7d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,16 +58,18 @@ minimq = "0.9.0" w5500 = "0.5" smlang= "0.8" minireq = "0.5" -rtt-target = "0.6" +rtt-target = { version = "0.6", optional = true } enum-iterator = { version = "2.1", default-features = false } enc424j600 = "0.4" embedded-hal = "1" smoltcp-nal = { version = "0.5", features=["shared-stack"] } serial-settings = "0.1" stm32f4xx-hal = {version = "0.22.1", features = ["stm32f407", "usb_fs"] } - postcard = "1" +[features] +rtt = ["dep:rtt-target"] + [build-dependencies] built = { version = "0.7", features = ["git2"], default-features = false } diff --git a/memory.x b/memory.x index 64ce282..b66dbf0 100644 --- a/memory.x +++ b/memory.x @@ -5,7 +5,7 @@ MEMORY FLASH : ORIGIN = 0x08000000, LENGTH = 768K RAM : ORIGIN = 0x20000000, LENGTH = 126K PANDUMP : ORIGIN = 0x2001FC00, LENGTH = 1K - BOOTFLAG_RAM: ORIGIN = 0x2001F800, LENGTH = 1K + BOOTFLAG_RAM : ORIGIN = 0x2001F800, LENGTH = 1K } _bootflag = ORIGIN(BOOTFLAG_RAM); diff --git a/src/hardware/platform.rs b/src/hardware/platform.rs index 972a74a..4b0fa9f 100644 --- a/src/hardware/platform.rs +++ b/src/hardware/platform.rs @@ -20,28 +20,26 @@ pub const BIAS_DAC_VCC: f32 = 3.2; #[panic_handler] fn panic(info: &core::panic::PanicInfo) -> ! { - use core::fmt::Write; - use rtt_target::{ChannelMode, UpChannel}; - cortex_m::interrupt::disable(); // Shutdown all of the RF channels. shutdown_channels(); - if let Some(mut channel) = unsafe { UpChannel::conjure(0) } { - channel.set_mode(ChannelMode::BlockIfFull); - writeln!(channel, "{}", info).ok(); - } - // Write panic info to RAM. panic_persist::report_panic_info(info); - // Reset the device in `release` configuration. - #[cfg(not(debug_assertions))] - cortex_m::peripheral::SCB::sys_reset(); + #[cfg(feature = "rtt")] + if let Some(mut channel) = unsafe { rtt_target::UpChannel::conjure(0) } { + use core::fmt::Write; + + channel.set_mode(rtt_target::ChannelMode::BlockIfFull); + writeln!(channel, "{}", info).ok(); + } #[cfg(debug_assertions)] - loop {} + cortex_m::asm::bkpt(); + + cortex_m::peripheral::SCB::sys_reset(); } /// Unconditionally disable and power-off all channels. diff --git a/src/hardware/setup.rs b/src/hardware/setup.rs index 4c730f1..9b7c3f3 100644 --- a/src/hardware/setup.rs +++ b/src/hardware/setup.rs @@ -103,9 +103,12 @@ pub fn setup( device: stm32f4xx_hal::pac::Peripherals, clock: SystemTimer, ) -> BoosterDevices { - // Configure RTT logging. - device.DBGMCU.cr().modify(|_, w| w.dbg_sleep().set_bit()); - rtt_target::rtt_init_print!(); + #[cfg(feature = "rtt")] + { + // Configure RTT logging. + device.DBGMCU.cr().modify(|_, w| w.dbg_sleep().set_bit()); + rtt_target::rtt_init_print!(); + } // Install the logger log::set_logger(&crate::LOGGER) @@ -139,6 +142,7 @@ pub fn setup( // Start the watchdog during the initialization process. let mut watchdog = hal::watchdog::IndependentWatchdog::new(device.IWDG); + watchdog.stop_on_debug(&device.DBGMCU, true); watchdog.start(30.secs()); let mut delay = AsmDelay::new(clocks.sysclk().to_Hz()); diff --git a/src/logger.rs b/src/logger.rs index 9c27890..c2e7299 100644 --- a/src/logger.rs +++ b/src/logger.rs @@ -4,7 +4,6 @@ use heapless::String; use super::SerialTerminal; use core::fmt::Write; use log::LevelFilter; -use rtt_target::rprintln; /// A logging buffer for storing serialized logs pending transmission. /// @@ -51,7 +50,8 @@ impl log::Log for BufferedLog { return; } - rprintln!("{} - {}", record.level(), record.args()); + #[cfg(feature = "rtt")] + rtt_target::rprintln!("{} - {}", record.level(), record.args()); let source_file = record.file().unwrap_or("Unknown"); let source_line = record.line().unwrap_or(u32::MAX);