diff --git a/Cargo.lock b/Cargo.lock index 91efa7f..8bd86b2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -885,7 +885,7 @@ dependencies = [ [[package]] name = "modality-trace-recorder-plugin" -version = "0.7.1" +version = "0.8.0" dependencies = [ "async-trait", "byteordered", diff --git a/Cargo.toml b/Cargo.toml index e3ae02b..becc4fc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "modality-trace-recorder-plugin" -version = "0.7.1" +version = "0.8.0" edition = "2021" authors = ["Jon Lamb "] description = "A Modality reflector plugin suite and ingest adapter library for Percepio's TraceRecorder data" diff --git a/README.md b/README.md index 9435c2f..c54d1f5 100644 --- a/README.md +++ b/README.md @@ -156,6 +156,9 @@ reflector configuration file, e.g. `[plugins.ingest.collectors.trace-recorder-it - `clk` — The speed of the clock feeding the TPIU/SWO module in Hz. - `baud` — The desired baud rate of the SWO output. - `reset` — Reset the target on startup. + - `chip-description-path` — Provides custom target descriptions based on CMSIS Pack files. + See the [probe-rs target extraction](https://probe.rs/docs/knowledge-base/cmsis-packs/#target-extraction) section for + more information. ### RTT Collector Section @@ -181,6 +184,9 @@ reflector configuration file, e.g. `[plugins.ingest.collectors.trace-recorder-rt - `speed` — The protocol speed in kHz. The default value is 4000. - `core` — The selected core to target. The default value is 0. - `reset` — Reset the target on startup. + - `chip-description-path` — Provides custom target descriptions based on CMSIS Pack files. + See the [probe-rs target extraction](https://probe.rs/docs/knowledge-base/cmsis-packs/#target-extraction) section for + more information. ### Configuration Examples diff --git a/src/bin/itm_collector.rs b/src/bin/itm_collector.rs index 43638eb..a5c682e 100644 --- a/src/bin/itm_collector.rs +++ b/src/bin/itm_collector.rs @@ -132,6 +132,15 @@ struct Opts { /// Reset the target on startup. #[clap(long, name = "reset", help_heading = "PROBE CONFIGURATION")] pub reset: bool, + + /// Chip description YAML file path. + /// Provides custom target descriptions based on CMSIS Pack files. + #[clap( + long, + name = "chip-description-path", + help_heading = "PROBE CONFIGURATION" + )] + pub chip_description_path: Option, } #[tokio::main] @@ -220,6 +229,9 @@ async fn do_main() -> Result<(), Box> { if opts.reset { trc_cfg.plugin.itm_collector.reset = true; } + if let Some(cd) = &opts.chip_description_path { + trc_cfg.plugin.itm_collector.chip_description_path = Some(cd.clone()); + } if !trc_cfg.plugin.itm_collector.disable_control_plane && trc_cfg.plugin.itm_collector.elf_file.is_none() @@ -242,6 +254,11 @@ async fn do_main() -> Result<(), Box> { .clone() .ok_or(Error::MissingChip)?; + if let Some(chip_desc) = &trc_cfg.plugin.itm_collector.chip_description_path { + debug!(path = %chip_desc.display(), "Adding custom chip description"); + probe_rs::config::add_target_from_yaml(chip_desc)?; + } + if trc_cfg.plugin.itm_collector.stimulus_port > 31 { return Err(Error::InvalidStimulusPort(trc_cfg.plugin.itm_collector.stimulus_port).into()); } diff --git a/src/bin/rtt_collector.rs b/src/bin/rtt_collector.rs index 7719f89..b62e41e 100644 --- a/src/bin/rtt_collector.rs +++ b/src/bin/rtt_collector.rs @@ -10,6 +10,7 @@ use probe_rs::{ use probe_rs_rtt::{Rtt, UpChannel}; use std::{ io, + path::PathBuf, time::{Duration, Instant}, }; use thiserror::Error; @@ -104,6 +105,15 @@ struct Opts { /// Reset the target on startup. #[clap(long, name = "reset", help_heading = "PROBE CONFIGURATION")] pub reset: bool, + + /// Chip description YAML file path. + /// Provides custom target descriptions based on CMSIS Pack files. + #[clap( + long, + name = "chip-description-path", + help_heading = "PROBE CONFIGURATION" + )] + pub chip_description_path: Option, } #[tokio::main] @@ -183,6 +193,9 @@ async fn do_main() -> Result<(), Box> { if opts.reset { trc_cfg.plugin.rtt_collector.reset = true; } + if let Some(cd) = &opts.chip_description_path { + trc_cfg.plugin.rtt_collector.chip_description_path = Some(cd.clone()); + } let chip = trc_cfg .plugin @@ -191,6 +204,11 @@ async fn do_main() -> Result<(), Box> { .clone() .ok_or(Error::MissingChip)?; + if let Some(chip_desc) = &trc_cfg.plugin.rtt_collector.chip_description_path { + debug!(path = %chip_desc.display(), "Adding custom chip description"); + probe_rs::config::add_target_from_yaml(chip_desc)?; + } + let mut probe = if let Some(probe_selector) = &trc_cfg.plugin.rtt_collector.probe_selector { debug!(probe_selector = %probe_selector.0, "Opening selected probe"); Probe::open(probe_selector.0.clone())? diff --git a/src/config.rs b/src/config.rs index 94394db..927c00e 100644 --- a/src/config.rs +++ b/src/config.rs @@ -84,6 +84,7 @@ pub struct ItmCollectorConfig { pub clk: Option, pub baud: Option, pub reset: bool, + pub chip_description_path: Option, } impl ItmCollectorConfig { @@ -110,6 +111,7 @@ impl Default for ItmCollectorConfig { clk: None, baud: None, reset: false, + chip_description_path: None, } } } @@ -128,6 +130,7 @@ pub struct RttCollectorConfig { pub speed: u32, pub core: usize, pub reset: bool, + pub chip_description_path: Option, } impl RttCollectorConfig { @@ -152,6 +155,7 @@ impl Default for RttCollectorConfig { speed: Self::DEFAULT_SPEED, core: Self::DEFAULT_CORE, reset: false, + chip_description_path: None, } } } @@ -585,6 +589,7 @@ core = 1 clk = 222 baud = 4444 reset = true +chip-description-path = "/tmp/S32K_Series.yaml" [[metadata.user-event-fmt-arg-attr-keys]] channel = 'stats' @@ -631,6 +636,7 @@ protocol = 'Jtag' speed = 1234 core = 1 reset = true +chip-description-path = "/tmp/S32K_Series.yaml" [[metadata.user-event-fmt-arg-attr-keys]] channel = 'stats' @@ -967,6 +973,7 @@ reset = true clk: 222.into(), baud: 4444.into(), reset: true, + chip_description_path: PathBuf::from("/tmp/S32K_Series.yaml").into(), }, rtt_collector: Default::default(), }, @@ -1083,6 +1090,7 @@ reset = true speed: 1234, core: 1, reset: true, + chip_description_path: PathBuf::from("/tmp/S32K_Series.yaml").into(), }, }, }