Skip to content

Commit 7de064e

Browse files
danieldegrassenordicjm
authored andcommitted
boot: zephyr: add support for booting ARC processors
Add support for booting ARC processors to MCUBoot. ARC defines the reset vector as the first function pointer within the vector table. Signed-off-by: Daniel DeGrasse <[email protected]>
1 parent 72459ec commit 7de064e

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

boot/zephyr/main.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,37 @@ static void do_boot(struct boot_rsp *rsp)
321321
#endif /* CONFIG_SOC_FAMILY_ESPRESSIF_ESP32 */
322322
}
323323

324+
#elif defined(CONFIG_ARC)
325+
326+
/*
327+
* ARC vector table has a pointer to the reset function as the first entry
328+
* in the vector table. Assume the vector table is at the start of the image,
329+
* and jump to reset
330+
*/
331+
static void do_boot(struct boot_rsp *rsp)
332+
{
333+
struct arc_vector_table {
334+
void (*reset)(void); /* Reset vector */
335+
} *vt;
336+
337+
#if defined(MCUBOOT_RAM_LOAD)
338+
vt = (struct arc_vector_table *)(rsp->br_hdr->ih_load_addr + rsp->br_hdr->ih_hdr_size);
339+
#else
340+
uintptr_t flash_base;
341+
int rc;
342+
343+
rc = flash_device_base(rsp->br_flash_dev_id, &flash_base);
344+
assert(rc == 0);
345+
346+
vt = (struct arc_vector_table *)(flash_base + rsp->br_image_off +
347+
rsp->br_hdr->ih_hdr_size);
348+
#endif
349+
350+
/* Lock interrupts and dive into the entry point */
351+
irq_lock();
352+
vt->reset();
353+
}
354+
324355
#else
325356
/* Default: Assume entry point is at the very beginning of the image. Simply
326357
* lock interrupts and jump there. This is the right thing to do for X86 and

0 commit comments

Comments
 (0)