Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zephyr: arm: Update reading the flash image reset vector #1661

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions boot/zephyr/flash_map_extended.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,12 @@ int flash_area_sector_from_off(off_t off, struct flash_sector *sector)

uint8_t flash_area_get_device_id(const struct flash_area *fa)
{
(void)fa;
return FLASH_DEVICE_ID;
#if defined(CONFIG_ARM)
return fa->fa_id;
#else
(void)fa;
return FLASH_DEVICE_ID;
#endif
}

#define ERASED_VAL 0xff
Expand Down
20 changes: 15 additions & 5 deletions boot/zephyr/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,26 @@ 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;
static uint32_t dst[2];

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

rc = flash_area_read(fap, rsp->br_hdr->ih_hdr_size, dst, sizeof(dst));
assert(rc == 0);
#ifndef CONFIG_ASSERT
/* Enter a lock up as asserts are disabled */
if (rc != 0) {
while (1);
}
#endif

nordicjm marked this conversation as resolved.
Show resolved Hide resolved
flash_area_close(fap);

vt = (struct arm_vector_table *)(flash_base +
rsp->br_image_off +
rsp->br_hdr->ih_hdr_size);
vt = (struct arm_vector_table *)dst;
#endif

if (IS_ENABLED(CONFIG_SYSTEM_TIMER_HAS_DISABLE_SUPPORT)) {
Expand Down
Loading