Adjusted template for STM32F103
This commit is contained in:
commit
94dce3b2e2
|
@ -0,0 +1,19 @@
|
||||||
|
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
|
||||||
|
# TODO(2) replace `$CHIP` with your chip's name (see `probe-run --list-chips` output)
|
||||||
|
runner = "probe-run --chip STM32F103CB"
|
||||||
|
rustflags = [
|
||||||
|
"-C", "linker=flip-link",
|
||||||
|
"-C", "link-arg=-Tlink.x",
|
||||||
|
"-C", "link-arg=-Tdefmt.x",
|
||||||
|
# This is needed if your flash or ram addresses are not aligned to 0x10000 in memory.x
|
||||||
|
# See https://github.com/rust-embedded/cortex-m-quickstart/pull/95
|
||||||
|
"-C", "link-arg=--nmagic",
|
||||||
|
]
|
||||||
|
|
||||||
|
[build]
|
||||||
|
target = "thumbv7m-none-eabi" # Cortex-M3
|
||||||
|
|
||||||
|
|
||||||
|
[alias]
|
||||||
|
rb = "run --bin"
|
||||||
|
rrb = "run --release --bin"
|
|
@ -0,0 +1,2 @@
|
||||||
|
/target
|
||||||
|
Cargo.lock
|
|
@ -0,0 +1,79 @@
|
||||||
|
[package]
|
||||||
|
# TODO(1) fix `authors` and `name` if you didn't use `cargo-generate`
|
||||||
|
authors = ["LongHairedHacker <sebastian@sebastians-site.de>"]
|
||||||
|
name = "wspr-beacon"
|
||||||
|
edition = "2018"
|
||||||
|
version = "0.1.0"
|
||||||
|
|
||||||
|
[workspace]
|
||||||
|
members = ["testsuite"]
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
cortex-m = "~0.7.1"
|
||||||
|
cortex-m-rt = "~0.6.13"
|
||||||
|
defmt = "~0.2.0"
|
||||||
|
defmt-rtt = "~0.2.0"
|
||||||
|
panic-probe = { version = "~0.2.0", features = ["print-defmt"] }
|
||||||
|
stm32f1xx-hal = { version = "~0.6.1", features = ["stm32f103", "rt"] }
|
||||||
|
embedded-hal = {version = "~0.2.3", feature = ["unproven"]}
|
||||||
|
|
||||||
|
[features]
|
||||||
|
# set logging levels here
|
||||||
|
default = [
|
||||||
|
"defmt-default",
|
||||||
|
# "dependency-a/defmt-trace",
|
||||||
|
]
|
||||||
|
|
||||||
|
# do NOT modify these features
|
||||||
|
defmt-default = []
|
||||||
|
defmt-trace = []
|
||||||
|
defmt-debug = []
|
||||||
|
defmt-info = []
|
||||||
|
defmt-warn = []
|
||||||
|
defmt-error = []
|
||||||
|
|
||||||
|
# cargo build/run
|
||||||
|
[profile.dev]
|
||||||
|
codegen-units = 1
|
||||||
|
debug = 2
|
||||||
|
debug-assertions = true # <-
|
||||||
|
incremental = false
|
||||||
|
opt-level = 3 # <-
|
||||||
|
overflow-checks = true # <-
|
||||||
|
|
||||||
|
# cargo test
|
||||||
|
[profile.test]
|
||||||
|
codegen-units = 1
|
||||||
|
debug = 2
|
||||||
|
debug-assertions = true # <-
|
||||||
|
incremental = false
|
||||||
|
opt-level = 3 # <-
|
||||||
|
overflow-checks = true # <-
|
||||||
|
|
||||||
|
# cargo build/run --release
|
||||||
|
[profile.release]
|
||||||
|
codegen-units = 1
|
||||||
|
debug = 2
|
||||||
|
debug-assertions = false # <-
|
||||||
|
incremental = false
|
||||||
|
lto = 'fat'
|
||||||
|
opt-level = 3 # <-
|
||||||
|
overflow-checks = false # <-
|
||||||
|
|
||||||
|
# cargo test --release
|
||||||
|
[profile.bench]
|
||||||
|
codegen-units = 1
|
||||||
|
debug = 2
|
||||||
|
debug-assertions = false # <-
|
||||||
|
incremental = false
|
||||||
|
lto = 'fat'
|
||||||
|
opt-level = 3 # <-
|
||||||
|
overflow-checks = false # <-
|
||||||
|
|
||||||
|
# uncomment this to switch from the crates.io version of defmt to its git version
|
||||||
|
# check app-template's README for instructions
|
||||||
|
# [patch.crates-io]
|
||||||
|
# defmt = { git = "https://github.com/knurling-rs/defmt", rev = "use defmt version reported by `probe-run --version`" }
|
||||||
|
# defmt-rtt = { git = "https://github.com/knurling-rs/defmt", rev = "use defmt version reported by `probe-run --version`" }
|
||||||
|
# defmt-test = { git = "https://github.com/knurling-rs/defmt", rev = "use defmt version reported by `probe-run --version`" }
|
||||||
|
# panic-probe = { git = "https://github.com/knurling-rs/defmt", rev = "use defmt version reported by `probe-run --version`" }
|
|
@ -0,0 +1,6 @@
|
||||||
|
/* Linker script for the STM32F103C8T6 */
|
||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
FLASH : ORIGIN = 0x08000000, LENGTH = 64K
|
||||||
|
RAM : ORIGIN = 0x20000000, LENGTH = 20K
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
#![no_main]
|
||||||
|
#![no_std]
|
||||||
|
|
||||||
|
use wspr_beacon as _; // global logger + panicking-behavior + memory layout
|
||||||
|
|
||||||
|
#[cortex_m_rt::entry]
|
||||||
|
fn main() -> ! {
|
||||||
|
defmt::info!("Hello, world!");
|
||||||
|
|
||||||
|
wspr_beacon::exit()
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
#![no_std]
|
||||||
|
|
||||||
|
use core::sync::atomic::{AtomicUsize, Ordering};
|
||||||
|
|
||||||
|
use defmt_rtt as _; // global logger
|
||||||
|
|
||||||
|
use panic_probe as _;
|
||||||
|
use stm32f1xx_hal as _;
|
||||||
|
|
||||||
|
// same panicking *behavior* as `panic-probe` but doesn't print a panic message
|
||||||
|
// this prevents the panic message being printed *twice* when `defmt::panic` is invoked
|
||||||
|
#[defmt::panic_handler]
|
||||||
|
fn panic() -> ! {
|
||||||
|
cortex_m::asm::udf()
|
||||||
|
}
|
||||||
|
|
||||||
|
static COUNT: AtomicUsize = AtomicUsize::new(0);
|
||||||
|
defmt::timestamp!("{=usize}", {
|
||||||
|
// NOTE(no-CAS) `timestamps` runs with interrupts disabled
|
||||||
|
let n = COUNT.load(Ordering::Relaxed);
|
||||||
|
COUNT.store(n + 1, Ordering::Relaxed);
|
||||||
|
n
|
||||||
|
});
|
||||||
|
|
||||||
|
/// Terminates the application and makes `probe-run` exit with exit-code = 0
|
||||||
|
pub fn exit() -> ! {
|
||||||
|
loop {
|
||||||
|
cortex_m::asm::bkpt();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
[package]
|
||||||
|
# TODO(1) fix `authors` if you didn't use `cargo-generate`
|
||||||
|
authors = ["LongHairedHacker <sebastian@sebastians-site.de>"]
|
||||||
|
name = "testsuite"
|
||||||
|
publish = false
|
||||||
|
edition = "2018"
|
||||||
|
version = "0.1.0"
|
||||||
|
|
||||||
|
[[test]]
|
||||||
|
name = "test"
|
||||||
|
harness = false
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
wspr-beacon = { path = ".." }
|
||||||
|
cortex-m = "0.7.1"
|
||||||
|
cortex-m-rt = "0.6.12"
|
||||||
|
defmt = "0.2.0"
|
||||||
|
defmt-rtt = "0.2.0"
|
||||||
|
defmt-test = "0.2.0"
|
||||||
|
panic-probe = { version = "0.2.0", features = ["print-defmt"] }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
# set logging levels here
|
||||||
|
default = [
|
||||||
|
# in tests, enable all logs
|
||||||
|
"defmt-trace",
|
||||||
|
# "dependency-a/defmt-trace",
|
||||||
|
]
|
||||||
|
|
||||||
|
# do NOT modify these features
|
||||||
|
defmt-default = []
|
||||||
|
defmt-trace = []
|
||||||
|
defmt-debug = []
|
||||||
|
defmt-info = []
|
||||||
|
defmt-warn = []
|
||||||
|
defmt-error = []
|
|
@ -0,0 +1,21 @@
|
||||||
|
#![no_std]
|
||||||
|
#![no_main]
|
||||||
|
|
||||||
|
use wspr_beacon as _; // memory layout + panic handler
|
||||||
|
|
||||||
|
// See https://crates.io/crates/defmt-test/0.1.0 for more documentation (e.g. about the 'state'
|
||||||
|
// feature)
|
||||||
|
#[defmt_test::tests]
|
||||||
|
mod tests {
|
||||||
|
use defmt::{assert, assert_eq};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn assert_true() {
|
||||||
|
assert!(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn assert_eq() {
|
||||||
|
assert_eq!(24, 42, "TODO: write actual tests")
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue