Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
2 changes: 1 addition & 1 deletion memory.x
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
22 changes: 10 additions & 12 deletions src/hardware/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this, combined with watchdog.stop_on_debug(...), enough, or do you additionally want to completely disable the watchdog when the rtt feature is enabled?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. Just watchdog.stop_on_debug is fine. Good find.


cortex_m::peripheral::SCB::sys_reset();
}

/// Unconditionally disable and power-off all channels.
Expand Down
10 changes: 7 additions & 3 deletions src/hardware/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down Expand Up @@ -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);

Expand Down
Loading