diff --git a/boot/bootutil/include/bootutil/bootutil.h b/boot/bootutil/include/bootutil/bootutil.h index 7f52799275..e90a647fb6 100644 --- a/boot/bootutil/include/bootutil/bootutil.h +++ b/boot/bootutil/include/bootutil/bootutil.h @@ -79,12 +79,19 @@ struct image_trailer { /* you must have pre-allocated all the entries within this structure */ fih_ret boot_go(struct boot_rsp *rsp); -fih_ret boot_go_for_image_id(struct boot_rsp *rsp, uint32_t image_id); +fih_ret boot_go_for_image_id_flash(struct boot_rsp *rsp, uint32_t image_id); + +#if defined(MCUBOOT_DIRECT_XIP) || defined(MCUBOOT_RAM_LOAD) +fih_ret boot_go_for_image_id_ram(struct boot_rsp *rsp, uint32_t image_id); +#endif struct boot_loader_state; void boot_state_clear(struct boot_loader_state *state); fih_ret context_boot_go_flash(struct boot_loader_state *state, struct boot_rsp *rsp); + +#if defined(MCUBOOT_DIRECT_XIP) || defined(MCUBOOT_RAM_LOAD) fih_ret context_boot_go_ram(struct boot_loader_state *state, struct boot_rsp *rsp); +#endif #define SPLIT_GO_OK (0) #define SPLIT_GO_NON_MATCHING (-1) diff --git a/boot/bootutil/src/loader.c b/boot/bootutil/src/loader.c index 81d88d8249..87e5d62469 100644 --- a/boot/bootutil/src/loader.c +++ b/boot/bootutil/src/loader.c @@ -3354,7 +3354,7 @@ boot_go(struct boot_rsp *rsp) * @return FIH_SUCCESS on success; nonzero on failure. */ fih_ret -boot_go_for_image_id(struct boot_rsp *rsp, uint32_t image_id) +boot_go_for_image_id_flash(struct boot_rsp *rsp, uint32_t image_id) { FIH_DECLARE(fih_rc, FIH_FAILURE); @@ -3371,6 +3371,37 @@ boot_go_for_image_id(struct boot_rsp *rsp, uint32_t image_id) FIH_RET(fih_rc); } +#if defined(MCUBOOT_DIRECT_XIP) || defined(MCUBOOT_RAM_LOAD) +/** + * Prepares the booting process, considering only a single image. This function + * moves images around in flash as appropriate, and tells you what address to + * boot from. + * + * @param rsp On success, indicates how booting should occur. + * + * @param image_id The image ID to prepare the boot process for. + * + * @return FIH_SUCCESS on success; nonzero on failure. + */ +fih_ret +boot_go_for_image_id_ram(struct boot_rsp *rsp, uint32_t image_id) +{ + FIH_DECLARE(fih_rc, FIH_FAILURE); + + if (image_id >= BOOT_IMAGE_NUMBER) { + FIH_RET(FIH_FAILURE); + } + +#if BOOT_IMAGE_NUMBER > 1 + memset(&boot_data.img_mask, 1, BOOT_IMAGE_NUMBER); + boot_data.img_mask[image_id] = 0; +#endif + + FIH_CALL(context_boot_go_ram, fih_rc, &boot_data, rsp); + FIH_RET(fih_rc); +} +#endif + /** * Clears the boot state, so that previous operations have no effect on new * ones. diff --git a/ci/fih_test_docker/fi_tester_gdb.sh b/ci/fih_test_docker/fi_tester_gdb.sh index a68aa667df..67d19f99b0 100755 --- a/ci/fih_test_docker/fi_tester_gdb.sh +++ b/ci/fih_test_docker/fi_tester_gdb.sh @@ -41,7 +41,7 @@ function skip_instruction { cat >commands.gdb <