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

Commit 62818bd

Browse files
committed
Update probe-rs to version 0.13.0
This patch doesn't implement 64-bit support, but only inserts conversions from u32 to u64 where necessary.
1 parent e9e73a8 commit 62818bd

File tree

10 files changed

+105
-78
lines changed

10 files changed

+105
-78
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
1414
- [#317] Clarify "can't determine stack overflow" error message
1515
- [#314] Clarify documentation in README
1616
- [#293] Update snapshot tests to new TRACE output
17+
- Update probe-rs to 0.13.0 (does not yet implement 64-bit support)
1718

1819
[#328]: https://github.com/knurling-rs/probe-run/pull/328
1920
[#326]: https://github.com/knurling-rs/probe-run/pull/326

Cargo.lock

Lines changed: 44 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ gimli = { version = "0.26", default-features = false }
2424
git-version = "0.3"
2525
log = "0.4"
2626
object = { version = "0.27", default-features = false }
27-
probe-rs = "0.12"
28-
probe-rs-rtt = "0.12"
27+
probe-rs = "0.13"
28+
probe-rs-rtt = "0.13"
2929
signal-hook = "0.3"
3030
structopt = "0.3"
3131

src/backtrace/unwind.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,13 @@ pub(crate) fn target(core: &mut Core, elf: &Elf, active_ram_region: &Option<RamR
5656
let mut registers = Registers::new(lr, sp, core);
5757

5858
loop {
59-
if let Some(outcome) =
60-
check_hard_fault(pc, &elf.vector_table, &mut output, sp, active_ram_region)
61-
{
59+
if let Some(outcome) = check_hard_fault(
60+
pc,
61+
&elf.vector_table,
62+
&mut output,
63+
sp.into(),
64+
active_ram_region,
65+
) {
6266
output.outcome = outcome;
6367
}
6468

@@ -114,7 +118,10 @@ pub(crate) fn target(core: &mut Core, elf: &Elf, active_ram_region: &Option<RamR
114118
let sp = unwrap_or_return_output!(registers.get(registers::SP));
115119
let ram_bounds = active_ram_region
116120
.as_ref()
117-
.map(|ram_region| ram_region.range.clone())
121+
.map(|ram_region| {
122+
ram_region.range.start.try_into().unwrap_or(u32::MAX)
123+
..ram_region.range.end.try_into().unwrap_or(u32::MAX)
124+
})
118125
.unwrap_or(cortexm::VALID_RAM_ADDRESS);
119126
let stacked = if let Some(stacked) =
120127
unwrap_or_return_output!(Stacked::read(registers.core, sp, fpu, ram_bounds))
@@ -195,7 +202,7 @@ fn overflowed_stack(sp: u32, active_ram_region: &Option<RamRegion>) -> bool {
195202
// NOTE stack is full descending; meaning the stack pointer can be
196203
// `ORIGIN(RAM) + LENGTH(RAM)`
197204
let range = active_ram_region.range.start..=active_ram_region.range.end;
198-
!range.contains(&sp)
205+
!range.contains(&sp.into())
199206
} else {
200207
log::warn!("no RAM region appears to contain the stack; probe-run can't determine if this was a stack overflow");
201208
false

src/canary.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::time::Instant;
22

3-
use probe_rs::{Core, MemoryInterface, Session};
3+
use probe_rs::{Core, MemoryInterface, RegisterValue, Session};
44

55
use crate::{registers::PC, Elf, TargetInfo, TIMEOUT};
66

@@ -116,7 +116,7 @@ impl Canary {
116116
}
117117
let mut canary = vec![0; self.size];
118118
let start = Instant::now();
119-
core.read_8(self.address, &mut canary)?;
119+
core.read_8(self.address.into(), &mut canary)?;
120120
let seconds = start.elapsed().as_secs_f64();
121121
log::trace!(
122122
"reading canary took {seconds:.3}s ({:.2} KiB/s)",
@@ -195,18 +195,21 @@ fn paint_stack(core: &mut Core, start: u32, end: u32) -> Result<(), probe_rs::Er
195195

196196
// write subroutine to RAM
197197
// NOTE: add `SUBROUTINE_LENGTH` to `start`, to avoid the subroutine overwriting itself
198-
core.write_8(start, &subroutine(start + SUBROUTINE_LENGTH as u32, end))?;
198+
core.write_8(
199+
start.into(),
200+
&subroutine(start + SUBROUTINE_LENGTH as u32, end),
201+
)?;
199202

200203
// store current PC and set PC to beginning of subroutine
201-
let previous_pc = core.read_core_reg(PC)?;
204+
let previous_pc: RegisterValue = core.read_core_reg(PC)?;
202205
core.write_core_reg(PC, start)?;
203206

204207
// execute the subroutine and wait for it to finish
205208
core.run()?;
206209
core.wait_for_core_halted(TIMEOUT)?;
207210

208211
// overwrite subroutine
209-
core.write_8(start, &[CANARY_VALUE; SUBROUTINE_LENGTH])?;
212+
core.write_8(start.into(), &[CANARY_VALUE; SUBROUTINE_LENGTH])?;
210213

211214
// reset PC to where it was before
212215
core.write_core_reg(PC, previous_pc)?;

src/elf.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ fn extract_symbols(elf: &ObjectFile) -> anyhow::Result<Symbols> {
200200
main_fn_address.ok_or_else(|| anyhow!("`main` symbol not found"))?;
201201

202202
Ok(Symbols {
203-
rtt_buffer_address,
203+
rtt_buffer_address: rtt_buffer_address.map(|v| v.into()),
204204
program_uses_heap,
205-
main_fn_address: main_function_address,
205+
main_fn_address: main_function_address.into(),
206206
})
207207
}

src/main.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use probe_rs::{
2727
flashing::{self, Format},
2828
Core,
2929
DebugProbeError::ProbeSpecific,
30-
MemoryInterface as _, Session,
30+
MemoryInterface as _, Permissions, Session,
3131
};
3232
use probe_rs_rtt::{Rtt, ScanRegion, UpChannel};
3333
use signal_hook::consts::signal;
@@ -63,9 +63,9 @@ fn run_target_program(elf_path: &Path, chip_name: &str, opts: &cli::Opts) -> any
6363

6464
let probe_target = target_info.probe_target.clone();
6565
let mut sess = if opts.connect_under_reset {
66-
probe.attach_under_reset(probe_target)?
66+
probe.attach_under_reset(probe_target, Permissions::default())?
6767
} else {
68-
let probe_attach = probe.attach(probe_target);
68+
let probe_attach = probe.attach(probe_target, Permissions::default());
6969
if let Err(probe_rs::Error::Probe(ProbeSpecific(e))) = &probe_attach {
7070
// FIXME Using `to_string().contains(...)` is a workaround as the concrete type
7171
// of `e` is not public and therefore does not allow downcasting.
@@ -187,7 +187,7 @@ fn start_program(sess: &mut Session, elf: &Elf) -> anyhow::Result<()> {
187187
let mut core = sess.core(0)?;
188188

189189
log::debug!("starting device");
190-
if core.get_available_breakpoint_units()? == 0 {
190+
if core.available_breakpoint_units()? == 0 {
191191
if elf.rtt_buffer_address().is_some() {
192192
bail!("RTT not supported on device without HW breakpoints");
193193
} else {
@@ -199,7 +199,7 @@ fn start_program(sess: &mut Session, elf: &Elf) -> anyhow::Result<()> {
199199
set_rtt_to_blocking(&mut core, elf.main_fn_address(), rtt_buffer_address)?
200200
}
201201

202-
core.set_hw_breakpoint(cortexm::clear_thumb_bit(elf.vector_table.hard_fault))?;
202+
core.set_hw_breakpoint(cortexm::clear_thumb_bit(elf.vector_table.hard_fault).into())?;
203203
core.run()?;
204204

205205
Ok(())
@@ -212,7 +212,7 @@ fn set_rtt_to_blocking(
212212
rtt_buffer_address: u32,
213213
) -> anyhow::Result<()> {
214214
// set and wait for a hardware breakpoint at the beginning of `fn main()`
215-
core.set_hw_breakpoint(main_fn_address)?;
215+
core.set_hw_breakpoint(main_fn_address.into())?;
216216
core.run()?;
217217
core.wait_for_core_halted(Duration::from_secs(5))?;
218218

@@ -222,16 +222,16 @@ fn set_rtt_to_blocking(
222222

223223
// read flags
224224
let channel_flags = &mut [0];
225-
core.read_32(rtt_buffer_address, channel_flags)?;
225+
core.read_32(rtt_buffer_address.into(), channel_flags)?;
226226
// modify flags to blocking
227227
const MODE_MASK: u32 = 0b11;
228228
const MODE_BLOCK_IF_FULL: u32 = 0b10;
229229
let modified_channel_flags = (channel_flags[0] & !MODE_MASK) | MODE_BLOCK_IF_FULL;
230230
// write flags back
231-
core.write_word_32(rtt_buffer_address, modified_channel_flags)?;
231+
core.write_word_32(rtt_buffer_address.into(), modified_channel_flags)?;
232232

233233
// clear the breakpoint we set before
234-
core.clear_hw_breakpoint(main_fn_address)?;
234+
core.clear_hw_breakpoint(main_fn_address.into())?;
235235

236236
Ok(())
237237
}

0 commit comments

Comments
 (0)