Put constant value into interrupt vector table

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
rubenswerk
Posts: 104
Joined: Wed Feb 22, 2012 11:39 am

Put constant value into interrupt vector table

Post by rubenswerk »

Hello,

I would like to put a constant value into STM32 interrupt vector table.
Usually, the table consists of weak symbols named VectorXXX, which are pointers to the ISR.

However, I want to put a constant 32 bit number into an unused vector, for example Vector100.

I know from software architecture point of view it's a very bad idea. I should define a fixed section in ther linker script and put my data there. However, I have already several devices with Read-Out-Protection=2 using the mentioned method, so I have to deal with it. This design choice was done several years ago when I had no experience at all :-(

In the past this was done by just writing the number into vectors.s, but I would like to avoid touching this generic file in the future.
Is there a better way to reach this ugly goal?

Thanks!
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Put constant value into interrupt vector table

Post by Giovanni »

Hi,

You may define a symbol in the .ld file or in the Makefile in the linker options.

IF I remember well:

USE_LDOPT = --defsym=Vectorxx=0xffffffff

Giovanni
rubenswerk
Posts: 104
Joined: Wed Feb 22, 2012 11:39 am

Re: Put constant value into interrupt vector table

Post by rubenswerk »

Hello Giovanni,

this is quite close to what I'd like to have.
Unfortunately, the assembler does not allow even values as symbol.
If I do
--defsym=Vector100=0x12345678
the assembler (or linker?) puts 0x12345679 (uneven address) into the vector table.

I can disable this behaviour if I remove:
Vector100:
.thumb_func

But then I have to touch vectors.S file which I would like to avoid.
Anyhow, the constant value which I want to put into the table comes from a #define in a .h header file, and I'm afraid there's no way to include this header without changing vectors.S

Looks like I don't get rid of this ugly architecture.

Have a nice sunday!
Post Reply