Topic : moving interrupt vector table in STM32F105

Forum : ARM

Original Post
Post Information Post
December 21, 2011 - 11:23pm
Guest

I want to move interrupt vector table (and all program) by 0x1000 bytes offset.
I understand that after reset program always starts from vector at 0x800:0004, and at at this addres must be jumpl to entry point of program. Before activating interrupts I have to set new vector table address using function
NVIC_SetVectorTable(NVIC_VectTab_FLASH, xxxx);

But how tell teh linker that this vector table should be places at another (but known) address but reset vector must be still at 0x800:0004 adres ? Any suggestions ?

Changing linker script from

..RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 0x10000
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 0x10000
..

to

RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 0x10000
FLASH (rx) : ORIGIN = 0x08001000, LENGTH = 0x0F000

will be enough to tell linker not to plece code and data inside first 0x1000 flash?

How to do it in linker script ?

Replies
Post Information Post
+1
0
-1
December 22, 2011 - 9:43am
Raisonance Support Team

Hi,

You can find some answers to your question from http://forum.raisonance.com/viewtopic.php?id=3675

Basically moving the whole application will not work (as the startup requests the 0x08000000 location for the vectors), so you need to create a second section to place your relocated vectors.

Best Regards,

+1
0
-1
January 5, 2012 - 12:07am
Guest

Thanks
I have changed linker script and my application now is moved to address 800:1000.

One of the first commands in my program should be
NVIC_SetVectorTable( NVIC_VectTab_FLASH, 0x1000 ); // 0x1000 is offset of my program

What happened to vector table? is it moved with the same offset ?

And now all I need now is the simplest way to tell processor where my program starts and initialize oryginal reset vector localized at address 800:0004 to point to ... "moved" new reset vector .

How to do this in the simple way ?

I use startup file: startup_stm32f10x_cl.s. Is it also moved ?

with best regards

+1
0
-1
January 5, 2012 - 9:43am
Raisonance Support Team

Hi,

Yes your table moves along with your application.
You should not have to modify your startup file. It contains the interrupt vector table, and the second entry of this table points to the startup entry point. The Linker will move/locate the startup according to the requested settings, and the entry will properly point to the (relocated) startup entry point.

I hope this helps,

Best Regards,

+1
0
-1
January 5, 2012 - 6:14pm
Guest

But one question: how easly prepare oryginal vector table located at 0x800:0000 and startup procedure ?
After reset, execution must be somehow directed to adres pointed by 'moved' vector table. What about stack ?

Could you give me some king of example of doing that ?

+1
0
-1
January 6, 2012 - 8:22am
Raisonance Support Team

Hi Xadamus,

You can download the CircleOS sources from http://www.stm32circle.com/.
This will show an example of interrupt vector table relocation.

Best Regards,

+1
0
-1
January 8, 2012 - 11:04pm
Guest

Bruno wrote:

Hi Xadamus,

You can download the CircleOS sources from http://www.stm32circle.com/.
This will show an example of interrupt vector table relocation.

Best Regards,

Thanks,
I loaded sources of CircleOs...
But it is not more clear for me at all, how to do what I want to..

And I would like to use the simples way to execute program that is compied with offset.

So if you could give me some suggestions, maybe example....

thanks in advice

+1
0
-1
January 16, 2012 - 9:53am
Guest

Can any help with this problem? How to simply do that using Ride-7 ?

with best regards