Skip to content

Commit

Permalink
Add support for custom chip description YAML files
Browse files Browse the repository at this point in the history
  • Loading branch information
jonlamb-gh committed Feb 22, 2024
1 parent abe5e68 commit d323b78
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "modality-trace-recorder-plugin"
version = "0.7.1"
version = "0.8.0"
edition = "2021"
authors = ["Jon Lamb <jon@auxon.io>"]
description = "A Modality reflector plugin suite and ingest adapter library for Percepio's TraceRecorder data"
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
17 changes: 17 additions & 0 deletions src/bin/itm_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PathBuf>,
}

#[tokio::main]
Expand Down Expand Up @@ -220,6 +229,9 @@ async fn do_main() -> Result<(), Box<dyn std::error::Error>> {
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()
Expand All @@ -242,6 +254,11 @@ async fn do_main() -> Result<(), Box<dyn std::error::Error>> {
.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());
}
Expand Down
18 changes: 18 additions & 0 deletions src/bin/rtt_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use probe_rs::{
use probe_rs_rtt::{Rtt, UpChannel};
use std::{
io,
path::PathBuf,
time::{Duration, Instant},
};
use thiserror::Error;
Expand Down Expand Up @@ -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<PathBuf>,
}

#[tokio::main]
Expand Down Expand Up @@ -183,6 +193,9 @@ async fn do_main() -> Result<(), Box<dyn std::error::Error>> {
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
Expand All @@ -191,6 +204,11 @@ async fn do_main() -> Result<(), Box<dyn std::error::Error>> {
.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())?
Expand Down
8 changes: 8 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ pub struct ItmCollectorConfig {
pub clk: Option<u32>,
pub baud: Option<u32>,
pub reset: bool,
pub chip_description_path: Option<PathBuf>,
}

impl ItmCollectorConfig {
Expand All @@ -110,6 +111,7 @@ impl Default for ItmCollectorConfig {
clk: None,
baud: None,
reset: false,
chip_description_path: None,
}
}
}
Expand All @@ -128,6 +130,7 @@ pub struct RttCollectorConfig {
pub speed: u32,
pub core: usize,
pub reset: bool,
pub chip_description_path: Option<PathBuf>,
}

impl RttCollectorConfig {
Expand All @@ -152,6 +155,7 @@ impl Default for RttCollectorConfig {
speed: Self::DEFAULT_SPEED,
core: Self::DEFAULT_CORE,
reset: false,
chip_description_path: None,
}
}
}
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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(),
},
Expand Down Expand Up @@ -1083,6 +1090,7 @@ reset = true
speed: 1234,
core: 1,
reset: true,
chip_description_path: PathBuf::from("/tmp/S32K_Series.yaml").into(),
},
},
}
Expand Down

0 comments on commit d323b78

Please sign in to comment.