Skip to content

Commit

Permalink
zephyr: arm: Update reading the flash image reset vector
Browse files Browse the repository at this point in the history
This change uses the flash functions to read the applications
reset vector. This allows flexibility on where the
application image is programmed.
The current implementation for in Zephyr for ARM platforms
does not allow the use-case where the application is programmed
to a different flash device than where mcuboot is programmed
and running from.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
  • Loading branch information
mmahadevan108 committed Mar 24, 2023
1 parent cdf9de0 commit 9c42d03
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions boot/zephyr/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,16 +178,22 @@ static void do_boot(struct boot_rsp *rsp)
/* Get ram address for image */
vt = (struct arm_vector_table *)(rsp->br_hdr->ih_load_addr + rsp->br_hdr->ih_hdr_size);
#else
uintptr_t flash_base;
int rc;
const struct flash_area *fap;
int area_id;
uint32_t dst[2];

/* Jump to flash image */
rc = flash_device_base(rsp->br_flash_dev_id, &flash_base);
area_id = flash_area_id_from_image_slot(0);
rc = flash_area_open(area_id, &fap);
assert(rc == 0);

vt = (struct arm_vector_table *)(flash_base +
rsp->br_image_off +
rsp->br_hdr->ih_hdr_size);
rc = flash_area_read(fap, rsp->br_hdr->ih_hdr_size, dst, 8);
assert(rc == 0);

flash_area_close(fap);

vt = (struct arm_vector_table *)dst;
#endif

if (IS_ENABLED(CONFIG_SYSTEM_TIMER_HAS_DISABLE_SUPPORT)) {
Expand Down

0 comments on commit 9c42d03

Please sign in to comment.