Skip to content
This repository was archived by the owner on Jan 14, 2023. It is now read-only.

Commit 3add44a

Browse files
bors[bot]Yatekii
andauthored
Merge #278
278: Prepare for 0.12.0 release r=Dirbaio a=Yatekii Co-authored-by: Noah Hüsser <[email protected]>
2 parents 4b3bf66 + 20f4f2d commit 3add44a

File tree

6 files changed

+77
-71
lines changed

6 files changed

+77
-71
lines changed

CHANGELOG.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
### Fixed
1313

14+
## [0.12.0]
15+
16+
### Changed
17+
18+
- Update to probe-rs 0.12.0.
19+
1420
## [0.11.0]
1521

1622
### Added
@@ -164,7 +170,8 @@ An example is this config:
164170
## [0.6.0]
165171
- Initial release
166172

167-
[Unreleased]: https://github.com/probe-rs/cargo-embed/compare/v0.11.0..master
173+
[Unreleased]: https://github.com/probe-rs/cargo-embed/compare/v0.12.0..master
174+
[0.12.0]: https://github.com/probe-rs/cargo-embed/releases/tag/v0.11.0..v0.12.0
168175
[0.11.0]: https://github.com/probe-rs/cargo-embed/releases/tag/v0.10.1..v0.11.0
169176
[0.10.1]: https://github.com/probe-rs/cargo-embed/releases/tag/v0.10.0..v0.10.1
170177
[0.10.0]: https://github.com/probe-rs/cargo-embed/releases/tag/v0.9.0..v0.10.0

Cargo.lock

+39-49
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cargo-embed"
3-
version = "0.11.0"
3+
version = "0.12.0"
44
authors = ["Noah Hüsser <[email protected]>"]
55
edition = "2018"
66
description = "A utility to develop software for embedded ARM and RISC-V cores."
@@ -18,9 +18,10 @@ ftdi = ["probe-rs/ftdi"]
1818
sentry = ["probe-rs-cli-util/sentry"]
1919

2020
[dependencies]
21-
probe-rs = { version = "0.11.0", git = "https://github.com/probe-rs/probe-rs" }
22-
gdb-server = { version = "0.11.0", git = "https://github.com/probe-rs/probe-rs" }
23-
probe-rs-cli-util = { version = "0.11.0", git = "https://github.com/probe-rs/probe-rs", default-features = false, features=["anyhow"] }
21+
probe-rs = { version = "0.12.0", git = "https://github.com/probe-rs/probe-rs" }
22+
gdb-server = { version = "0.12.0", git = "https://github.com/probe-rs/probe-rs" }
23+
probe-rs-cli-util = { version = "0.12.0", git = "https://github.com/probe-rs/probe-rs", default-features = false, features=["anyhow"] }
24+
probe-rs-rtt = { version = "0.12.0", git = "https://github.com/probe-rs/probe-rs" }
2425

2526
structopt = "0.3.25"
2627
git-version = "0.3.5"
@@ -31,7 +32,6 @@ colored = "2.0.0"
3132
serde = { version = "1.0", features = ["derive"] }
3233
serde_json = { version = "1.0.71" }
3334
figment = { version = "0.10", features = ["toml", "json", "yaml", "env"] }
34-
probe-rs-rtt = { version = "0.11.0", git = "https://github.com/probe-rs/probe-rs-rtt" }
3535
chrono = "0.4"
3636
crossterm = "<= 0.22.2"
3737
goblin = "0.4.2"

src/main.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -529,8 +529,14 @@ fn main_try() -> Result<()> {
529529
ScanRegion::Ram
530530
};
531531

