2019-04-28 12:43 AM
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
2019-04-28 07:25 AM
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
2019-04-28 07:54 AM
When CubeMX flexibility requirement increases, would we realize direct typing the C source be the ultimate freedom?
2019-04-28 01:15 PM
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.
2019-04-28 01:25 PM
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.