From 99c31a89856c1f5487724ed8f30cd0319d4f0028 Mon Sep 17 00:00:00 2001 From: Hidekazu Kobayashi Date: Mon, 21 Feb 2022 12:53:10 +0900 Subject: [PATCH 1/3] Add way to pass chip description file --- src/cli.rs | 3 +++ src/main.rs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/cli.rs b/src/cli.rs index 438ffe01..f26b2296 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -27,6 +27,9 @@ pub(crate) struct Opts { #[structopt(long, required_unless_one(&["list-chips", "list-probes", "version"]), env = "PROBE_RUN_CHIP")] chip: Option, + #[structopt(name = "chip description file path", long = "chip-description-path")] + pub(crate) chip_description_path: Option, + /// The probe to use (eg. `VID:PID`, `VID:PID:Serial`, or just `Serial`). #[structopt(long, env = "PROBE_RUN_PROBE")] pub(crate) probe: Option, diff --git a/src/main.rs b/src/main.rs index 490208b9..e784def1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -52,6 +52,9 @@ fn run_target_program(elf_path: &Path, chip_name: &str, opts: &cli::Opts) -> any let elf_bytes = fs::read(elf_path)?; let elf = &Elf::parse(&elf_bytes)?; + if let Some(ref cdp) = opts.chip_description_path { + probe_rs::config::add_target_from_yaml(Path::new(cdp))?; + } let target_info = TargetInfo::new(chip_name, elf)?; let probe = probe::open(opts)?; From f2a10d3b68d7ebf590435c0c0078253705ca4b83 Mon Sep 17 00:00:00 2001 From: Hidekazu Kobayashi Date: Tue, 22 Feb 2022 18:17:39 +0900 Subject: [PATCH 2/3] Fix cli option description Co-authored-by: Johann Hemmann --- src/cli.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cli.rs b/src/cli.rs index f26b2296..dff874ad 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -27,7 +27,8 @@ pub(crate) struct Opts { #[structopt(long, required_unless_one(&["list-chips", "list-probes", "version"]), env = "PROBE_RUN_CHIP")] chip: Option, - #[structopt(name = "chip description file path", long = "chip-description-path")] + /// Path to chip description file, in YAML format. + #[structopt(long)] pub(crate) chip_description_path: Option, /// The probe to use (eg. `VID:PID`, `VID:PID:Serial`, or just `Serial`). From c55b39eefa3dee0ba90c5021056f599375ddbcf7 Mon Sep 17 00:00:00 2001 From: Hidekazu Kobayashi Date: Tue, 22 Feb 2022 18:21:25 +0900 Subject: [PATCH 3/3] Use ergonomic pattern match Co-authored-by: Johann Hemmann --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index e784def1..6c6a54e7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -52,7 +52,7 @@ fn run_target_program(elf_path: &Path, chip_name: &str, opts: &cli::Opts) -> any let elf_bytes = fs::read(elf_path)?; let elf = &Elf::parse(&elf_bytes)?; - if let Some(ref cdp) = opts.chip_description_path { + if let Some(cdp) = &opts.chip_description_path { probe_rs::config::add_target_from_yaml(Path::new(cdp))?; } let target_info = TargetInfo::new(chip_name, elf)?;