Skip to content

Commit 9c42d03

Browse files
committed
zephyr: arm: Update reading the flash image reset vector
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 <[email protected]>
1 parent cdf9de0 commit 9c42d03

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

boot/zephyr/main.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,16 +178,22 @@ static void do_boot(struct boot_rsp *rsp)
178178
/* Get ram address for image */
179179
vt = (struct arm_vector_table *)(rsp->br_hdr->ih_load_addr + rsp->br_hdr->ih_hdr_size);
180180
#else
181-
uintptr_t flash_base;
182181
int rc;
182+
const struct flash_area *fap;
183+
int area_id;
184+
uint32_t dst[2];
183185

184186
/* Jump to flash image */
185-
rc = flash_device_base(rsp->br_flash_dev_id, &flash_base);
187+
area_id = flash_area_id_from_image_slot(0);
188+
rc = flash_area_open(area_id, &fap);
186189
assert(rc == 0);
187190

188-
vt = (struct arm_vector_table *)(flash_base +
189-
rsp->br_image_off +
190-
rsp->br_hdr->ih_hdr_size);
191+
rc = flash_area_read(fap, rsp->br_hdr->ih_hdr_size, dst, 8);
192+
assert(rc == 0);
193+
194+
flash_area_close(fap);
195+
196+
vt = (struct arm_vector_table *)dst;
191197
#endif
192198

193199
if (IS_ENABLED(CONFIG_SYSTEM_TIMER_HAS_DISABLE_SUPPORT)) {

0 commit comments

Comments
 (0)