2018-06-24 04:03 AM
Hi,
I am using the Nucleo-H743ZI development board and trying to make an Interrupt driver for it. The driver has to support changing the vector table contents at runtime. So I made a copy of the vector table in the AXI SRAM at its first address (0x24000000)typedef void(*voidPFn_t)(void);
static volatile voidPFn_t newVectorTable[_VECTOR_TABLE_SIZE] __attribute__ ((section('.sram_d1')));
void interruptInit() {
volatile voidPFn_t* origVectorTable = (voidPFn_t*) SCB->VTOR;
// copy the content of the original vector table into the new vector table
for(uint32_t i = 0; i < _VECTOR_TABLE_SIZE; i++)
newVectorTable[i] = origVectorTable[i];
// install the new interrupt vector table
SCB->VTOR = ((uint32_t) &newVectorTable);
}
I succeeded to copy the content of the original vector table and I could see that through the memory window of my IDE. Also I set the VTOR register to 0x24000000 and modified my new vector table correctly.
But the problem is when I fire an interrupt in my test example the cpu goes to execute the interrupt handler of the original vector table not my new vector table. I don't know why that happens.
#interrupt #stm32h743 #nucleo-h743zi #stm32h7 #vector-table #axi-sramSolved! Go to Solution.
2018-06-27 05:17 AM
Hi!
I think you are facing a cache coherency issue (
for some details about cache & cache coherency).newVectorTable[VECSYSTICK] = &SysTick_Handler_New; // SysTick Handler
/* perform a cache maintenance : can be optimized by using SCB_CleanDCache_by_Addr */
SCB_CleanDCache();
SCB_InvalidateICache();Br,
Abdel
2018-06-24 08:30 AM
Suggest using the ITCM RAM at 0x00000000
2018-06-24 02:49 PM
Tried that, but nothing new. the same problem occurred.
2018-06-24 04:04 PM
I've tried relocating the vector table on an STM32H743I-EVAL, reasonably standard configuration, with caching enabled.
I can copy the vectors to ITCM RAM, and change the SysTick_Handler routine to point to another one, which outputs periodically so I can see it is using that one, and not the standard one.
void SysTick_Handler_New(void)
{ static int i = 0; if (i == 0) putchar('*'); i = (i + 1) % 1000; HAL_IncTick();}...
♯ define VECSYSTICK 15
...
newVectorTable[VECSYSTICK] = &SysTick_Handler_New; // SysTick Handler
I can see it transition to the newly pointed too code.
If I use AXI SRAM it vectors off some illegal address
2018-06-26 08:24 AM
Did you make any changes to the linker script file?
2018-06-26 09:43 AM
I'm not using GNU/GCC, for the purposes of the test the memories in question were not described to the linker.
2018-06-27 05:17 AM
Hi!
I think you are facing a cache coherency issue (
for some details about cache & cache coherency).newVectorTable[VECSYSTICK] = &SysTick_Handler_New; // SysTick Handler
/* perform a cache maintenance : can be optimized by using SCB_CleanDCache_by_Addr */
SCB_CleanDCache();
SCB_InvalidateICache();Br,
Abdel
2018-06-27 10:20 AM
Had tried SCB_InvalidateDCache_by_Addr(), working today. Evidence suggests no write-through/invalidation occurs on the I-Cache normally, ggrr!
2018-06-28 07:10 PM
extern
uint32_t __Vectors[];/* vector table ROM */
#define VECTORTABLE_SIZE (256)
/* size Cortex-M7 vector table */
#define VECTORTABLE_ALIGNMENT (0x100ul)
#define ADDRESS_SRAM *(uint32_t*)0x2400000
#define NEXT_ADDRESS_SRAM(A) (ADDRESS_SRAM+(A))
/* next power of 2 = 256 */
/* new vector table in RAM */
uint32_t vectorTable_RAM[VECTORTABLE_SIZE] __attribute__(( aligned (VECTORTABLE_ALIGNMENT) ));
/*----------------------------------------------------------------------------
SysTick_Handler
*----------------------------------------------------------------------------*/
volatile
uint32_t msTicks = 0;/* counts 1ms timeTicks */
void
SysTick_Handler(void
) {msTicks++;
/* increment counter */
}
/*----------------------------------------------------------------------------
SysTick_Handler (RAM)
*----------------------------------------------------------------------------*/
volatile
uint32_t msTicks_RAM = 0;/* counts 1ms timeTicks */
void
SysTick_Handler_RAM(void
) {msTicks_RAM++;
/* increment counter */
}
/*----------------------------------------------------------------------------
MAIN function
*----------------------------------------------------------------------------*/
int
main (void
) {uint32_t i;
for
(i = 0; i < VECTORTABLE_SIZE; i++) {NEXT_ADDRESS_SRAM(i)
= __Vectors[i];/* copy vector table to RAM */
}
/* replace SysTick Handler */
NEXT_ADDRESS_SRAM
[ + 16] = (uint32_t)SysTick_Handler_RAM;/* relocate vector table */
();SCB->VTOR = (uint32_t)&vectorTable_RAM;
();(); ();/* Get Core Clock Frequency */
( / 1000ul);/* Setup SysTick Timer for 1 msec */
while
(1);}
2018-06-28 07:12 PM
SCB-> VTOR = (uint32_t) &
ADDRESS_SRAM
;