diff --git a/CHANGELOG.md b/CHANGELOG.md index 62eea02..05821b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +## [0.12.0] + +### Changed + +- Update to probe-rs 0.12.0. + ## [0.11.0] ### Added @@ -164,7 +170,8 @@ An example is this config: ## [0.6.0] - Initial release -[Unreleased]: https://github.com/probe-rs/cargo-embed/compare/v0.11.0..master +[Unreleased]: https://github.com/probe-rs/cargo-embed/compare/v0.12.0..master +[0.12.0]: https://github.com/probe-rs/cargo-embed/releases/tag/v0.11.0..v0.12.0 [0.11.0]: https://github.com/probe-rs/cargo-embed/releases/tag/v0.10.1..v0.11.0 [0.10.1]: https://github.com/probe-rs/cargo-embed/releases/tag/v0.10.0..v0.10.1 [0.10.0]: https://github.com/probe-rs/cargo-embed/releases/tag/v0.9.0..v0.10.0 diff --git a/Cargo.lock b/Cargo.lock index 68b97bc..b0bac13 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -287,12 +287,12 @@ dependencies = [ [[package]] name = "cargo-embed" -version = "0.11.0" +version = "0.12.0" dependencies = [ "anyhow", "chrono", "colored", - "crossterm 0.22.1", + "crossterm", "defmt-decoder", "env_logger", "figment", @@ -457,23 +457,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ebde6a9dd5e331cd6c6f48253254d117642c31653baa475e394657c59c1f7d" dependencies = [ "bitflags", - "crossterm_winapi 0.8.0", - "libc", - "mio", - "parking_lot", - "signal-hook", - "signal-hook-mio", - "winapi", -] - -[[package]] -name = "crossterm" -version = "0.22.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c85525306c4291d1b73ce93c8acf9c339f9b213aef6c1d85c3830cbf1c16325c" -dependencies = [ - "bitflags", - "crossterm_winapi 0.9.0", + "crossterm_winapi", "libc", "mio", "parking_lot", @@ -491,15 +475,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "crossterm_winapi" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ae1b35a484aa10e07fe0638d02301c5ad24de82d310ccbd2f3693da5f09bf1c" -dependencies = [ - "winapi", -] - [[package]] name = "ctor" version = "0.1.21" @@ -797,8 +772,8 @@ dependencies = [ [[package]] name = "gdb-server" -version = "0.11.0" -source = "git+https://github.com/probe-rs/probe-rs#5e2f6354e2d00b0ffe83682a0fd7f5b7386a21e3" +version = "0.12.0" +source = "git+https://github.com/probe-rs/probe-rs#451d9da11924fdd55f1faa5364ee2f2dae1b7254" dependencies = [ "anyhow", "async-std", @@ -837,6 +812,12 @@ name = "gimli" version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0a01e0497841a3b2db4f8afa483cce65f7e96a3498bd6c541734792aeac8fe7" + +[[package]] +name = "gimli" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" dependencies = [ "fallible-iterator", "stable_deref_trait", @@ -1116,9 +1097,9 @@ dependencies = [ [[package]] name = "jep106" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "939876d20519325db0883757e29e9858ee02919d0f03e43c74f69296caa314f4" +checksum = "e80f965a2a659a7a4d9cdb9821a869d6e33c10f3e094e8f7d01648063c425953" dependencies = [ "serde", ] @@ -1229,9 +1210,9 @@ checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" [[package]] name = "minimal-lexical" -version = "0.1.3" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c835948974f68e0bd58636fc6c5b1fbff7b297e3046f11b3b3c18bbac012c6d" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" @@ -1285,9 +1266,9 @@ dependencies = [ [[package]] name = "nom" -version = "7.0.0" +version = "7.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffd9d26838a953b4af82cbeb9f1592c6798916983959be223a7124e992742c1" +checksum = "1b1d11e1ef389c76fe5b81bcaf2ea32cf88b62bc494e19f493d0b30e7a930109" dependencies = [ "memchr", "minimal-lexical", @@ -1356,6 +1337,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "object" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67ac1d3f9a1d3616fd9a60c8d74296f22406a238b6a72f5cc1e6f314df4ffbf9" +dependencies = [ + "memchr", +] + [[package]] name = "once_cell" version = "1.8.0" @@ -1500,8 +1490,8 @@ checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" [[package]] name = "probe-rs" -version = "0.11.0" -source = "git+https://github.com/probe-rs/probe-rs#5e2f6354e2d00b0ffe83682a0fd7f5b7386a21e3" +version = "0.12.0" +source = "git+https://github.com/probe-rs/probe-rs#451d9da11924fdd55f1faa5364ee2f2dae1b7254" dependencies = [ "anyhow", "base64", @@ -1509,7 +1499,7 @@ dependencies = [ "bitfield", "bitvec", "enum-primitive-derive", - "gimli 0.25.0", + "gimli 0.26.1", "hidapi", "ihex", "jaylink", @@ -1517,7 +1507,7 @@ dependencies = [ "libftdi1-sys", "log", "num-traits", - "object 0.26.2", + "object 0.27.1", "once_cell", "probe-rs-target", "rusb", @@ -1532,8 +1522,8 @@ dependencies = [ [[package]] name = "probe-rs-cli-util" -version = "0.11.0" -source = "git+https://github.com/probe-rs/probe-rs#5e2f6354e2d00b0ffe83682a0fd7f5b7386a21e3" +version = "0.12.0" +source = "git+https://github.com/probe-rs/probe-rs#451d9da11924fdd55f1faa5364ee2f2dae1b7254" dependencies = [ "anyhow", "cargo_metadata", @@ -1555,8 +1545,8 @@ dependencies = [ [[package]] name = "probe-rs-rtt" -version = "0.11.0" -source = "git+https://github.com/probe-rs/probe-rs-rtt#43b37def680f684fc74f6c78570b40f3f48c607e" +version = "0.12.0" +source = "git+https://github.com/probe-rs/probe-rs#451d9da11924fdd55f1faa5364ee2f2dae1b7254" dependencies = [ "log", "probe-rs", @@ -1566,8 +1556,8 @@ dependencies = [ [[package]] name = "probe-rs-target" -version = "0.11.0" -source = "git+https://github.com/probe-rs/probe-rs#5e2f6354e2d00b0ffe83682a0fd7f5b7386a21e3" +version = "0.12.0" +source = "git+https://github.com/probe-rs/probe-rs#451d9da11924fdd55f1faa5364ee2f2dae1b7254" dependencies = [ "base64", "jep106", @@ -2036,9 +2026,9 @@ dependencies = [ [[package]] name = "simplelog" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59d0fe306a0ced1c88a58042dc22fc2ddd000982c26d75f6aa09a394547c41e0" +checksum = "8baa24de25f3092d9697c76f94cf09f67fca13db2ea11ce80c2f055c1aaf0795" dependencies = [ "chrono", "log", @@ -2331,7 +2321,7 @@ checksum = "39c8ce4e27049eed97cfa363a5048b09d995e209994634a0efc26a14ab6c0c23" dependencies = [ "bitflags", "cassowary", - "crossterm 0.20.0", + "crossterm", "unicode-segmentation", "unicode-width", ] diff --git a/Cargo.toml b/Cargo.toml index 3ce5ce1..fae544d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo-embed" -version = "0.11.0" +version = "0.12.0" authors = ["Noah Hüsser "] edition = "2018" description = "A utility to develop software for embedded ARM and RISC-V cores." @@ -18,9 +18,10 @@ ftdi = ["probe-rs/ftdi"] sentry = ["probe-rs-cli-util/sentry"] [dependencies] -probe-rs = { version = "0.11.0", git = "https://github.com/probe-rs/probe-rs" } -gdb-server = { version = "0.11.0", git = "https://github.com/probe-rs/probe-rs" } -probe-rs-cli-util = { version = "0.11.0", git = "https://github.com/probe-rs/probe-rs", default-features = false, features=["anyhow"] } +probe-rs = { version = "0.12.0", git = "https://github.com/probe-rs/probe-rs" } +gdb-server = { version = "0.12.0", git = "https://github.com/probe-rs/probe-rs" } +probe-rs-cli-util = { version = "0.12.0", git = "https://github.com/probe-rs/probe-rs", default-features = false, features=["anyhow"] } +probe-rs-rtt = { version = "0.12.0", git = "https://github.com/probe-rs/probe-rs" } structopt = "0.3.25" git-version = "0.3.5" @@ -31,7 +32,6 @@ colored = "2.0.0" serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0.71" } figment = { version = "0.10", features = ["toml", "json", "yaml", "env"] } -probe-rs-rtt = { version = "0.11.0", git = "https://github.com/probe-rs/probe-rs-rtt" } chrono = "0.4" crossterm = "<= 0.22.2" goblin = "0.4.2" diff --git a/src/main.rs b/src/main.rs index 6d7bfbf..ca1c81b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -529,8 +529,14 @@ fn main_try() -> Result<()> { ScanRegion::Ram }; - match Rtt::attach_region(session.clone(), &rtt_header_address) { + let mut session_handle = session.lock().unwrap(); + let memory_map = session_handle.target().memory_map.clone(); + let mut core = session_handle.core(0)?; + + match Rtt::attach_region(&mut core, &memory_map, &rtt_header_address) { Ok(rtt) => { + drop(core); + drop(session_handle); log::info!("RTT initialized."); // `App` puts the terminal into a special state, as required @@ -553,9 +559,11 @@ fn main_try() -> Result<()> { let logname = format!("{}_{}_{}", name, chip_name, Local::now().to_rfc3339()); let mut app = rttui::app::App::new(rtt, &config, logname)?; loop { - app.poll_rtt(); + let mut session_handle = session.lock().unwrap(); + let mut core = session_handle.core(0)?; + app.poll_rtt(&mut core); app.render(&defmt_state); - if app.handle_event() { + if app.handle_event(&mut core) { logging::println("Shutting down."); return Ok(()); }; diff --git a/src/rttui/app.rs b/src/rttui/app.rs index 7a5b7ed..54778c2 100644 --- a/src/rttui/app.rs +++ b/src/rttui/app.rs @@ -3,8 +3,8 @@ use crossterm::{ event::{self, KeyCode}, execute, terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, - ExecutableCommand, }; +use probe_rs::Core; use probe_rs_rtt::RttChannel; use std::{fmt::write, path::PathBuf, sync::mpsc::RecvTimeoutError}; use std::{ @@ -25,7 +25,7 @@ use super::{ event::Events, }; -use event::{DisableMouseCapture, KeyModifiers}; +use event::KeyModifiers; /// App holds the state of the application pub struct App { @@ -141,7 +141,7 @@ impl App { if file.read_to_end(&mut buffer).is_ok() { if let Ok(binary) = goblin::elf::Elf::parse(buffer.as_slice()) { for sym in &binary.syms { - if let Some(Ok(name)) = binary.strtab.get(sym.st_name) { + if let Some(name) = binary.strtab.get_at(sym.st_name) { if name == "_SEGGER_RTT" { return Some(sym.st_value); } @@ -359,7 +359,7 @@ impl App { } /// Returns true if the application should exit. - pub fn handle_event(&mut self) -> bool { + pub fn handle_event(&mut self, core: &mut Core) -> bool { match self.events.next(Duration::from_millis(10)) { Ok(event) => match event.code { KeyCode::Char('c') if event.modifiers.contains(KeyModifiers::CONTROL) => { @@ -436,7 +436,7 @@ impl App { false } KeyCode::Enter => { - self.push_rtt(); + self.push_rtt(core); false } KeyCode::Char(c) => { @@ -475,14 +475,14 @@ impl App { } /// Polls the RTT target for new data on all channels. - pub fn poll_rtt(&mut self) { + pub fn poll_rtt(&mut self, core: &mut Core) { for channel in self.tabs.iter_mut() { - channel.poll_rtt(); + channel.poll_rtt(core); } } - pub fn push_rtt(&mut self) { - self.tabs[self.current_tab].push_rtt(); + pub fn push_rtt(&mut self, core: &mut Core) { + self.tabs[self.current_tab].push_rtt(core); } } diff --git a/src/rttui/channel.rs b/src/rttui/channel.rs index 74f1db6..70c9c32 100644 --- a/src/rttui/channel.rs +++ b/src/rttui/channel.rs @@ -1,6 +1,7 @@ use std::fmt; use chrono::Local; +use probe_rs::Core; use probe_rs_rtt::{DownChannel, UpChannel}; #[derive(Debug, Copy, Clone, PartialEq, serde::Serialize, serde::Deserialize)] @@ -117,10 +118,10 @@ impl ChannelState { /// Polls the RTT target for new data on the specified channel. /// /// Processes all the new data and adds it to the linebuffer of the respective channel. - pub fn poll_rtt(&mut self) { + pub fn poll_rtt(&mut self, core: &mut Core) { // TODO: Proper error handling. let count = if let Some(channel) = self.up_channel.as_mut() { - match channel.read(self.rtt_buffer.0.as_mut()) { + match channel.read(core, self.rtt_buffer.0.as_mut()) { Ok(count) => count, Err(err) => { log::error!("\nError reading from RTT: {}", err); @@ -176,10 +177,10 @@ impl ChannelState { }; } - pub fn push_rtt(&mut self) { + pub fn push_rtt(&mut self, core: &mut Core) { if let Some(down_channel) = self.down_channel.as_mut() { self.input += "\n"; - down_channel.write(self.input.as_bytes()).unwrap(); + down_channel.write(core, self.input.as_bytes()).unwrap(); self.input.clear(); } }