Multisync
Multisync

Reputation: 823

STM32: Booting and fetching vector table from SRAM

I would like to run my program from the SRAM region of the device.

It seemed quite clear to me, that I have to perform following steps:

  1. Modify the vector table offset register SCB->VTOR (located at 0xE000ED08) to point to the beginning of the SRAM region, as that is where my vector table is located: 0x20000000
  2. Reset the device so it fetches the stack pointer initialization value and the reset handler adress again.

Unfortunately, whenever I issue a reset init command in OpenOCD, the value of SCB->VTOR gets cleared. Hence, stack pointer initialization value and reset handler adress are fetched from 0x00000000 instead of 0x20000000.


Question

How do I get my STM32F4 to fetch the vector table from 0x20000000?

Upvotes: 2

Views: 2070

Answers (1)

Turbo J
Turbo J

Reputation: 7711

Just load the SP (MSP) from 0x20000000 (=VTOR) and the PC from 0x20000004 (=VTOR+4) manually.

The reset init command will usually reset the whole chip and no just the core - and VTOR will be initialized to zero even then.

Upvotes: 2

Related Questions