cancel
Showing results for 
Search instead for 
Did you mean: 

Cube MX and VECT_TAB_OFFSET

tekampe
Associate II
Posted on October 05, 2016 at 17:48

Hello,

i am using a custom made bootloader on an stm32f107. So i need to change VECT_TAB_OFFSET in the application code to offset the vector table. But every time when i`m generating code with Cube Mx the file system_stm32f1xx.c gets overwritten. 

Is it possible to add a user code section to change the defiene?

Thanks for your help

#cube-mx-bootloader-vect_tab_offs
1 ACCEPTED SOLUTION

Accepted Solutions
stm32cube-t
Senior III
Posted on January 02, 2017 at 16:32

Hello,

The following has been implemented in 4.18 release: The system_stm32fxxx.c file is now copied into the src folder and can be modified by the user. 

View solution in original post

5 REPLIES 5
Posted on October 05, 2016 at 17:59

It seems unnecessary to even be using a define, this is the sort of thing rational people use the linker and public symbols to fix-up

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
slimen
Senior
Posted on October 05, 2016 at 18:13

Hello,

For information:To make the change in the STM32CubeMX generated code, you can insert your code in the user code sections parts :

/* USER CODE BEGIN 0 */

...
/* USER CODE END 0 */

In CubeMx for keeping the user code, you should check ''code generator'' setting and ensure that you check and tick ''Keep user code when re-generating'' as following: In CubeMX -> Project -> Settings -> ''Code Generator'' TAB, then tick ''Keep User Code when re-generating''. See related

/public/STe2ecommunities/mcu/Lists/STM32Java/Flat.aspx?RootFolder=https%3a//my.st.com/public/STe2ecommunities/mcu/Lists/STM32Java/cubemx%20stm32%20feature%20request%20support%20custom%20VECT_TAB_OFFSET&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000F9A0E3A95BA69146A17C2E80209ADC21&currentviews=188

. Regards
davidworden9
Associate II
Posted on October 05, 2016 at 19:44

clive1, would you happen to have any examples of what the changes look like in the linker and the public symbols?

I will be doing something very similar where I need to make modifications to the main application to support a bootloader, and I am gathering up information on what items need to be changed (including vector table offset).

Thank you!

Posted on October 05, 2016 at 20:55

extern void * __Vectors; // where startup_stm32fxxx.s EXPORTs __Vectors
void SystemInit(void)
{
/* FPU settings ------------------------------------------------------------*/
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
SCB->CPACR |= ((3UL << 
10
*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */
#endif
/* Configure the Vector Table location */
SCB->VTOR = (u32)(&__Vectors);
...
}

Have other practical gems like uint32_t SystemCoreClock = (((HSE_VALUE / PLL_M) * PLL_N) / PLL_P); Which while not entirely bullet-proof is orders of magnitude less numb-skulled than putting in yet another constant. And code inSetSysClock() that can actual determine which core it is running on and set maximal core, bus and flash wait states in an appropriate fashion. Which works well for DISCO F407G, F401C, F411 and F446 boards when I grab a random one to demo a code fragment or idea.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
stm32cube-t
Senior III
Posted on January 02, 2017 at 16:32

Hello,

The following has been implemented in 4.18 release: The system_stm32fxxx.c file is now copied into the src folder and can be modified by the user.