aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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