cancel
Showing results for 
Search instead for 
Did you mean: 

vector table relocation VTOR

Peter Lissenburg
Associate III
Posted on June 29, 2016 at 15:11

Hi there,

I'm implementing a bootloader. And have created an application vector table that is different to the bootloader vector table

Boot Vectors at 0x08000000

App Vectors  at 0x08010400

volatile const void (*vectortable[71])(void)={

  (const void*)0x20010000, // just something, won't be used except as a place holder

  (const void*)0x08010179, // just something, won't be used except as a place holder

  (const void*)NMI_Handler               ,

  (const void*)HardFault_Handler         ,

......etc

After the boot loader has done it's CRC/check_for_update/etc

And before I jump to the application start I need to relocate or rather redirect the processor to the application vector table at 0x08010400

so

SBC->VTOR = 0x08010400;

This seems to be OK, bit 29 is clear, the least significant 9 bits are clear and the offset from 0x00 AKA 0x08000000 is 0x00010400 (Have tried both 0x08010400 and 0x00010400)

My understanding, (which I hope is wrong in some way) is that upon reset the CPU will get the vector from the 0x08000004 location and start up. Then I change the vector location to be 0x08010400 and all other interrupt vectors 0x08010408 etc, are fetched from there. Until the next reset where is starts all afresh again.

However, it's not happening!

I can see the vectors at both 0x08000000 and 0x08010400. I can see the SBC->VTOR contains either 0x00000000 or 0x08000000 (makes no difference, both work fine) and then it is changed to 0x08010400 and no interrupts are fetched. I can manually (Using debugger) change the VTOR back to the 0x08000000 vector set and it all starts/continues OK.

I do admit to being very confused by the statement;

''you must align the offset to the number of exception entries in the vector

table. The minimum alignment is 128 words''. It does not seem to fit into my concept of how it all works.

Could someone point me in the right direction?

Many thanks.

Cheers.

Pete L.

#vtor
3 REPLIES 3
Posted on June 29, 2016 at 17:16

It should reset to zero, and it gets to the FLASH because the BOOTx pins cause the FLASH to map/shadow at zero at reset.

The multiple it resides at depend on the implementation's vector table size, rounded to the next power of 2, so 512 (0x200, or 128*4) boundaries should work here.

The SCB->VTOR is most often set by code in SystemInit(), so you need to make sure you use a system_stm32fxxx.c for the Application is configured differently from the Loader.

I've not had any problems with VTOR not functioning correctly, you'll need to look more closely at what you are doing.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Peter Lissenburg
Associate III
Posted on June 30, 2016 at 13:11

Thanks Guys,

Found the problem to be in the new vector table I omitted the RESERVED vectors and so messed up the order.

Cheers.

Pete L.