Skip to content

Instantly share code, notes, and snippets.

@xobs
Created March 29, 2025 04:12
Show Gist options
  • Save xobs/1b7542f28d5c8a6f2940767f4f59b64b to your computer and use it in GitHub Desktop.
Save xobs/1b7542f28d5c8a6f2940767f4f59b64b to your computer and use it in GitHub Desktop.
A hacky patch to probe-rs to allow manually specifying a probe without discovering it first.
diff --git a/probe-rs-tools/src/bin/probe-rs/cmd/info.rs b/probe-rs-tools/src/bin/probe-rs/cmd/info.rs
index 8fcbd62b3..af949976a 100644
--- a/probe-rs-tools/src/bin/probe-rs/cmd/info.rs
+++ b/probe-rs-tools/src/bin/probe-rs/cmd/info.rs
@@ -14,9 +14,12 @@ use termtree::Tree;
use crate::{
rpc::{
client::RpcClient,
- functions::info::{
- ApInfo, ComponentTreeNode, DebugPortInfo, DebugPortInfoNode, DebugPortVersion,
- InfoEvent, MinDpSupport, TargetInfoRequest,
+ functions::{
+ info::{
+ ApInfo, ComponentTreeNode, DebugPortInfo, DebugPortInfoNode, DebugPortVersion,
+ InfoEvent, MinDpSupport, TargetInfoRequest,
+ },
+ probe::DebugProbeEntry,
},
},
util::{cli::select_probe, common_options::ProbeOptions},
@@ -55,7 +58,20 @@ impl Cmd {
vec![WireProtocol::Jtag, WireProtocol::Swd]
};
- let probe = select_probe(&client, self.common.probe.map(Into::into)).await?;
+ let probe = if let Some(descriptor) = &self.common.probe {
+ DebugProbeEntry {
+ identifier: "manual".to_owned(),
+ vendor_id: descriptor.vendor_id,
+ product_id: descriptor.product_id,
+ serial_number: descriptor
+ .serial_number
+ .clone()
+ .unwrap_or_else(|| "".to_owned()),
+ probe_type: "manual".to_owned(),
+ }
+ } else {
+ select_probe(&client, self.common.probe.map(Into::into)).await?
+ };
for protocol in protocols {
let msg = format!("Probing target via {protocol}");
diff --git a/probe-rs-tools/src/bin/probe-rs/util/cli.rs b/probe-rs-tools/src/bin/probe-rs/util/cli.rs
index af7cabe00..d06e56524 100644
--- a/probe-rs-tools/src/bin/probe-rs/util/cli.rs
+++ b/probe-rs-tools/src/bin/probe-rs/util/cli.rs
@@ -60,7 +60,20 @@ pub async fn attach_probe(
client.load_chip_family(file).await?;
}
- let probe = select_probe(client, probe_options.probe.map(Into::into)).await?;
+ let probe = if let Some(descriptor) = &probe_options.probe {
+ DebugProbeEntry {
+ identifier: "manual".to_owned(),
+ vendor_id: descriptor.vendor_id,
+ product_id: descriptor.product_id,
+ serial_number: descriptor
+ .serial_number
+ .clone()
+ .unwrap_or_else(|| "".to_owned()),
+ probe_type: "manual".to_owned(),
+ }
+ } else {
+ select_probe(client, probe_options.probe.map(Into::into)).await?
+ };
let result = client
.attach_probe(AttachRequest {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment