2017-12-11 11:04 AM
To make the firmware (flash offset 0x20000) start properly when branched into from my Bootloader (flash offset 0x0), I had to make the following changes to the system_stm32f4xx.c file and define a project symbol 'VECT_TAB_OFFSET=0x20000':
/* &sharpdefine VECT_TAB_SRAM */
&sharpif !defined(VECT_TAB_OFFSET)
&sharpdefine VECT_TAB_OFFSET 0x00 /*!< Vector Table base offset field.
This value must be a multiple of 0x200. */
&sharpendif
Memory regions definition in the linker file:
MEMORY
{
FLASH (rx) : ORIGIN = 0x08020000, LENGTH = 896K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 192K
MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K
CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K
}
Is there a better way to specify the address of the vector table without having to modify any Cube MX generated files?
#vector-table2017-12-11 12:06 PM
Round here we use symbols exported by the linker to do the job, this has been described to ST engineers several times, but they continue to use the #define method
extern void *__Vectors; // Or whatever name your startup.s exports
void SystemInit(void)
{
..
SCB->VTOR = (uint32_t)&__Vectors; // Let the linker do the job
}
You're going to have to modify something
2017-12-12 10:02 AM
,
,
Thanks for sharing Clive.
Personally I have no issue with the ♯ define itself and modifying one of ST's files would also be acceptable if my modifications didn't get lost each time I regenerate the code in CubeMX.
So, if anybody at ST are monitoring this community and read this, could you please allow modifications to stick in places where you foresee users will add new or modify existing code?
2017-12-13 03:18 AM
Hello,
I raised your feedback internally to CubeMx team.
Best Regards
Imen
2018-02-19 08:41 AM
Hello
Dahl.Odd_Gunnar
,
First of all, sorry for my late answer.
Regarding the user code to add in the generated code, you have the section USER BEGIN and USER END to fill with the code you want. These sections are present in all files under User repertory in the generated code.
If you need a new user section at a particular place in a specific file,please send us your request in order toanalyze it.
BR. Jeanne
2018-02-19 11:02 AM
,
,
The deeper point is that you shouldn't have to edit .C files to reflect the address you're going to place them at, this whole ♯ define ,
VECT_TAB_OFFSET nonsense is *NOT* how rational people have solved the issue, you shouldn't have to fiddle with build addresses in multiple places, and keep them orthogonal/coherent, the linker determines where the code is fixated in memory, use symbols. That's what linkers and tools are built to do, there isn't a need for a bunch of human interaction. This is the kind of junior engineer hackary that needs to be purged from the code base by people who understand how tools work.
This stuff is generally in the system_stm32xyz.c files. Grep the source trees for ,
VECT_TAB_OFFSET to grasp the scope.