aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/stm32h7b0/.cargo/config.toml8
-rw-r--r--examples/stm32h7b0/Cargo.toml74
-rw-r--r--examples/stm32h7b0/build.rs35
-rw-r--r--examples/stm32h7b0/memory.x5
-rw-r--r--examples/stm32h7b0/src/bin/ospi_memory_mapped.rs (renamed from examples/stm32h7/src/bin/ospi_memory_mapped.rs)5
5 files changed, 124 insertions, 3 deletions
diff --git a/examples/stm32h7b0/.cargo/config.toml b/examples/stm32h7b0/.cargo/config.toml
new file mode 100644
index 000000000..870849a27
--- /dev/null
+++ b/examples/stm32h7b0/.cargo/config.toml
@@ -0,0 +1,8 @@
1[target.thumbv7em-none-eabihf]
2runner = 'probe-rs run --chip STM32H7B0VBTx'
3
4[build]
5target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU)
6
7[env]
8DEFMT_LOG = "trace"
diff --git a/examples/stm32h7b0/Cargo.toml b/examples/stm32h7b0/Cargo.toml
new file mode 100644
index 000000000..02c620443
--- /dev/null
+++ b/examples/stm32h7b0/Cargo.toml
@@ -0,0 +1,74 @@
1[package]
2edition = "2021"
3name = "embassy-stm32h7b0-examples"
4version = "0.1.0"
5license = "MIT OR Apache-2.0"
6
7[dependencies]
8embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32h7b0vb", "time-driver-tim2", "exti", "memory-x", "unstable-pac", "chrono"] }
9embassy-sync = { version = "0.6.0", path = "../../embassy-sync", features = ["defmt"] }
10embassy-embedded-hal = { version = "0.2.0", path = "../../embassy-embedded-hal" }
11embassy-executor = { version = "0.6.1", path = "../../embassy-executor", features = ["task-arena-size-32768", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] }
12embassy-time = { version = "0.3.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
13embassy-net = { version = "0.4.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6", "dns"] }
14embassy-usb = { version = "0.3.0", path = "../../embassy-usb", features = ["defmt"] }
15embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
16
17defmt = "0.3"
18defmt-rtt = "0.4"
19
20cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] }
21cortex-m-rt = "0.7.0"
22embedded-hal = "0.2.6"
23embedded-hal-1 = { package = "embedded-hal", version = "1.0" }
24embedded-hal-async = { version = "1.0" }
25embedded-nal-async = "0.8.0"
26embedded-io-async = { version = "0.6.1" }
27panic-probe = { version = "0.3", features = ["print-defmt"] }
28heapless = { version = "0.8", default-features = false }
29rand_core = "0.6.3"
30critical-section = "1.1"
31micromath = "2.0.0"
32stm32-fmc = "0.3.0"
33embedded-storage = "0.3.1"
34static_cell = "2"
35chrono = { version = "^0.4", default-features = false }
36grounded = "0.2.0"
37
38# cargo build/run
39[profile.dev]
40codegen-units = 1
41debug = 2
42debug-assertions = true # <-
43incremental = false
44opt-level = 3 # <-
45overflow-checks = true # <-
46
47# cargo test
48[profile.test]
49codegen-units = 1
50debug = 2
51debug-assertions = true # <-
52incremental = false
53opt-level = 3 # <-
54overflow-checks = true # <-
55
56# cargo build/run --release
57[profile.release]
58codegen-units = 1
59debug = 2
60debug-assertions = false # <-
61incremental = false
62lto = 'fat'
63opt-level = 3 # <-
64overflow-checks = false # <-
65
66# cargo test --release
67[profile.bench]
68codegen-units = 1
69debug = 2
70debug-assertions = false # <-
71incremental = false
72lto = 'fat'
73opt-level = 3 # <-
74overflow-checks = false # <-
diff --git a/examples/stm32h7b0/build.rs b/examples/stm32h7b0/build.rs
new file mode 100644
index 000000000..30691aa97
--- /dev/null
+++ b/examples/stm32h7b0/build.rs
@@ -0,0 +1,35 @@
1//! This build script copies the `memory.x` file from the crate root into
2//! a directory where the linker can always find it at build time.
3//! For many projects this is optional, as the linker always searches the
4//! project root directory -- wherever `Cargo.toml` is. However, if you
5//! are using a workspace or have a more complicated build setup, this
6//! build script becomes required. Additionally, by requesting that
7//! Cargo re-run the build script whenever `memory.x` is changed,
8//! updating `memory.x` ensures a rebuild of the application with the
9//! new memory settings.
10
11use std::env;
12use std::fs::File;
13use std::io::Write;
14use std::path::PathBuf;
15
16fn main() {
17 // Put `memory.x` in our output directory and ensure it's
18 // on the linker search path.
19 let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
20 File::create(out.join("memory.x"))
21 .unwrap()
22 .write_all(include_bytes!("memory.x"))
23 .unwrap();
24 println!("cargo:rustc-link-search={}", out.display());
25
26 // By default, Cargo will re-run a build script whenever
27 // any file in the project changes. By specifying `memory.x`
28 // here, we ensure the build script is only re-run when
29 // `memory.x` is changed.
30 println!("cargo:rerun-if-changed=memory.x");
31
32 println!("cargo:rustc-link-arg-bins=--nmagic");
33 println!("cargo:rustc-link-arg-bins=-Tlink.x");
34 println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
35}
diff --git a/examples/stm32h7b0/memory.x b/examples/stm32h7b0/memory.x
new file mode 100644
index 000000000..6eb1bb7c1
--- /dev/null
+++ b/examples/stm32h7b0/memory.x
@@ -0,0 +1,5 @@
1MEMORY
2{
3 FLASH : ORIGIN = 0x08000000, LENGTH = 128K /* BANK_1 */
4 RAM : ORIGIN = 0x24000000, LENGTH = 512K /* SRAM */
5} \ No newline at end of file
diff --git a/examples/stm32h7/src/bin/ospi_memory_mapped.rs b/examples/stm32h7b0/src/bin/ospi_memory_mapped.rs
index 40f39f751..e32a22e41 100644
--- a/examples/stm32h7/src/bin/ospi_memory_mapped.rs
+++ b/examples/stm32h7b0/src/bin/ospi_memory_mapped.rs
@@ -61,7 +61,7 @@ async fn main(_spawner: Spawner) {
61 free_running_clock: false, 61 free_running_clock: false,
62 clock_mode: false, 62 clock_mode: false,
63 wrap_size: WrapSize::None, 63 wrap_size: WrapSize::None,
64 clock_prescaler: 2, 64 clock_prescaler: 4,
65 sample_shifting: true, 65 sample_shifting: true,
66 delay_hold_quarter_cycle: false, 66 delay_hold_quarter_cycle: false,
67 chip_select_boundary: 0, 67 chip_select_boundary: 0,
@@ -94,8 +94,8 @@ async fn main(_spawner: Spawner) {
94 flash.read_memory(0, &mut rd_buf, true); 94 flash.read_memory(0, &mut rd_buf, true);
95 info!("WRITE BUF: {=[u8]:#X}", wr_buf); 95 info!("WRITE BUF: {=[u8]:#X}", wr_buf);
96 info!("READ BUF: {=[u8]:#X}", rd_buf); 96 info!("READ BUF: {=[u8]:#X}", rd_buf);
97 info!("Enabling memory mapped mode");
98 flash.enable_mm().await; 97 flash.enable_mm().await;
98 info!("Enabled memory mapped mode");
99 99
100 let first_u32 = unsafe { *(0x90000000 as *const u32) }; 100 let first_u32 = unsafe { *(0x90000000 as *const u32) };
101 assert_eq!(first_u32, 0x03020100); 101 assert_eq!(first_u32, 0x03020100);
@@ -121,7 +121,6 @@ const CMD_QUAD_READ: u8 = 0x6B;
121const CMD_QUAD_WRITE_PG: u8 = 0x32; 121const CMD_QUAD_WRITE_PG: u8 = 0x32;
122 122
123const CMD_READ_ID: u8 = 0x9F; 123const CMD_READ_ID: u8 = 0x9F;
124const CMD_READ_UUID: u8 = 0x4B;
125 124
126const CMD_ENABLE_RESET: u8 = 0x66; 125const CMD_ENABLE_RESET: u8 = 0x66;
127const CMD_RESET: u8 = 0x99; 126const CMD_RESET: u8 = 0x99;