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

Commit

Permalink
Merge #278
Browse files Browse the repository at this point in the history
278: Prepare for 0.12.0 release r=Dirbaio a=Yatekii



Co-authored-by: Noah Hüsser <[email protected]>
  • Loading branch information
bors[bot] and Yatekii authored Nov 24, 2021
2 parents 4b3bf66 + 20f4f2d commit 3add44a
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 71 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
88 changes: 39 additions & 49 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cargo-embed"
version = "0.11.0"
version = "0.12.0"
authors = ["Noah Hüsser <[email protected]>"]
edition = "2018"
description = "A utility to develop software for embedded ARM and RISC-V cores."
Expand All @@ -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"
Expand All @@ -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"
Expand Down
14 changes: 11 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(());
};
Expand Down
18 changes: 9 additions & 9 deletions src/rttui/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -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 {
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -436,7 +436,7 @@ impl App {
false
}
KeyCode::Enter => {
self.push_rtt();
self.push_rtt(core);
false
}
KeyCode::Char(c) => {
Expand Down Expand Up @@ -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);
}
}

Expand Down
9 changes: 5 additions & 4 deletions src/rttui/channel.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
}
}
Expand Down

0 comments on commit 3add44a

Please sign in to comment.