diff options
| author | xoviat <[email protected]> | 2023-05-27 15:03:25 -0500 |
|---|---|---|
| committer | xoviat <[email protected]> | 2023-05-27 15:03:25 -0500 |
| commit | c19967dcf24d5223de5fd9b390371dc24aeccc1d (patch) | |
| tree | c6980e0dd40ff192fc4723f2b885103613bf524b | |
| parent | 66304a102d628f2e61f9e38bb95eb11a2663335d (diff) | |
stm32/ipcc: extract tl_mbox linker file to embassy-stm32
| -rw-r--r-- | embassy-stm32/build.rs | 10 | ||||
| -rw-r--r-- | embassy-stm32/tl_mbox.x.in (renamed from tests/stm32/memory_ble.x) | 14 | ||||
| -rw-r--r-- | examples/stm32wb/Cargo.toml | 2 | ||||
| -rw-r--r-- | examples/stm32wb/build.rs | 36 | ||||
| -rw-r--r-- | examples/stm32wb/memory.x | 35 |
5 files changed, 20 insertions, 77 deletions
diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index 540981727..9207cf3f4 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs | |||
| @@ -910,6 +910,16 @@ fn main() { | |||
| 910 | println!("cargo:rustc-cfg={}x{}", &chip_name[..9], &chip_name[10..11]); | 910 | println!("cargo:rustc-cfg={}x{}", &chip_name[..9], &chip_name[10..11]); |
| 911 | } | 911 | } |
| 912 | 912 | ||
| 913 | // ======== | ||
| 914 | // stm32wb tl_mbox link sections | ||
| 915 | |||
| 916 | if chip_name.starts_with("stm32wb") { | ||
| 917 | let out_file = out_dir.join("tl_mbox.x").to_string_lossy().to_string(); | ||
| 918 | fs::write(out_file, fs::read_to_string("tl_mbox.x.in").unwrap()).unwrap(); | ||
| 919 | println!("cargo:rustc-link-search={}", out_dir.display()); | ||
| 920 | println!("cargo:rerun-if-changed=tl_mbox.x.in"); | ||
| 921 | } | ||
| 922 | |||
| 913 | // ======= | 923 | // ======= |
| 914 | // Features for targeting groups of chips | 924 | // Features for targeting groups of chips |
| 915 | 925 | ||
diff --git a/tests/stm32/memory_ble.x b/embassy-stm32/tl_mbox.x.in index 4332e2c72..b6eecb429 100644 --- a/tests/stm32/memory_ble.x +++ b/embassy-stm32/tl_mbox.x.in | |||
| @@ -1,21 +1,13 @@ | |||
| 1 | /* | 1 | MEMORY |
| 2 | Memory size for STM32WB55xG with 512K FLASH | ||
| 3 | */ | ||
| 4 | |||
| 5 | MEMORY | ||
| 6 | { | 2 | { |
| 7 | FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K | ||
| 8 | RAM (xrw) : ORIGIN = 0x20000008, LENGTH = 0x2FFF8 | ||
| 9 | RAM_SHARED (xrw) : ORIGIN = 0x20030000, LENGTH = 10K | 3 | RAM_SHARED (xrw) : ORIGIN = 0x20030000, LENGTH = 10K |
| 10 | } | 4 | } |
| 11 | 5 | ||
| 12 | /* Place stack at the end of SRAM1 */ | ||
| 13 | _stack_start = ORIGIN(RAM) + LENGTH(RAM); | ||
| 14 | |||
| 15 | /* | 6 | /* |
| 16 | * Scatter the mailbox interface memory sections in shared memory | 7 | * Scatter the mailbox interface memory sections in shared memory |
| 17 | */ | 8 | */ |
| 18 | SECTIONS { | 9 | SECTIONS |
| 10 | { | ||
| 19 | TL_REF_TABLE (NOLOAD) : { *(TL_REF_TABLE) } >RAM_SHARED | 11 | TL_REF_TABLE (NOLOAD) : { *(TL_REF_TABLE) } >RAM_SHARED |
| 20 | 12 | ||
| 21 | MB_MEM1 (NOLOAD) : { *(MB_MEM1) } >RAM_SHARED | 13 | MB_MEM1 (NOLOAD) : { *(MB_MEM1) } >RAM_SHARED |
diff --git a/examples/stm32wb/Cargo.toml b/examples/stm32wb/Cargo.toml index 3c7e3e874..8cfac772a 100644 --- a/examples/stm32wb/Cargo.toml +++ b/examples/stm32wb/Cargo.toml | |||
| @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" | |||
| 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } |
| 9 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 9 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32wb55rg", "time-driver-any", "exti"] } | 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32wb55rg", "time-driver-any", "memory-x", "exti"] } |
| 12 | 12 | ||
| 13 | defmt = "0.3" | 13 | defmt = "0.3" |
| 14 | defmt-rtt = "0.4" | 14 | defmt-rtt = "0.4" |
diff --git a/examples/stm32wb/build.rs b/examples/stm32wb/build.rs index 30691aa97..29b3a9b2a 100644 --- a/examples/stm32wb/build.rs +++ b/examples/stm32wb/build.rs | |||
| @@ -1,35 +1,11 @@ | |||
| 1 | //! This build script copies the `memory.x` file from the crate root into | 1 | use std::error::Error; |
| 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 | |||
| 11 | use std::env; | ||
| 12 | use std::fs::File; | ||
| 13 | use std::io::Write; | ||
| 14 | use std::path::PathBuf; | ||
| 15 | |||
| 16 | fn 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 | 2 | ||
| 3 | fn main() -> Result<(), Box<dyn Error>> { | ||
| 32 | println!("cargo:rustc-link-arg-bins=--nmagic"); | 4 | println!("cargo:rustc-link-arg-bins=--nmagic"); |
| 33 | println!("cargo:rustc-link-arg-bins=-Tlink.x"); | 5 | println!("cargo:rustc-link-arg-bins=-Tlink.x"); |
| 6 | println!("cargo:rerun-if-changed=link.x"); | ||
| 7 | println!("cargo:rustc-link-arg-bins=-Ttl_mbox.x"); | ||
| 34 | println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); | 8 | println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); |
| 9 | |||
| 10 | Ok(()) | ||
| 35 | } | 11 | } |
diff --git a/examples/stm32wb/memory.x b/examples/stm32wb/memory.x deleted file mode 100644 index e1f0530bd..000000000 --- a/examples/stm32wb/memory.x +++ /dev/null | |||
| @@ -1,35 +0,0 @@ | |||
| 1 | /* | ||
| 2 | The size of this file must be exactly the same as in other memory_xx.x files. | ||
| 3 | Memory size for STM32WB55xC with 256K FLASH | ||
| 4 | */ | ||
| 5 | |||
| 6 | MEMORY | ||
| 7 | { | ||
| 8 | FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 256K | ||
| 9 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 192K | ||
| 10 | RAM_SHARED (xrw) : ORIGIN = 0x20030000, LENGTH = 10K | ||
| 11 | } | ||
| 12 | |||
| 13 | /* | ||
| 14 | Memory size for STM32WB55xG with 512K FLASH | ||
| 15 | |||
| 16 | MEMORY | ||
| 17 | { | ||
| 18 | FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K | ||
| 19 | RAM (xrw) : ORIGIN = 0x20000008, LENGTH = 0x2FFF8 | ||
| 20 | RAM_SHARED (xrw) : ORIGIN = 0x20030000, LENGTH = 10K | ||
| 21 | } | ||
| 22 | */ | ||
| 23 | |||
| 24 | /* Place stack at the end of SRAM1 */ | ||
| 25 | _stack_start = ORIGIN(RAM) + LENGTH(RAM); | ||
| 26 | |||
| 27 | /* | ||
| 28 | * Scatter the mailbox interface memory sections in shared memory | ||
| 29 | */ | ||
| 30 | SECTIONS { | ||
| 31 | TL_REF_TABLE (NOLOAD) : { *(TL_REF_TABLE) } >RAM_SHARED | ||
| 32 | |||
| 33 | MB_MEM1 (NOLOAD) : { *(MB_MEM1) } >RAM_SHARED | ||
| 34 | MB_MEM2 (NOLOAD) : { _sMB_MEM2 = . ; *(MB_MEM2) ; _eMB_MEM2 = . ; } >RAM_SHARED | ||
| 35 | } | ||
