Skip to content

Commit bac0a09

Browse files
authored
Merge pull request #1 from usbalbin/code
Code
2 parents 75a307e + 1a72867 commit bac0a09

File tree

27 files changed

+12466
-0
lines changed

27 files changed

+12466
-0
lines changed

.github/workflows/example.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
on:
2+
pull_request:
3+
merge_group:
4+
5+
name: example-simple
6+
7+
# Make sure CI fails on all warnings, including Clippy lints
8+
env:
9+
RUSTFLAGS: "-Dwarnings"
10+
11+
jobs:
12+
ci:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
rust:
17+
- stable
18+
19+
steps:
20+
- uses: actions/checkout@v2
21+
- uses: actions-rs/toolchain@v1
22+
with:
23+
profile: minimal
24+
toolchain: ${{ matrix.rust }}
25+
target: thumbv7em-none-eabihf
26+
override: true
27+
28+
- name: Format
29+
working-directory: ./examples/simple
30+
run: cargo fmt
31+
- name: Regular build
32+
working-directory: ./examples/simple
33+
run: cargo check
34+
- name: Clippy
35+
working-directory: ./examples/simple
36+
run: cargo clippy

.github/workflows/macros.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
on:
2+
pull_request:
3+
merge_group:
4+
5+
name: macros
6+
7+
# Make sure CI fails on all warnings, including Clippy lints
8+
env:
9+
RUSTFLAGS: "-Dwarnings"
10+
11+
jobs:
12+
ci:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
rust:
17+
- stable
18+
19+
steps:
20+
- uses: actions/checkout@v2
21+
- uses: actions-rs/toolchain@v1
22+
with:
23+
profile: minimal
24+
toolchain: ${{ matrix.rust }}
25+
override: true
26+
27+
- name: Format
28+
working-directory: ./macros
29+
run: cargo fmt
30+
- name: Regular build
31+
working-directory: ./macros
32+
run: cargo check
33+
- name: Clippy
34+
working-directory: ./macros
35+
run: cargo clippy
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
on:
2+
pull_request:
3+
merge_group:
4+
5+
name: probe-plotter-tools
6+
7+
# Make sure CI fails on all warnings, including Clippy lints
8+
env:
9+
RUSTFLAGS: "-Dwarnings"
10+
11+
jobs:
12+
ci:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
rust:
17+
- stable
18+
19+
steps:
20+
- uses: actions/checkout@v2
21+
- uses: actions-rs/toolchain@v1
22+
with:
23+
profile: minimal
24+
toolchain: ${{ matrix.rust }}
25+
override: true
26+
27+
- name: Install libudev (linux)
28+
run: |
29+
sudo apt update
30+
sudo apt install -y libudev-dev
31+
32+
- name: Format
33+
working-directory: ./probe-plotter-tools
34+
run: cargo fmt
35+
- name: Regular build
36+
working-directory: ./probe-plotter-tools
37+
run: cargo check
38+
- name: Clippy
39+
working-directory: ./probe-plotter-tools
40+
run: cargo clippy
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
on:
2+
pull_request:
3+
merge_group:
4+
5+
name: probe-plotter
6+
7+
# Make sure CI fails on all warnings, including Clippy lints
8+
env:
9+
RUSTFLAGS: "-Dwarnings"
10+
11+
jobs:
12+
ci:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
rust:
17+
- stable
18+
19+
steps:
20+
- uses: actions/checkout@v2
21+
- uses: actions-rs/toolchain@v1
22+
with:
23+
profile: minimal
24+
toolchain: ${{ matrix.rust }}
25+
target: thumbv7em-none-eabihf
26+
override: true
27+
28+
- name: Format
29+
working-directory: ./probe-plotter
30+
run: cargo fmt
31+
- name: Regular build
32+
working-directory: ./probe-plotter
33+
run: cargo check
34+
- name: Clippy
35+
working-directory: ./probe-plotter
36+
run: cargo clippy

README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# probe-plotter
2+
3+
A set of tools to plot values from the target to graph in rerun with minimal performance impact. This project is based on code from `defmt` and `cortex_m`'s `singleton` macro. It also uses rerun for visualization.
4+
5+
* probe-plotter - The target side library
6+
* probe-plotter-tools - The host side application
7+
8+
```rust
9+
#![no_std]
10+
#![no_main]
11+
12+
use cortex_m_rt::entry;
13+
use panic_halt as _;
14+
15+
#[entry]
16+
fn main() -> ! {
17+
use probe_plotter::make_metric;
18+
let mut sawtooth = make_metric!(SAWTOOTH: i32 = 42, "(x / 10) % 100").unwrap();
19+
let mut sine = make_metric!(SINE: i32 = 42, "100 * sin(2 * pi * x / 4000)").unwrap();
20+
loop {
21+
for i in 0..i32::MAX {
22+
sawtooth.set(i);
23+
sine.set(i);
24+
cortex_m::asm::delay(100_000);
25+
}
26+
}
27+
}
28+
```
29+
30+
The formulas seen in the `make_metric` macro invocation are computed by the host and will thus have zero impact on the targets performance. The `set` method on the metrics object is simply a volatile store which is quite cheap. The host will then read that value using the debug probe at regular intervals and update the graph on any changes.
31+
32+
##### Prerequisits
33+
probe-plotter uses the Rerun viewer for visualizing the graphs. Please [make sure to have that installed](https://rerun.io/docs/getting-started/installing-viewer#installing-the-viewer). Also make sure to have libudev installed.
34+
35+
##### To run the tool
36+
37+
```
38+
cd probe-plotter-host
39+
cargo run /path/to/elf chip_name
40+
```
41+
42+
So for example plotting the example in examples/simple on a Nucleo-G474RE
43+
44+
```
45+
cd examples/simple
46+
cargo run # Let it flash and then cancel (Ctrl+C) to let the target continue running in the background while giving up access to the probe
47+
48+
cd ../probe-plotter-tools
49+
cargo run ../examples/simple/target/thumbv7em-none-eabihf/debug/simple stm32g474retx
50+
# Rerun will open with a graph showing all created metrics objects
51+
```
52+
53+
<img width="2880" height="1920" alt="Screenshot" src="https://github.com/user-attachments/assets/5f7f20c9-009d-42c7-9613-789ae26afe54" />

Screenshot.png

717 KB
Loading

examples/simple/.cargo/config.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[target.thumbv7em-none-eabihf]
2+
runner = 'probe-rs run --connect-under-reset'
3+
4+
[build]
5+
target = "thumbv7em-none-eabihf"
6+
7+
rustflags = [
8+
"-C", "link-arg=-Tlink.x",
9+
"-C", "link-arg=-Tdefmt.x"
10+
]

examples/simple/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target

0 commit comments

Comments
 (0)