Boot: Load image to SRAM for execution
Check the newest image's header for an SRAM load address, and if it
is present then copy the image to that address. This allows for faster
execution as well as the potential for larger images.
Signed-off-by: Oliver Swede <oli.swede@arm.com>
Change-Id: Ifbe868cb35d217086918ebeb5bb41690065b9f46
diff --git a/bl2/ext/mcuboot/bl2_main.c b/bl2/ext/mcuboot/bl2_main.c
index 9adc072..c556816 100644
--- a/bl2/ext/mcuboot/bl2_main.c
+++ b/bl2/ext/mcuboot/bl2_main.c
@@ -64,9 +64,19 @@
rc = flash_device_base(rsp->br_flash_dev_id, &flash_base);
assert(rc == 0);
- vt = (struct arm_vector_table *)(flash_base +
- rsp->br_image_off +
- rsp->br_hdr->ih_hdr_size);
+ if (rsp->br_hdr->ih_flags & IMAGE_F_RAM_LOAD) {
+ /* The image has been copied to SRAM, find the vector table
+ * at the load address instead of image's address in flash
+ */
+ vt = (struct arm_vector_table *)(rsp->br_hdr->ih_load_addr +
+ rsp->br_hdr->ih_hdr_size);
+ } else {
+ /* Using the flash address as not executing in SRAM */
+ vt = (struct arm_vector_table *)(flash_base +
+ rsp->br_image_off +
+ rsp->br_hdr->ih_hdr_size);
+ }
+
__disable_irq();
__set_MSP(vt->msp);
__DSB();