Put constant value into interrupt vector table

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

Moderators: RoccoMarco, barthess

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

Put constant value into interrupt vector table

Postby rubenswerk » Sat Jun 22, 2019 11:52 pm

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: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Put constant value into interrupt vector table

Postby Giovanni » Sun Jun 23, 2019 4:55 am

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
Location: Austria

Re: Put constant value into interrupt vector table

Postby rubenswerk » Sun Jun 23, 2019 10:43 am

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!


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 20 guests