boot: Add capability for ram loading
The MCUBOOT_RAM_LOAD feature supports configurations where code is
loaded from flash into RAM before execution. As such, it is not
necessary for upgrades to move data around in flash.
Signed-off-by: David Brown <david.brown@linaro.org>
diff --git a/boot/bootutil/include/bootutil/caps.h b/boot/bootutil/include/bootutil/caps.h
index 9bf060c..aa288b1 100644
--- a/boot/bootutil/include/bootutil/caps.h
+++ b/boot/bootutil/include/bootutil/caps.h
@@ -49,6 +49,7 @@
#define BOOTUTIL_CAP_ENC_X25519 (1<<13)
#define BOOTUTIL_CAP_BOOTSTRAP (1<<14)
#define BOOTUTIL_CAP_AES256 (1<<15)
+#define BOOTUTIL_CAP_RAM_LOAD (1<<16)
/*
* Query the number of images this bootloader is configured for. This
diff --git a/boot/bootutil/src/caps.c b/boot/bootutil/src/caps.c
index 87bac1a..be06271 100644
--- a/boot/bootutil/src/caps.c
+++ b/boot/bootutil/src/caps.c
@@ -72,6 +72,9 @@
#if defined(MCUBOOT_AES_256)
res |= BOOTUTIL_CAP_AES256;
#endif
+#if defined(MCUBOOT_RAM_LOAD)
+ res |= BOOTUTIL_CAP_RAM_LOAD;
+#endif
return res;
}
diff --git a/sim/src/caps.rs b/sim/src/caps.rs
index 4af8bd0..932b5ab 100644
--- a/sim/src/caps.rs
+++ b/sim/src/caps.rs
@@ -26,6 +26,7 @@
EncX25519 = (1 << 13),
Bootstrap = (1 << 14),
Aes256 = (1 << 15),
+ RamLoad = (1 << 16),
}
impl Caps {
@@ -39,6 +40,12 @@
pub fn get_num_images() -> usize {
(unsafe { bootutil_get_num_images() }) as usize
}
+
+ /// Query if this configuration performs some kind of upgrade by writing to flash.
+ pub fn modifies_flash() -> bool {
+ // All other configurations perform upgrades by writing to flash.
+ !Self::RamLoad.present()
+ }
}
extern "C" {