cancel
Showing results for 
Search instead for 
Did you mean: 

Is there any way to change "Vector Table base offset" and making it fixed rather than let Cube change it every time the code is regenerated?

shayan0373n
Associate II

Hello,

I'm working with a bootloader so I need to change the Vector Table base offset to 0x00002000. This is done in system_stm32f1xx.c file:

#define VECT_TAB_OFFSET  0x00002000U /*!< Vector Table base offset field. This value must be a multiple of 0x200. */

But as this part of code is not inside a USER CODE section, every time I regenerate the code, I should change this macro manually. I'm looking for any better solutions.

Regards,

Shayan

4 REPLIES 4

I've pushed unsuccessfully for many years for the SystemInit() to set SCB->VTOR using a linker symbol for the vector table so the whole thing has a single dependency, ie where the linker places the code, and thus whatever you set in the build target dialog, linker script or scatter file. This is what a properly engineered solution should do, not have dependencies in multiple places, and use #defines

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
S.Ma
Principal

When CubeMX flexibility requirement increases, would we realize direct typing the C source be the ultimate freedom?

I do agree with you upon the necessity of "single dependency". So one solution can be that to define a symbol in linker descriptor such as:

VECTOR_ORIGIN = 0x08002000;

And then import the symbol inside the .c file; something like:

extern uint32_t VECTOR_ORIGIN;
SCB->VTOR = &VECTOR_ORIGIN;

But yet again, we need to somehow make this code regenerate-proof. So I would like to suggest adding a USER CODE section in this file.

Doubtlessly, the ultimate "freedom" can only be achieved by direct typing the C source. But these tools like Cube can give you quite a good head start when time is concerned.