Page 1 of 1

Interrupt Vector Table in RAM  Topic is solved

Posted: Tue Nov 09, 2021 8:48 am
by kdums
Hi!
We need to have the Vector table in RAM, because we can have a problem with code fetch from flash.

Kind regards,
Klaus

We suggest the following change:

--- \os\common\startup\ARMCMx\compilers\GCC\crt0_v7m.S 2020-09-04 09:54:04.000000000 +0100
+++ \os\common\startup\ARMCMx\compilers\GCC\crt0_v7m.S 2021-11-09 08:39:59.000000000 +0100
@@ -197,12 +197,27 @@

/* PSP stack pointers initialization.*/
ldr r0, =__process_stack_end__
msr PSP, r0

#if CRT0_VTOR_INIT == TRUE
+ /* copy Vector Table to RAM */
+ /* Data initialization. Note, it assumes that the DATA size
+ is a multiple of 4 so the linker file must ensure this.*/
+ ldr r1, =_ram_vectors_load
+ ldr r2, =_ram_vectors_start
+ ldr r3, =_ram_vectors_end
+vloop:
+ cmp r2, r3
+ ittt lo
+ ldrlo r0, [r1], #4
+ strlo r0, [r2], #4
+ blo vloop
+
+ /* set base address of Vector Table */
ldr r0, =_vectors
movw r1, #SCB_VTOR & 0xFFFF
movt r1, #SCB_VTOR >> 16
str r0, [r1]
#endif

Re: Interrupt Vector Table in RAM

Posted: Tue Nov 09, 2021 9:52 am
by Giovanni
Hi,

I added the initialization code to crt0_v7m.S but the option to enable is CRT0_INIT_VECTORS (CRT0_VTOR_INIT is about initializing the register).

In your linker script you also need to do something like this:

Code: Select all

/* Flash region to be used for exception vectors.*/
REGION_ALIAS("VECTORS_FLASH", ram0);
REGION_ALIAS("VECTORS_FLASH_LMA", flash0);


On startup vectors are copied just before DATA segment initialization. Note that __early_init() is called with vectors still placed in flash, it is mean to be "early" so no initializations are done before calling that.

The code is in trunk, if it is fine for you I will look into back-porting it in 21.11.1.

Giovanni

Re: Interrupt Vector Table in RAM

Posted: Mon Nov 15, 2021 3:16 pm
by kdums
Thanks!