Skip to content

Commit 8da6c29

Browse files
committed
Move xtasks to target-gen; extend README; link correctly
1 parent ff4cf85 commit 8da6c29

File tree

11 files changed

+31
-284
lines changed

11 files changed

+31
-284
lines changed

.cargo/config.toml

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
[alias]
2-
xtask = "run --package xtask --"
3-
export = "xtask export"
4-
iterate = "xtask iterate"
5-
61
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
72
rustflags = [
83
"-C",
@@ -12,12 +7,16 @@ rustflags = [
127
"-C",
138
"link-arg=-Tmemory.x",
149
# Code-size optimizations.
15-
"-Z",
16-
"trap-unreachable=no",
10+
# This requires nightly atm.
11+
# "-Z",
12+
# "trap-unreachable=no",
1713
"-C",
1814
"inline-threshold=5",
1915
"-C",
2016
"no-vectorize-loops",
2117
"-C",
2218
"force-frame-pointers=no",
2319
]
20+
21+
[build]
22+
target = "{{target-arch}}"

Cargo.toml

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
cargo-features = ["per-package-target"]
2-
31
[package]
42
authors = ["{{authors}}"]
53
edition = "2021"
64
readme = "README.md"
75
name = "{{project-name}}"
86
version = "0.1.0"
97

10-
forced-target = "{{target-arch}}"
11-
128
[dependencies]
139
cortex-m = "0.7.0"
1410
flash-algorithm = { version = "0.3.0" }
11+
rtt-target = { version = "0.3", features = ["cortex-m"] }
1512

1613
# this lets you use `cargo fix`!
1714
[[bin]]
@@ -50,6 +47,3 @@ debug = false
5047
debug-assertions = false
5148
opt-level = 0
5249
overflow-checks = false
53-
54-
[workspace]
55-
members = [".", "xtask"]

README.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,14 @@ to generate a new project from the template.
3939

4040
Building requires nightly Rust.
4141

42-
Just run `cargo export`. It spits out the flash algo in the probe-rs YAML format.
42+
Just run `target-gen export`. It spits out the flash algo in the probe-rs YAML format.
43+
44+
## Developing the algorithm
45+
46+
Building requires nightly Rust.
47+
48+
Just run `target-gen test`. It spits out the flash algo in the probe-rs YAML format and downloads it onto a target and makes a test run.
49+
You will also be able to see RTT messages.
4350

4451
# License
4552

calculate-memory.rhai

+7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ variable::set(
1212
+ parse_int(variable::get("flash-size").sub_string(2), 16)
1313
).to_hex()
1414
);
15+
variable::set(
16+
"link-address",
17+
"0x" + (
18+
parse_int(variable::get("ram-start-address").sub_string(2), 16)
19+
+ 0x20
20+
).to_hex()
21+
);
1522

1623
let target = variable::get("target");
1724

link.x

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ALGO_PLACEMENT_START_ADDRESS = {{ram-start-address}};
1+
ALGO_PLACEMENT_START_ADDRESS = {{link-address}};

rust-toolchain

-1
This file was deleted.

src/main.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use core::mem::MaybeUninit;
55

66
use flash_algorithm::*;
7+
use rtt_target::{rprintln, rtt_init_print};
78

89
struct Algorithm;
910

@@ -20,21 +21,26 @@ algorithm!(Algorithm, {
2021

2122
impl FlashAlgorithm for Algorithm {
2223
fn new(_address: u32, _clock: u32, _function: Function) -> Result<Self, ErrorCode> {
24+
rtt_init_print!();
25+
rprintln!("Init");
2326
// TODO: Add setup code for the flash algorithm.
2427
Ok(Self)
2528
}
2629

2730
fn erase_all(&mut self) -> Result<(), ErrorCode> {
31+
rprintln!("Erase All");
2832
// TODO: Add code here that erases the entire flash.
2933
Err(ErrorCode::new(0x70d0).unwrap())
3034
}
3135

32-
fn erase_sector(&mut self, _addr: u32) -> Result<(), ErrorCode> {
36+
fn erase_sector(&mut self, addr: u32) -> Result<(), ErrorCode> {
37+
rprintln!("Erase sector addr:{}", addr);
3338
// TODO: Add code here that erases a page to flash.
3439
Ok(())
3540
}
3641

37-
fn program_page(&mut self, _addr: u32, _size: u32, _data: *const u8) -> Result<(), ErrorCode> {
42+
fn program_page(&mut self, addr: u32, size: u32, _data: *const u8) -> Result<(), ErrorCode> {
43+
rprintln!("Program Page addr:{} size:{}", addr, size);
3844
// TODO: Add code here that writes a page to flash.
3945
Ok(())
4046
}

xtask/Cargo.toml

-15
This file was deleted.

xtask/src/export.rs

-83
This file was deleted.

xtask/src/iterate.rs

-127
This file was deleted.

xtask/src/main.rs

-40
This file was deleted.

0 commit comments

Comments
 (0)