aboutsummaryrefslogtreecommitdiff
path: root/embassy-rp
diff options
context:
space:
mode:
author9names <[email protected]>2025-02-16 12:34:48 +1100
committer9names <[email protected]>2025-02-16 15:43:01 +1100
commit4cc5ab9474773148dd8976e22f3fb6f5e270cd3a (patch)
tree96058b9a554ea8dee7895875d9a20a4ebad358bc /embassy-rp
parent0ce6da9706b9d929691c9292c923117fcbc2f9c6 (diff)
Add rp235x imagedef features (based on rp2040 boot2 features)
rp235x firmwares need an Image Definition if they want to be called from the rp235x bootrom. Currently this Image Definition is manually added to each project/example, but for most users it will always be the default (Secure Exe). This commit adds crate features to allow users to configure this, with the default of including a Secure Exe Image Definition in. Just like the boot2-* features, this includes an opt-out (imagedef-none) to allow the user to not make use of this included Image Definition.
Diffstat (limited to 'embassy-rp')
-rw-r--r--embassy-rp/Cargo.toml25
-rw-r--r--embassy-rp/src/lib.rs24
2 files changed, 48 insertions, 1 deletions
diff --git a/embassy-rp/Cargo.toml b/embassy-rp/Cargo.toml
index 4e5c66feb..d65e281ee 100644
--- a/embassy-rp/Cargo.toml
+++ b/embassy-rp/Cargo.toml
@@ -83,7 +83,7 @@ boot2-ram-memcpy = []
83boot2-w25q080 = [] 83boot2-w25q080 = []
84## Use boot2 with support for Winbond W25X10CL SPI flash. 84## Use boot2 with support for Winbond W25X10CL SPI flash.
85boot2-w25x10cl = [] 85boot2-w25x10cl = []
86## Have embassy not provide the boot2 so you can use your own. 86## Have embassy-rp not provide the boot2 so you can use your own.
87## Place your own in the ".boot2" section like: 87## Place your own in the ".boot2" section like:
88## ``` 88## ```
89## #[link_section = ".boot2"] 89## #[link_section = ".boot2"]
@@ -92,6 +92,29 @@ boot2-w25x10cl = []
92## ``` 92## ```
93boot2-none = [] 93boot2-none = []
94 94
95#! ### Image Definition support
96#! RP2350's internal bootloader will only execute firmware if it has a valid Image Definition.
97#! There are other tags that can be used (for example, you can tag an image as "DATA")
98#! but programs will want to have an exe header. "SECURE_EXE" is usually what you want.
99#! Use imagedef-none if you want to configure the Image Definition manually
100#! If none are selected, imagedef-secure-exe will be used
101
102## Image is executable and starts in Secure mode
103imagedef-secure-exe = []
104## Image is executable and starts in Non-secure mode
105imagedef-nonsecure-exe = []
106
107## Have embassy-rp not provide the Image Definition so you can use your own.
108## Place your own in the ".start_block" section like:
109## ```
110## use embassy_rp::block::ImageDef;
111##
112## #[link_section = ".start_block"]
113## #[used]
114## static IMAGE_DEF: ImageDef = ImageDef::secure_exe(); // Update this with your own implementation.
115## ```
116imagedef-none = []
117
95## Configure the hal for use with the rp2040 118## Configure the hal for use with the rp2040
96rp2040 = ["rp-pac/rp2040"] 119rp2040 = ["rp-pac/rp2040"]
97_rp235x = ["rp-pac/rp235x"] 120_rp235x = ["rp-pac/rp235x"]
diff --git a/embassy-rp/src/lib.rs b/embassy-rp/src/lib.rs
index 80ee47802..de60af890 100644
--- a/embassy-rp/src/lib.rs
+++ b/embassy-rp/src/lib.rs
@@ -456,6 +456,30 @@ select_bootloader! {
456 default => BOOT_LOADER_W25Q080 456 default => BOOT_LOADER_W25Q080
457} 457}
458 458
459#[cfg(all(not(feature = "imagedef-none"), feature = "_rp235x"))]
460macro_rules! select_imagedef {
461 ( $( $feature:literal => $imagedef:ident, )+ default => $default:ident ) => {
462 $(
463 #[cfg(feature = $feature)]
464 #[link_section = ".start_block"]
465 #[used]
466 static IMAGE_DEF: crate::block::ImageDef = crate::block::ImageDef::$imagedef();
467 )*
468
469 #[cfg(not(any( $( feature = $feature),* )))]
470 #[link_section = ".start_block"]
471 #[used]
472 static IMAGE_DEF: crate::block::ImageDef = crate::block::ImageDef::$default();
473 }
474}
475
476#[cfg(all(not(feature = "imagedef-none"), feature = "_rp235x"))]
477select_imagedef! {
478 "imagedef-secure-exe" => secure_exe,
479 "imagedef-nonsecure-exe" => non_secure_exe,
480 default => secure_exe
481}
482
459/// Installs a stack guard for the CORE0 stack in MPU region 0. 483/// Installs a stack guard for the CORE0 stack in MPU region 0.
460/// Will fail if the MPU is already configured. This function requires 484/// Will fail if the MPU is already configured. This function requires
461/// a `_stack_end` symbol to be defined by the linker script, and expects 485/// a `_stack_end` symbol to be defined by the linker script, and expects