use rtt logging

master
Robert Jördens 2021-05-12 19:02:15 +02:00
parent 76b9be6d93
commit 5b616a2874
4 changed files with 64 additions and 45 deletions

68
Cargo.lock generated
View File

@ -133,17 +133,6 @@ dependencies = [
"volatile-register",
]
[[package]]
name = "cortex-m-log"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e202d2eac4e34adf7524a563e36623bae6f69cc0a73ef9bd22a4c93a5a806fa"
dependencies = [
"cortex-m 0.7.2",
"cortex-m-semihosting",
"log",
]
[[package]]
name = "cortex-m-rt"
version = "0.6.13"
@ -191,15 +180,6 @@ dependencies = [
"syn",
]
[[package]]
name = "cortex-m-semihosting"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6bffa6c1454368a6aa4811ae60964c38e6996d397ff8095a8b9211b1c1f749bc"
dependencies = [
"cortex-m 0.7.2",
]
[[package]]
name = "derive_miniconf"
version = "0.1.0"
@ -538,13 +518,13 @@ dependencies = [
]
[[package]]
name = "panic-semihosting"
version = "0.5.6"
name = "panic-rtt-target"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3d55dedd501dfd02514646e0af4d7016ce36bc12ae177ef52056989966a1eec"
checksum = "0d6ab67bc881453e4c90f958c657c1303670ea87bc1a16e87fd71a40f656dce9"
dependencies = [
"cortex-m 0.7.2",
"cortex-m-semihosting",
"rtt-target 0.3.1",
]
[[package]]
@ -646,6 +626,35 @@ dependencies = [
"syn",
]
[[package]]
name = "rtt-logger"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d082d3a20a5d4f69ad509720de1777fe5aa2092ea1af51b254ff79113d46d2ea"
dependencies = [
"log",
"rtt-target 0.2.2",
]
[[package]]
name = "rtt-target"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0869b4c5b6a6d8c5583fc473f9eb3423a170f77626b8c8a7fb18eddcda5770e2"
dependencies = [
"cortex-m 0.6.7",
"ufmt-write",
]
[[package]]
name = "rtt-target"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "065d6058bb1204f51a562a67209e1817cf714759d5cf845aa45c75fa7b0b9d9b"
dependencies = [
"ufmt-write",
]
[[package]]
name = "rustc_version"
version = "0.2.3"
@ -746,7 +755,6 @@ dependencies = [
"ad9959",
"asm-delay",
"cortex-m 0.6.7",
"cortex-m-log",
"cortex-m-rt",
"cortex-m-rtic",
"dsp",
@ -759,8 +767,10 @@ dependencies = [
"miniconf",
"minimq",
"nb 1.0.0",
"panic-semihosting",
"panic-rtt-target",
"paste",
"rtt-logger",
"rtt-target 0.2.2",
"serde",
"serde-json-core",
"shared-bus",
@ -822,6 +832,12 @@ version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06"
[[package]]
name = "ufmt-write"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e87a2ed6b42ec5e28cc3b94c09982969e9227600b2e3dcbc1db927a84c06bd69"
[[package]]
name = "unicode-xid"
version = "0.2.1"

View File

@ -30,9 +30,10 @@ members = ["ad9959", "dsp"]
[dependencies]
cortex-m = { version = "0.6", features = ["const-fn"] }
cortex-m-rt = { version = "0.6", features = ["device"] }
cortex-m-log = { version = "0.7", features = ["log-integration"] }
log = "0.4"
panic-semihosting = { version = "0.5", optional = true }
log = { version = "0.4", features = ["max_level_trace", "release_max_level_info"] }
rtt-target = { version = "0.2.1", features = ["cortex-m"], optional = true }
panic-rtt-target = { version = "0.1.1", features = ["cortex-m"], optional = true }
rtt-logger = { version = "0.1", optional = true }
serde = { version = "1.0", features = ["derive"], default-features = false }
heapless = { version = "0.6", features = ["serde"] }
cortex-m-rtic = "0.5.6"
@ -69,7 +70,7 @@ git = "https://github.com/quartiq/minimq.git"
rev = "d2ec3e8"
[features]
semihosting = ["panic-semihosting", "cortex-m-log/semihosting"]
rtt = [ "rtt-target", "panic-rtt-target", "rtt-logger" ]
bkpt = [ ]
nightly = ["cortex-m/inline-asm", "dsp/nightly"]
pounder_v1_1 = [ ]

View File

@ -145,19 +145,21 @@ pub fn setup(
.pll2_q_ck(100.mhz())
.freeze(vos, &device.SYSCFG);
#[cfg(feature = "semihosting")]
#[cfg(feature = "rtt")]
{
use cortex_m_log::log::{init as init_log, Logger};
use cortex_m_log::printer::semihosting::{hio::HStdout, InterruptOk};
use log::LevelFilter;
static mut LOGGER: Option<Logger<InterruptOk<HStdout>>> = None;
let logger = Logger {
inner: InterruptOk::<_>::stdout().unwrap(),
level: LevelFilter::Info,
};
let logger = unsafe { LOGGER.get_or_insert(logger) };
// Enable debug during WFE/WFI-induced sleep
device.DBGMCU.cr.modify(|_, w| w.dbgsleep_d1().set_bit());
init_log(logger).unwrap();
use log::LevelFilter;
use rtt_logger::RTTLogger;
use rtt_target::rtt_init_print;
static LOGGER: RTTLogger = RTTLogger::new(LevelFilter::Info);
rtt_init_print!(NoBlockSkip, 1024);
log::set_logger(&LOGGER)
.map(|()| log::set_max_level(log::LevelFilter::Trace))
.unwrap();
log::info!("Setup...");
}
// Set up the system timer for RTIC scheduling.

View File

@ -4,9 +4,6 @@ use stm32h7xx_hal as hal;
// Re-export for the DigitalInputs below:
pub use embedded_hal::digital::v2::InputPin;
#[cfg(feature = "semihosting")]
use panic_semihosting as _;
mod adc;
mod afe;
mod configuration;
@ -57,9 +54,12 @@ pub type EthernetPhy = hal::ethernet::phy::LAN8742A<hal::ethernet::EthernetMAC>;
pub use configuration::{setup, PounderDevices, StabilizerDevices};
#[cfg(feature = "rtt")]
use panic_rtt_target as _;
#[inline(never)]
#[panic_handler]
#[cfg(all(not(feature = "semihosting")))]
#[cfg(all(not(feature = "rtt")))]
fn panic(_info: &core::panic::PanicInfo) -> ! {
let gpiod = unsafe { &*hal::stm32::GPIOD::ptr() };
// Turn on both red LEDs, FP_LED_1, FP_LED_3