bup: it works!

This commit is contained in:
Lotte Steenbrink 2020-06-19 10:54:20 +02:00
parent ed537ec7e1
commit 482ddc59d0
4 changed files with 34 additions and 6 deletions

View file

@ -18,7 +18,7 @@ debug = 1
debug-assertions = true # !
incremental = false
lto = "fat"
opt-level = 'z' # !
opt-level = 0
overflow-checks = false
[profile.release]

1
tools/Cargo.lock generated
View file

@ -169,6 +169,7 @@ dependencies = [
"probe-rs",
"probe-rs-rtt",
"rustc-demangle",
"thiserror",
"xmas-elf",
]

View file

@ -15,3 +15,4 @@ probe-rs = "0.6.2"
probe-rs-rtt = "0.1.0"
rustc-demangle = "0.1.16"
xmas-elf = "0.7.0"
thiserror = "1.0.11"

View file

@ -13,6 +13,7 @@ use std::{
process,
rc::Rc,
};
use core::fmt::Error;
use anyhow::{anyhow, bail};
use arrayref::array_ref;
@ -192,17 +193,42 @@ fn notmain() -> Result<i32, anyhow::Error> {
// run
let core = Rc::new(core);
let mut rtt = Rtt::attach_region(
core.clone(),
&sess,
&ScanRegion::Exact(rtt_addr.ok_or_else(|| anyhow!("RTT control block not available"))?),
)?;
let mut num_retries = 5;
let mut rtt: Result<Rtt, probe_rs_rtt::Error>;
loop {
// TODO how do i best to this without allocating two rtts
rtt = Rtt::attach_region(
core.clone(),
&sess,
&ScanRegion::Exact(rtt_addr.ok_or_else(|| anyhow!("RTT control block not available"))?), // todo only do this once?
);
// todo clean up control flow
if rtt.is_ok() {
log::info!("successfully attached rtt");
break;
}
num_retries -= 1;
if num_retries == 0 {
// todo return last err instead
break;
}
log::info!("Rtt::attach_region failed. retrying.");
}
log::info!("go rtt");
let channel = rtt
.unwrap()
.up_channels()
.take(0)
.ok_or_else(|| anyhow!("RTT up channel 0 not found"))?;
log::info!("chan");
static CONTINUE: AtomicBool = AtomicBool::new(true);
ctrlc::set_handler(|| {