mirror of
https://github.com/ferrous-systems/embedded-trainings-2020.git
synced 2024-05-19 08:48:17 +00:00
bup: it works!
This commit is contained in:
parent
ed537ec7e1
commit
482ddc59d0
|
@ -18,7 +18,7 @@ debug = 1
|
||||||
debug-assertions = true # !
|
debug-assertions = true # !
|
||||||
incremental = false
|
incremental = false
|
||||||
lto = "fat"
|
lto = "fat"
|
||||||
opt-level = 'z' # !
|
opt-level = 0
|
||||||
overflow-checks = false
|
overflow-checks = false
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
|
|
1
tools/Cargo.lock
generated
1
tools/Cargo.lock
generated
|
@ -169,6 +169,7 @@ dependencies = [
|
||||||
"probe-rs",
|
"probe-rs",
|
||||||
"probe-rs-rtt",
|
"probe-rs-rtt",
|
||||||
"rustc-demangle",
|
"rustc-demangle",
|
||||||
|
"thiserror",
|
||||||
"xmas-elf",
|
"xmas-elf",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -15,3 +15,4 @@ probe-rs = "0.6.2"
|
||||||
probe-rs-rtt = "0.1.0"
|
probe-rs-rtt = "0.1.0"
|
||||||
rustc-demangle = "0.1.16"
|
rustc-demangle = "0.1.16"
|
||||||
xmas-elf = "0.7.0"
|
xmas-elf = "0.7.0"
|
||||||
|
thiserror = "1.0.11"
|
||||||
|
|
|
@ -13,6 +13,7 @@ use std::{
|
||||||
process,
|
process,
|
||||||
rc::Rc,
|
rc::Rc,
|
||||||
};
|
};
|
||||||
|
use core::fmt::Error;
|
||||||
|
|
||||||
use anyhow::{anyhow, bail};
|
use anyhow::{anyhow, bail};
|
||||||
use arrayref::array_ref;
|
use arrayref::array_ref;
|
||||||
|
@ -192,17 +193,42 @@ fn notmain() -> Result<i32, anyhow::Error> {
|
||||||
// run
|
// run
|
||||||
|
|
||||||
let core = Rc::new(core);
|
let core = Rc::new(core);
|
||||||
let mut rtt = Rtt::attach_region(
|
let mut num_retries = 5;
|
||||||
core.clone(),
|
|
||||||
&sess,
|
let mut rtt: Result<Rtt, probe_rs_rtt::Error>;
|
||||||
&ScanRegion::Exact(rtt_addr.ok_or_else(|| anyhow!("RTT control block not available"))?),
|
|
||||||
)?;
|
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
|
let channel = rtt
|
||||||
|
.unwrap()
|
||||||
.up_channels()
|
.up_channels()
|
||||||
.take(0)
|
.take(0)
|
||||||
.ok_or_else(|| anyhow!("RTT up channel 0 not found"))?;
|
.ok_or_else(|| anyhow!("RTT up channel 0 not found"))?;
|
||||||
|
|
||||||
|
log::info!("chan");
|
||||||
|
|
||||||
static CONTINUE: AtomicBool = AtomicBool::new(true);
|
static CONTINUE: AtomicBool = AtomicBool::new(true);
|
||||||
|
|
||||||
ctrlc::set_handler(|| {
|
ctrlc::set_handler(|| {
|
||||||
|
|
Loading…
Reference in a new issue