From a97a24f6f4a17ed8faf4267cb7cc9d47feaf3b27 Mon Sep 17 00:00:00 2001 From: Urhengulas Date: Fri, 3 Feb 2023 22:36:10 +0100 Subject: [PATCH 1/4] Update to `probe-rs v0.16` --- Cargo.lock | 37 ++++++++++++------------------------- Cargo.toml | 3 +-- src/main.rs | 8 ++++---- 3 files changed, 17 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 50100bca..1ecd9072 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -495,6 +495,12 @@ dependencies = [ "serde", ] +[[package]] +name = "kmp" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "131bddab59a64213cc1e9f0c5be010d7eb485951358ab7e52017888dec482028" + [[package]] name = "lazy_static" version = "1.4.0" @@ -694,9 +700,9 @@ dependencies = [ [[package]] name = "probe-rs" -version = "0.14.2" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "717926460dbc3ff7bc366fd0502433a064eea2a2aa189dbb4abd5396de3716a8" +checksum = "af0cb90573126a62538ec927e644264d5d142a8cb517bff0bb2b6334cb76058f" dependencies = [ "anyhow", "base64", @@ -709,12 +715,13 @@ dependencies = [ "ihex", "jaylink", "jep106", + "kmp", "num-traits", "object", "once_cell", "probe-rs-target", "rusb", - "scroll 0.11.0", + "scroll", "serde", "serde_yaml 0.9.17", "static_assertions", @@ -723,24 +730,11 @@ dependencies = [ "tracing", ] -[[package]] -name = "probe-rs-rtt" -version = "0.14.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6768fd3c3fdc2661e2542d443bfa2ed7f48d27159e36409e65b9db955c1c60fd" -dependencies = [ - "probe-rs", - "scroll 0.10.2", - "serde", - "thiserror", - "tracing", -] - [[package]] name = "probe-rs-target" -version = "0.14.2" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f01903e24b4187015ab2c3214e009b67de6658b4fc86c8ab9876808060f7a953" +checksum = "dc9506b54a53311ceff6bd66f72ceb766908cf62bb25933d71004929a5d348ee" dependencies = [ "base64", "jep106", @@ -766,7 +760,6 @@ dependencies = [ "os_pipe", "pretty_assertions", "probe-rs", - "probe-rs-rtt", "rstest", "serial_test", "signal-hook", @@ -921,12 +914,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "scroll" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fda28d4b4830b807a8b43f7b0e6b5df875311b3e7621d84577188c175b6ec1ec" - [[package]] name = "scroll" version = "0.11.0" diff --git a/Cargo.toml b/Cargo.toml index f1a7519b..9c729006 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,8 +25,7 @@ gimli = { version = "0.27", default-features = false } git-version = "0.3" log = "0.4" object = { version = "0.30", default-features = false } -probe-rs = "0.14.1" -probe-rs-rtt = "0.14.1" +probe-rs = "0.16" signal-hook = "0.3" [dev-dependencies] diff --git a/src/main.rs b/src/main.rs index 9e12c89b..dfcdf02f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -25,11 +25,11 @@ use defmt_decoder::{DecodeError, Frame, Locations, StreamDecoder}; use probe_rs::{ config::MemoryRegion, flashing::{self, Format}, + rtt::{Rtt, ScanRegion, UpChannel}, Core, DebugProbeError::ProbeSpecific, MemoryInterface as _, Permissions, Session, }; -use probe_rs_rtt::{Rtt, ScanRegion, UpChannel}; use signal_hook::consts::signal; use crate::{backtrace::Outcome, canary::Canary, elf::Elf, target_info::TargetInfo}; @@ -125,7 +125,7 @@ fn run_target_program(elf_path: &Path, chip_name: &str, opts: &cli::Opts) -> any let mut options = flashing::DownloadOptions::default(); options.dry_run = false; - options.progress = Some(&fp); + options.progress = Some(fp); options.disable_double_buffering = opts.disable_double_buffering; options.verify = opts.verify; @@ -417,7 +417,7 @@ fn setup_logging_channel( return Ok(channel); } - Err(probe_rs_rtt::Error::ControlBlockNotFound) => { + Err(probe_rs::rtt::Error::ControlBlockNotFound) => { log::trace!("Could not attach because the target's RTT control block isn't initialized (yet). retrying"); } @@ -428,7 +428,7 @@ fn setup_logging_channel( } log::error!("Max number of RTT attach retries exceeded."); - Err(anyhow!(probe_rs_rtt::Error::ControlBlockNotFound)) + Err(anyhow!(probe_rs::rtt::Error::ControlBlockNotFound)) } /// Print a line to separate different execution stages. From 591f77cbbe8d9b444a86ae601fbbd0b37f3c8506 Mon Sep 17 00:00:00 2001 From: Urhengulas Date: Tue, 7 Feb 2023 11:53:42 +0100 Subject: [PATCH 2/4] Update `CHANGELOG.md` --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7de637cc..9c6a80e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,10 +6,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ## [Unreleased] +- [#378] Update to `probe-rs v0.16` + +[#378]: https://github.com/knurling-rs/probe-run/pull/378 + ## [v0.3.6] - 2023-01-23 - [#375] Release `probe-run v0.3.6` -- [#373] Update probe-rs to v0.14 +- [#373] Update to `probe-rs v0.14` - [#371] Add "missing drivers" to troubleshooting section - [#366] Update CI From 2cab09fa640e8b89b1a4630bece043030e1e4c15 Mon Sep 17 00:00:00 2001 From: Urhengulas Date: Fri, 3 Feb 2023 22:51:58 +0100 Subject: [PATCH 3/4] `cargo clippy --fix` --- src/backtrace/pp.rs | 8 ++++---- src/backtrace/unwind.rs | 4 ++-- src/cli.rs | 5 +---- src/dep/rust_std/toolchain.rs | 2 +- src/main.rs | 2 +- src/probe.rs | 4 ++-- tests/snapshot.rs | 2 +- 7 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/backtrace/pp.rs b/src/backtrace/pp.rs index 7680140c..de0c1ee5 100644 --- a/src/backtrace/pp.rs +++ b/src/backtrace/pp.rs @@ -28,7 +28,7 @@ pub fn backtrace(frames: &[Frame], settings: &Settings) -> io::Result<()> { .map(|location| location.path_is_relative) .unwrap_or(false); - let mut line = format!("{:>4}:", frame_index); + let mut line = format!("{frame_index:>4}:"); if settings.include_addresses || subroutine.name.is_none() { write!(line, " {:#010x} @", subroutine.pc).unwrap(); } @@ -44,7 +44,7 @@ pub fn backtrace(frames: &[Frame], settings: &Settings) -> io::Result<()> { } else { line.normal() }; - writeln!(stderr, "{}", colorized_line)?; + writeln!(stderr, "{colorized_line}")?; if let Some(location) = &subroutine.location { let dep_path = dep::Path::from_std_path(&location.path); @@ -58,10 +58,10 @@ pub fn backtrace(frames: &[Frame], settings: &Settings) -> io::Result<()> { let line = location.line; let column = location .column - .map(|column| Cow::Owned(format!(":{}", column))) + .map(|column| Cow::Owned(format!(":{column}"))) .unwrap_or(Cow::Borrowed("")); - writeln!(stderr, " at {}:{}{}", path, line, column)?; + writeln!(stderr, " at {path}:{line}{column}")?; } frame_index += 1; diff --git a/src/backtrace/unwind.rs b/src/backtrace/unwind.rs index 22f4e7ea..31ae6f79 100644 --- a/src/backtrace/unwind.rs +++ b/src/backtrace/unwind.rs @@ -16,10 +16,10 @@ use crate::{ }; fn missing_debug_info(pc: u32) -> String { - format!("debug information for address {:#x} is missing. Likely fixes: + format!("debug information for address {pc:#x} is missing. Likely fixes: 1. compile the Rust code with `debug = 1` or higher. This is configured in the `profile.{{release,bench}}` sections of Cargo.toml (`profile.{{dev,test}}` default to `debug = 2`) 2. use a recent version of the `cortex-m` crates (e.g. cortex-m 0.6.3 or newer). Check versions in Cargo.lock - 3. if linking to C code, compile the C code with the `-g` flag", pc) + 3. if linking to C code, compile the C code with the `-g` flag") } /// Virtually* unwinds the target's program diff --git a/src/cli.rs b/src/cli.rs index 7b5790fe..7eec26fb 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -162,10 +162,7 @@ fn print_version() { // Extract the "abbreviated object name" let hash = extract_git_hash(GIT_DESCRIBE); - println!( - "{} {}\nsupported defmt version: {}", - VERSION, hash, DEFMT_VERSION - ); + println!("{VERSION} {hash}\nsupported defmt version: {DEFMT_VERSION}"); } /// Extract git hash from a `git describe` statement diff --git a/src/dep/rust_std/toolchain.rs b/src/dep/rust_std/toolchain.rs index 2d127679..99bb355f 100644 --- a/src/dep/rust_std/toolchain.rs +++ b/src/dep/rust_std/toolchain.rs @@ -102,7 +102,7 @@ impl<'p> One52<'p> { Channel::Beta => "beta".into(), Channel::Nightly { date } => { if let Some(date) = date { - format!("nightly-{}", date).into() + format!("nightly-{date}").into() } else { "nightly".into() } diff --git a/src/main.rs b/src/main.rs index dfcdf02f..a58bf548 100644 --- a/src/main.rs +++ b/src/main.rs @@ -285,7 +285,7 @@ fn extract_and_print_logs( let num_bytes_read = match logging_channel.read(core, &mut read_buf) { Ok(n) => n, Err(e) => { - eprintln!("RTT error: {}", e); + eprintln!("RTT error: {e}"); break; } }; diff --git a/src/probe.rs b/src/probe.rs index b819de28..68f76714 100644 --- a/src/probe.rs +++ b/src/probe.rs @@ -45,9 +45,9 @@ pub fn print(probes: &[DebugProbeInfo]) { probes .iter() .enumerate() - .for_each(|(num, link)| println!("[{}]: {:?}", num, link)); + .for_each(|(num, link)| println!("[{num}]: {link:?}")); } else { - println!("Error: {}", NO_PROBE_FOUND_ERR); + println!("Error: {NO_PROBE_FOUND_ERR}"); } } diff --git a/tests/snapshot.rs b/tests/snapshot.rs index f8868358..a02befd9 100644 --- a/tests/snapshot.rs +++ b/tests/snapshot.rs @@ -91,7 +91,7 @@ fn truncate_output(probe_run_output: String) -> String { // https://github.com/knurling-rs/probe-run/issues/217 is resolved && !line.starts_with("└─ ") }) - .map(|line| format!("{}\n", line)) + .map(|line| format!("{line}\n")) .collect() } From 1da553274237dddb09102100f6b426dbb041da91 Mon Sep 17 00:00:00 2001 From: Urhengulas Date: Sun, 5 Feb 2023 14:14:06 +0100 Subject: [PATCH 4/4] Satisfy clippy --- .github/workflows/ci.yml | 4 ++-- tests/snapshot.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8b305b9d..29fcff6d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,8 +38,8 @@ jobs: - name: Install C libraries for tooling run: sudo apt-get update && sudo apt-get install libudev-dev libusb-1.0-0-dev - - run: cargo fmt -- --check - - run: cargo clippy -- -D warnings + - run: cargo fmt --check + - run: cargo clippy --all-targets -- -D warnings # Refs: https://github.com/rust-lang/crater/blob/9ab6f9697c901c4a44025cf0a39b73ad5b37d198/.github/workflows/bors.yml#L125-L149 # bors.tech integration diff --git a/tests/snapshot.rs b/tests/snapshot.rs index a02befd9..b2946c37 100644 --- a/tests/snapshot.rs +++ b/tests/snapshot.rs @@ -119,6 +119,6 @@ fn snapshot_test(#[case] args: &str, #[case] success: bool) { #[cfg(target_family = "unix")] fn ctrl_c_by_user_is_reported_as_such() { let run_result = run_and_terminate("silent-loop-rzcobs", 5); - assert_eq!(false, run_result.exit_status.success()); + assert!(!run_result.exit_status.success()); insta::assert_snapshot!(run_result.output); }