mirror of
https://github.com/embassy-rs/embassy.git
synced 2025-09-28 12:50:37 +00:00
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.
This commit is contained in:
parent
0ce6da9706
commit
4cc5ab9474
@ -83,7 +83,7 @@ boot2-ram-memcpy = []
|
||||
boot2-w25q080 = []
|
||||
## Use boot2 with support for Winbond W25X10CL SPI flash.
|
||||
boot2-w25x10cl = []
|
||||
## Have embassy not provide the boot2 so you can use your own.
|
||||
## Have embassy-rp not provide the boot2 so you can use your own.
|
||||
## Place your own in the ".boot2" section like:
|
||||
## ```
|
||||
## #[link_section = ".boot2"]
|
||||
@ -92,6 +92,29 @@ boot2-w25x10cl = []
|
||||
## ```
|
||||
boot2-none = []
|
||||
|
||||
#! ### Image Definition support
|
||||
#! RP2350's internal bootloader will only execute firmware if it has a valid Image Definition.
|
||||
#! There are other tags that can be used (for example, you can tag an image as "DATA")
|
||||
#! but programs will want to have an exe header. "SECURE_EXE" is usually what you want.
|
||||
#! Use imagedef-none if you want to configure the Image Definition manually
|
||||
#! If none are selected, imagedef-secure-exe will be used
|
||||
|
||||
## Image is executable and starts in Secure mode
|
||||
imagedef-secure-exe = []
|
||||
## Image is executable and starts in Non-secure mode
|
||||
imagedef-nonsecure-exe = []
|
||||
|
||||
## Have embassy-rp not provide the Image Definition so you can use your own.
|
||||
## Place your own in the ".start_block" section like:
|
||||
## ```
|
||||
## use embassy_rp::block::ImageDef;
|
||||
##
|
||||
## #[link_section = ".start_block"]
|
||||
## #[used]
|
||||
## static IMAGE_DEF: ImageDef = ImageDef::secure_exe(); // Update this with your own implementation.
|
||||
## ```
|
||||
imagedef-none = []
|
||||
|
||||
## Configure the hal for use with the rp2040
|
||||
rp2040 = ["rp-pac/rp2040"]
|
||||
_rp235x = ["rp-pac/rp235x"]
|
||||
|
@ -456,6 +456,30 @@ select_bootloader! {
|
||||
default => BOOT_LOADER_W25Q080
|
||||
}
|
||||
|
||||
#[cfg(all(not(feature = "imagedef-none"), feature = "_rp235x"))]
|
||||
macro_rules! select_imagedef {
|
||||
( $( $feature:literal => $imagedef:ident, )+ default => $default:ident ) => {
|
||||
$(
|
||||
#[cfg(feature = $feature)]
|
||||
#[link_section = ".start_block"]
|
||||
#[used]
|
||||
static IMAGE_DEF: crate::block::ImageDef = crate::block::ImageDef::$imagedef();
|
||||
)*
|
||||
|
||||
#[cfg(not(any( $( feature = $feature),* )))]
|
||||
#[link_section = ".start_block"]
|
||||
#[used]
|
||||
static IMAGE_DEF: crate::block::ImageDef = crate::block::ImageDef::$default();
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(not(feature = "imagedef-none"), feature = "_rp235x"))]
|
||||
select_imagedef! {
|
||||
"imagedef-secure-exe" => secure_exe,
|
||||
"imagedef-nonsecure-exe" => non_secure_exe,
|
||||
default => secure_exe
|
||||
}
|
||||
|
||||
/// Installs a stack guard for the CORE0 stack in MPU region 0.
|
||||
/// Will fail if the MPU is already configured. This function requires
|
||||
/// a `_stack_end` symbol to be defined by the linker script, and expects
|
||||
|
Loading…
x
Reference in New Issue
Block a user