Page 1 of 1

Put constant value into interrupt vector table

Posted: Sat Jun 22, 2019 11:52 pm
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!

Re: Put constant value into interrupt vector table

Posted: Sun Jun 23, 2019 4:55 am
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

Re: Put constant value into interrupt vector table

Posted: Sun Jun 23, 2019 10:43 am
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!