532-
match Rtt::attach_region(session.clone(), &rtt_header_address) {
532+
let mut session_handle = session.lock().unwrap();
533+
let memory_map = session_handle.target().memory_map.clone();
534+
let mut core = session_handle.core(0)?;
535+
536+
match Rtt::attach_region(&mut core, &memory_map, &rtt_header_address) {
533537
Ok(rtt) => {
538+
drop(core);
539+
drop(session_handle);
534540
log::info!("RTT initialized.");
535541

536542
// `App` puts the terminal into a special state, as required
@@ -553,9 +559,11 @@ fn main_try() -> Result<()> {
553559
let logname = format!("{}_{}_{}", name, chip_name, Local::now().to_rfc3339());
554560
let mut app = rttui::app::App::new(rtt, &config, logname)?;
555561
loop {
556-
app.poll_rtt();
562+
let mut session_handle = session.lock().unwrap();
563+
let mut core = session_handle.core(0)?;
564+
app.poll_rtt(&mut core);
557565
app.render(&defmt_state);
558-
if app.handle_event() {
566+
if app.handle_event(&mut core) {
559567
logging::println("Shutting down.");
560568
return Ok(());
561569
};

src/rttui/app.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use crossterm::{
33
event::{self, KeyCode},
44
execute,
55
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
6-
ExecutableCommand,
76
};
7+
use probe_rs::Core;
88
use probe_rs_rtt::RttChannel;
99
use std::{fmt::write, path::PathBuf, sync::mpsc::RecvTimeoutError};
1010
use std::{
@@ -25,7 +25,7 @@ use super::{
2525
event::Events,
2626
};
2727

28-
use event::{DisableMouseCapture, KeyModifiers};
28+
use event::KeyModifiers;
2929

3030
/// App holds the state of the application
3131
pub struct App {
@@ -141,7 +141,7 @@ impl App {
141141
if file.read_to_end(&mut buffer).is_ok() {
142142
if let Ok(binary) = goblin::elf::Elf::parse(buffer.as_slice()) {
143143
for sym in &binary.syms {
144-
if let Some(Ok(name)) = binary.strtab.get(sym.st_name) {
144+
if let Some(name) = binary.strtab.get_at(sym.st_name) {
145145
if name == "_SEGGER_RTT" {
146146
return Some(sym.st_value);
147147
}
@@ -359,7 +359,7 @@ impl App {
359359
}
360360

361361
/// Returns true if the application should exit.
362-
pub fn handle_event(&mut self) -> bool {
362+
pub fn handle_event(&mut self, core: &mut Core) -> bool {
363363
match self.events.next(Duration::from_millis(10)) {
364364
Ok(event) => match event.code {
365365
KeyCode::Char('c') if event.modifiers.contains(KeyModifiers::CONTROL) => {
@@ -436,7 +436,7 @@ impl App {
436436
false
437437
}
438438
KeyCode::Enter => {
439-
self.push_rtt();
439+
self.push_rtt(core);
440440
false
441441
}
442442
KeyCode::Char(c) => {
@@ -475,14 +475,14 @@ impl App {
475475
}
476476

477477
/// Polls the RTT target for new data on all channels.
478-
pub fn poll_rtt(&mut self) {
478+
pub fn poll_rtt(&mut self, core: &mut Core) {
479479
for channel in self.tabs.iter_mut() {
480-
channel.poll_rtt();
480+
channel.poll_rtt(core);
481481
}
482482
}
483483

484-
pub fn push_rtt(&mut self) {
485-
self.tabs[self.current_tab].push_rtt();
484+
pub fn push_rtt(&mut self, core: &mut Core) {
485+
self.tabs[self.current_tab].push_rtt(core);
486486
}
487487
}
488488

src/rttui/channel.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::fmt;
22

33
use chrono::Local;
4+
use probe_rs::Core;
45
use probe_rs_rtt::{DownChannel, UpChannel};
56

67
#[derive(Debug, Copy, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
@@ -117,10 +118,10 @@ impl ChannelState {
117118
/// Polls the RTT target for new data on the specified channel.
118119
///
119120
/// Processes all the new data and adds it to the linebuffer of the respective channel.
120-
pub fn poll_rtt(&mut self) {
121+
pub fn poll_rtt(&mut self, core: &mut Core) {
121122
// TODO: Proper error handling.
122123
let count = if let Some(channel) = self.up_channel.as_mut() {
123-
match channel.read(self.rtt_buffer.0.as_mut()) {
124+
match channel.read(core, self.rtt_buffer.0.as_mut()) {
124125
Ok(count) => count,
125126
Err(err) => {
126127
log::error!("\nError reading from RTT: {}", err);
@@ -176,10 +177,10 @@ impl ChannelState {
176177
};
177178
}
178179

179-
pub fn push_rtt(&mut self) {
180+
pub fn push_rtt(&mut self, core: &mut Core) {
180181
if let Some(down_channel) = self.down_channel.as_mut() {
181182
self.input += "\n";
182-
down_channel.write(self.input.as_bytes()).unwrap();
183+
down_channel.write(core, self.input.as_bytes()).unwrap();
183184
self.input.clear();
184185
}
185186
}

0 commit comments

Comments
 (0)