knurling-rs / probe-run

Run embedded programs just like native ones
Apache License 2.0
645 stars 75 forks source link

support pure RAM programs #160

Open japaric opened 3 years ago

japaric commented 3 years ago

Context: most of the time spent in running a defmt-test test suite goes into loading the test images. Program loading can take seconds whereas tests are usually completed in less than one second. If the test suite comprises of several test files the problem is further aggravated. This leads to very slow edit-compile-test cycles.

Goal: speed up program loading by at least 2x (because a erase step is not required when writing to RAM)

Implementing this requires several changes

(NOTE: we probably have the logic for these 2 steps in an old version of probe-run)

sszilvasi commented 2 years ago

I recently experimented with no-FLASH projects and ended up creating a proof-of-concept RAM-only project template by comparing two memory layouts in pico-sdk:

  1. https://github.com/raspberrypi/pico-sdk/blob/master/src/rp2_common/pico_standard_link/memmap_default.ld
  2. https://github.com/raspberrypi/pico-sdk/blob/master/src/rp2_common/pico_standard_link/memmap_no_flash.ld

As the target RP Pico used for development does actually have a FLASH, I "disabled" it by flashing picoblank to the boot loader region. The debugger RP Pico had the DapperMime firmware on it.

The RAM-only project currently works with elf2uf2-rs and teleprobe, but fails with probe-run:

$ cargo run
    Finished dev [optimized + debuginfo] target(s) in 0.05s
     Running `probe-run --chip RP2040 target/thumbv6m-none-eabi/debug/rp2040-project-template`
(HOST) INFO  success!
Error: A core architecture specific error occured

Caused by:
    Unsupported address 0x2003c550 for HW breakpoint. Breakpoint must be at address < 0x2000_0000.

Does probe-run error out due to the problem described in this issue?

japaric commented 2 years ago

Does probe-run error out due to the problem described in this issue?

doesn't look like but the analysis in the issue description is one year old and may no longer be accurate. from looking at the output of cargo run you posted it seems that loading the program to RAM worked but probe-run failed afterwards when it tried to set some breakpoints. the breakpoints are used to catch hardware faults (I don't remember if they have other uses)

Unsupported address 0x2003c550 for HW breakpoint. Breakpoint must be at address < 0x2000_0000.

this is a limitation of the v6-M variant (or I think anything that ships with FPB v1, iirc). you cannot put a hardware breakpoint in RAM (usually located at 0x2000_0000) but you can put any number of software breakpoints in RAM (software breakpoints only work on half-word writeable memory). from a quick look at the probe-rs API docs it doesn't seem like it supports software breakpoints through a high-level API but I guess it should be possible to implement software breakpoints on top of the existing API

sszilvasi commented 2 years ago

Would implementing software breakpoints on top of the existing API need to happen in the probe-rs repo then?

japaric commented 2 years ago

Would implementing software breakpoints on top of the existing API need to happen in the probe-rs repo then?

not strictly necessary but that would be the best place for such functionality to reside in.