Skip to content

Commit 993c2ff

Browse files
edersondisouzanordicjm
authored andcommitted
boot/bootutil/ram_load: Add flash area pointer to bootloader state
Since 1b2fc09, many places now reuse the flash area pointer from the bootloader state. Unfortunately, some RAM load usage (on single loader or runtime-source sample) didn't set up the flash area pointer on the bootloader state, so they were broken. This patch fixes that by adding the flash area pointer to the created bootloader states - directly or via a new parameter to boot_load_image_from_flash_to_sram(). Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
1 parent 88294be commit 993c2ff

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

boot/bootutil/include/bootutil/bootutil_public.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,13 @@ boot_image_load_header(const struct flash_area *fa_p,
319319
*
320320
* @param[in] state boot loader state
321321
* @param[in] hdr image header
322+
* @param[in] fa flash area pointer
322323
*
323324
* @return 0 on success, error code otherwise
324325
*/
325326
int boot_load_image_from_flash_to_sram(struct boot_loader_state *state,
326-
struct image_header *hdr);
327+
struct image_header *hdr,
328+
const struct flash_area *fa);
327329

328330
/**
329331
* Removes an image from SRAM, by overwriting it with zeros.

boot/bootutil/src/ram_load.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,8 @@ boot_remove_image_from_flash(struct boot_loader_state *state, uint32_t slot)
419419
}
420420

421421
int boot_load_image_from_flash_to_sram(struct boot_loader_state *state,
422-
struct image_header *hdr)
422+
struct image_header *hdr,
423+
const struct flash_area *fap)
423424
{
424425
int active_slot;
425426

@@ -428,6 +429,7 @@ int boot_load_image_from_flash_to_sram(struct boot_loader_state *state,
428429
*/
429430
active_slot = state->slot_usage[BOOT_CURR_IMG(state)].active_slot;
430431
BOOT_IMG(state, active_slot).hdr = *hdr;
432+
BOOT_IMG_AREA(state, active_slot) = fap;
431433

432434
return boot_load_image_to_sram(state);
433435
}

boot/zephyr/single_loader.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ boot_go(struct boot_rsp *rsp)
121121

122122
#ifdef MCUBOOT_RAM_LOAD
123123
static struct boot_loader_state state;
124+
BOOT_IMG_AREA(&state, 0) = _fa_p;
124125
state.imgs[0][0].hdr = _hdr;
125126

126127
rc = boot_load_image_to_sram(&state);

samples/runtime-source/zephyr/hooks/hooks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ fih_ret boot_go_hook(struct boot_rsp *rsp)
7272
#ifdef MCUBOOT_RAM_LOAD
7373
state = boot_get_loader_state();
7474

75-
rc = boot_load_image_from_flash_to_sram(state, &_hdr);
75+
rc = boot_load_image_from_flash_to_sram(state, &_hdr, _fa_p);
7676
if (rc != 0) {
7777
flash_area_close(_fa_p);
7878
continue;

0 commit comments

Comments
 (0)