rp2040: Load vectortable into ram
Load the interrupt vector table into ram at startup. This reduces the chance of a flash cache access causing timing instability. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
44e79e0c37
commit
f1982edcd5
|
@ -16,6 +16,26 @@
|
||||||
#include "sched.h" // sched_main
|
#include "sched.h" // sched_main
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************
|
||||||
|
* Ram IRQ vector table
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
// Copy vector table to ram and activate it
|
||||||
|
static void
|
||||||
|
enable_ram_vectortable(void)
|
||||||
|
{
|
||||||
|
// Symbols created by rp2040_link.lds.S linker script
|
||||||
|
extern uint32_t _ram_vectortable_start, _ram_vectortable_end;
|
||||||
|
extern uint32_t _text_vectortable_start;
|
||||||
|
|
||||||
|
uint32_t count = (&_ram_vectortable_end - &_ram_vectortable_start) * 4;
|
||||||
|
__builtin_memcpy(&_ram_vectortable_start, &_text_vectortable_start, count);
|
||||||
|
barrier();
|
||||||
|
|
||||||
|
SCB->VTOR = (uint32_t)&_ram_vectortable_start;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************
|
/****************************************************************
|
||||||
* Bootloader
|
* Bootloader
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
@ -145,6 +165,7 @@ clock_setup(void)
|
||||||
void
|
void
|
||||||
armcm_main(void)
|
armcm_main(void)
|
||||||
{
|
{
|
||||||
|
enable_ram_vectortable();
|
||||||
clock_setup();
|
clock_setup();
|
||||||
sched_main();
|
sched_main();
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,12 @@ SECTIONS
|
||||||
. = ALIGN(4);
|
. = ALIGN(4);
|
||||||
_data_flash = .;
|
_data_flash = .;
|
||||||
|
|
||||||
|
.ram_vectortable (NOLOAD) : {
|
||||||
|
_ram_vectortable_start = .;
|
||||||
|
. = . + ( _text_vectortable_end - _text_vectortable_start ) ;
|
||||||
|
_ram_vectortable_end = .;
|
||||||
|
} > ram
|
||||||
|
|
||||||
.data : AT (_data_flash)
|
.data : AT (_data_flash)
|
||||||
{
|
{
|
||||||
. = ALIGN(4);
|
. = ALIGN(4);
|
||||||
|
|
Loading…
Reference in New Issue