Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0152f37

Browse files
committedFeb 11, 2022
system: Set VTOR systematically at SystemInit()
When USART Bootloader jumps to application, it doesn't restore VTOR (Bootloader Vector Table is used). It is thus necessary to configure it unconditionally. By the way get ride of USER_VECT_TAB_ADDRESS Signed-off-by: Alexandre Bourdiol <[email protected]>
1 parent 1559816 commit 0152f37

File tree

15 files changed

+259
-251
lines changed

15 files changed

+259
-251
lines changed
 

‎system/STM32F1xx/system_stm32f1xx.c

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,33 @@
7979
/* #define DATA_IN_ExtSRAM */
8080
#endif /* STM32F100xE || STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */
8181

82-
/*!< Uncomment the following line if you need to relocate your vector Table in
83-
Internal SRAM. */
82+
83+
/* Note: Following vector table addresses must be defined in line with linker
84+
configuration. */
85+
86+
/*!< Uncomment the following line and change the address
87+
if you need to relocate your vector Table at a custom base address (+ VECT_TAB_OFFSET) */
88+
/* #define VECT_TAB_BASE_ADDRESS 0x08000000 */
89+
90+
/*!< Uncomment the following line if you need to relocate your vector Table
91+
in Sram else user remap will be done by default in Flash. */
8492
/* #define VECT_TAB_SRAM */
93+
8594
#ifndef VECT_TAB_OFFSET
86-
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
87-
This value must be a multiple of 0x200. */
95+
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
96+
This value must be a multiple of 0x200. */
8897
#endif
8998

99+
#ifndef VECT_TAB_BASE_ADDRESS
100+
#if defined(VECT_TAB_SRAM)
101+
#define VECT_TAB_BASE_ADDRESS SRAM_BASE /*!< Vector Table base address field.
102+
This value must be a multiple of 0x200. */
103+
#else
104+
#define VECT_TAB_BASE_ADDRESS FLASH_BASE /*!< Vector Table base address field.
105+
This value must be a multiple of 0x200. */
106+
#endif /* VECT_TAB_SRAM */
107+
#endif /* VECT_TAB_BASE_ADDRESS */
108+
90109

91110
/**
92111
* @}
@@ -195,11 +214,8 @@ void SystemInit (void)
195214
#endif /* DATA_IN_ExtSRAM */
196215
#endif
197216

198-
#ifdef VECT_TAB_SRAM
199-
SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM. */
200-
#else
201-
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH. */
202-
#endif
217+
/* Configure the Vector Table location add offset address ------------------*/
218+
SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET;
203219
}
204220

205221
/**

‎system/STM32F2xx/system_stm32f2xx.c

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,32 @@
6666
on STM322xG_EVAL board as data memory */
6767
/* #define DATA_IN_ExtSRAM */
6868

69-
/*!< Uncomment the following line if you need to relocate your vector Table in
70-
Internal SRAM. */
69+
/* Note: Following vector table addresses must be defined in line with linker
70+
configuration. */
71+
72+
/*!< Uncomment the following line and change the address
73+
if you need to relocate your vector Table at a custom base address (+ VECT_TAB_OFFSET) */
74+
/* #define VECT_TAB_BASE_ADDRESS 0x08000000 */
75+
76+
/*!< Uncomment the following line if you need to relocate your vector Table
77+
in Sram else user remap will be done by default in Flash. */
7178
/* #define VECT_TAB_SRAM */
79+
7280
#ifndef VECT_TAB_OFFSET
73-
#define VECT_TAB_OFFSET 0x00 /*!< Vector Table base offset field.
74-
This value must be a multiple of 0x200. */
81+
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
82+
This value must be a multiple of 0x200. */
7583
#endif
84+
85+
#ifndef VECT_TAB_BASE_ADDRESS
86+
#if defined(VECT_TAB_SRAM)
87+
#define VECT_TAB_BASE_ADDRESS SRAM_BASE /*!< Vector Table base address field.
88+
This value must be a multiple of 0x200. */
89+
#else
90+
#define VECT_TAB_BASE_ADDRESS FLASH_BASE /*!< Vector Table base address field.
91+
This value must be a multiple of 0x200. */
92+
#endif /* VECT_TAB_SRAM */
93+
#endif /* VECT_TAB_BASE_ADDRESS */
94+
7695
/******************************************************************************/
7796

7897
/**
@@ -155,11 +174,7 @@ void SystemInit(void)
155174
#endif /* DATA_IN_ExtSRAM */
156175

157176
/* Configure the Vector Table location add offset address ------------------*/
158-
#ifdef VECT_TAB_SRAM
159-
SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
160-
#else
161-
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
162-
#endif
177+
SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET;
163178
}
164179

165180
/**

‎system/STM32F3xx/system_stm32f3xx.c

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -84,32 +84,32 @@
8484
/** @addtogroup STM32F3xx_System_Private_Defines
8585
* @{
8686
*/
87-
#ifndef VECT_TAB_OFFSET
88-
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
89-
This value must be a multiple of 0x200. */
90-
#else
91-
#define USER_VECT_TAB_ADDRESS
92-
#endif
9387

9488
/* Note: Following vector table addresses must be defined in line with linker
9589
configuration. */
96-
/*!< Uncomment the following line if you need to relocate the vector table
97-
anywhere in Flash or Sram, else the vector table is kept at the automatic
98-
remap of boot address selected */
99-
/* #define USER_VECT_TAB_ADDRESS */
10090

101-
#if defined(USER_VECT_TAB_ADDRESS)
91+
/*!< Uncomment the following line and change the address
92+
if you need to relocate your vector Table at a custom base address (+ VECT_TAB_OFFSET) */
93+
/* #define VECT_TAB_BASE_ADDRESS 0x08000000 */
94+
10295
/*!< Uncomment the following line if you need to relocate your vector Table
103-
in Sram else user remap will be done in Flash. */
96+
in Sram else user remap will be done by default in Flash. */
10497
/* #define VECT_TAB_SRAM */
98+
99+
#ifndef VECT_TAB_OFFSET
100+
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
101+
This value must be a multiple of 0x200. */
102+
#endif
103+
104+
#ifndef VECT_TAB_BASE_ADDRESS
105105
#if defined(VECT_TAB_SRAM)
106106
#define VECT_TAB_BASE_ADDRESS SRAM_BASE /*!< Vector Table base address field.
107107
This value must be a multiple of 0x200. */
108108
#else
109109
#define VECT_TAB_BASE_ADDRESS FLASH_BASE /*!< Vector Table base address field.
110110
This value must be a multiple of 0x200. */
111111
#endif /* VECT_TAB_SRAM */
112-
#endif /* USER_VECT_TAB_ADDRESS */
112+
#endif /* VECT_TAB_BASE_ADDRESS */
113113

114114
/******************************************************************************/
115115
/**
@@ -194,9 +194,7 @@ void SystemInit(void)
194194
RCC->CIR = 0x009F0000U;
195195

196196
/* Configure the Vector Table location -------------------------------------*/
197-
#if defined(USER_VECT_TAB_ADDRESS)
198-
SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation */
199-
#endif /* USER_VECT_TAB_ADDRESS */
197+
SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET;
200198
}
201199

202200
/**

‎system/STM32F4xx/system_stm32f4xx.c

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -79,32 +79,33 @@
7979
#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx ||\
8080
STM32F479xx */
8181

82-
#ifndef VECT_TAB_OFFSET
83-
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
84-
This value must be a multiple of 0x200. */
85-
#else
86-
#define USER_VECT_TAB_ADDRESS
87-
#endif
88-
8982
/* Note: Following vector table addresses must be defined in line with linker
9083
configuration. */
91-
/*!< Uncomment the following line if you need to relocate the vector table
92-
anywhere in Flash or Sram, else the vector table is kept at the automatic
93-
remap of boot address selected */
94-
/* #define USER_VECT_TAB_ADDRESS */
9584

96-
#if defined(USER_VECT_TAB_ADDRESS)
85+
/*!< Uncomment the following line and change the address
86+
if you need to relocate your vector Table at a custom base address (+ VECT_TAB_OFFSET) */
87+
/* #define VECT_TAB_BASE_ADDRESS 0x08000000 */
88+
9789
/*!< Uncomment the following line if you need to relocate your vector Table
98-
in Sram else user remap will be done in Flash. */
90+
in Sram else user remap will be done by default in Flash. */
9991
/* #define VECT_TAB_SRAM */
92+
93+
#ifndef VECT_TAB_OFFSET
94+
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
95+
This value must be a multiple of 0x200. */
96+
#endif
97+
98+
#ifndef VECT_TAB_BASE_ADDRESS
10099
#if defined(VECT_TAB_SRAM)
101100
#define VECT_TAB_BASE_ADDRESS SRAM_BASE /*!< Vector Table base address field.
102101
This value must be a multiple of 0x200. */
103102
#else
104103
#define VECT_TAB_BASE_ADDRESS FLASH_BASE /*!< Vector Table base address field.
105104
This value must be a multiple of 0x200. */
106105
#endif /* VECT_TAB_SRAM */
107-
#endif /* USER_VECT_TAB_ADDRESS */
106+
#endif /* VECT_TAB_BASE_ADDRESS */
107+
108+
108109
/******************************************************************************/
109110

110111
/**
@@ -193,9 +194,7 @@ void SystemInit(void)
193194
#endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */
194195

195196
/* Configure the Vector Table location -------------------------------------*/
196-
#if defined(USER_VECT_TAB_ADDRESS)
197-
SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
198-
#endif /* USER_VECT_TAB_ADDRESS */
197+
SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET;
199198
}
200199

201200
/**

‎system/STM32F7xx/system_stm32f7xx.c

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,31 +63,32 @@
6363
*/
6464

6565
/************************* Miscellaneous Configuration ************************/
66+
/* Note: Following vector table addresses must be defined in line with linker
67+
configuration. */
6668

69+
/*!< Uncomment the following line and change the address
70+
if you need to relocate your vector Table at a custom base address (+ VECT_TAB_OFFSET) */
71+
/* #define VECT_TAB_BASE_ADDRESS 0x08000000 */
72+
73+
/*!< Uncomment the following line if you need to relocate your vector Table
74+
in Sram else user remap will be done by default in Flash. */
75+
/* #define VECT_TAB_SRAM */
6776

6877
#ifndef VECT_TAB_OFFSET
6978
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
7079
This value must be a multiple of 0x200. */
71-
#else
72-
#define USER_VECT_TAB_ADDRESS
7380
#endif
7481

75-
/* Note: Following vector table addresses must be defined in line with linker
76-
configuration. */
77-
/*!< Define USER_VECT_TAB_ADDRESS line if you need to relocate the vector table
78-
anywhere in Flash or Sram, else the vector table is kept at the automatic
79-
remap of boot address selected */
80-
#if defined(USER_VECT_TAB_ADDRESS)
81-
/*!< Define VECT_TAB_SRAM if you need to relocate your vector Table
82-
in Sram else user remap will be done in Flash. */
82+
#ifndef VECT_TAB_BASE_ADDRESS
8383
#if defined(VECT_TAB_SRAM)
8484
#define VECT_TAB_BASE_ADDRESS RAMDTCM_BASE /*!< Vector Table base address field.
8585
This value must be a multiple of 0x200. */
8686
#else
8787
#define VECT_TAB_BASE_ADDRESS FLASH_BASE /*!< Vector Table base address field.
8888
This value must be a multiple of 0x200. */
8989
#endif /* VECT_TAB_SRAM */
90-
#endif /* USER_VECT_TAB_ADDRESS */
90+
#endif /* VECT_TAB_BASE_ADDRESS */
91+
9192
/******************************************************************************/
9293

9394
/**
@@ -168,9 +169,7 @@ void SystemInit(void)
168169

169170

170171
/* Configure the Vector Table location -------------------------------------*/
171-
#if defined(USER_VECT_TAB_ADDRESS)
172-
SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
173-
#endif /* USER_VECT_TAB_ADDRESS */
172+
SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET;
174173
}
175174

176175
/**

‎system/STM32G0xx/system_stm32g0xx.c

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -93,32 +93,33 @@
9393
*/
9494

9595
/************************* Miscellaneous Configuration ************************/
96-
#ifndef VECT_TAB_OFFSET
97-
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
98-
This value must be a multiple of 0x200. */
99-
#else
100-
#define USER_VECT_TAB_ADDRESS
101-
#endif
102-
10396
/* Note: Following vector table addresses must be defined in line with linker
10497
configuration. */
105-
/*!< Uncomment the following line if you need to relocate the vector table
106-
anywhere in Flash or Sram, else the vector table is kept at the automatic
107-
remap of boot address selected */
108-
/* #define USER_VECT_TAB_ADDRESS */
10998

110-
#if defined(USER_VECT_TAB_ADDRESS)
99+
/*!< Uncomment the following line and change the address
100+
if you need to relocate your vector Table at a custom base address (+ VECT_TAB_OFFSET) */
101+
/* #define VECT_TAB_BASE_ADDRESS 0x08000000 */
102+
111103
/*!< Uncomment the following line if you need to relocate your vector Table
112-
in Sram else user remap will be done in Flash. */
104+
in Sram else user remap will be done by default in Flash. */
113105
/* #define VECT_TAB_SRAM */
106+
107+
#ifndef VECT_TAB_OFFSET
108+
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
109+
This value must be a multiple of 0x100. */
110+
#endif
111+
112+
#ifndef VECT_TAB_BASE_ADDRESS
114113
#if defined(VECT_TAB_SRAM)
115114
#define VECT_TAB_BASE_ADDRESS SRAM_BASE /*!< Vector Table base address field.
116-
This value must be a multiple of 0x200. */
115+
This value must be a multiple of 0x100. */
117116
#else
118117
#define VECT_TAB_BASE_ADDRESS FLASH_BASE /*!< Vector Table base address field.
119-
This value must be a multiple of 0x200. */
118+
This value must be a multiple of 0x100. */
120119
#endif /* VECT_TAB_SRAM */
121-
#endif /* USER_VECT_TAB_ADDRESS */
120+
#endif /* VECT_TAB_BASE_ADDRESS */
121+
122+
122123
/******************************************************************************/
123124
/**
124125
* @}
@@ -197,9 +198,7 @@ void SystemInit(void)
197198
#endif
198199

199200
/* Configure the Vector Table location -------------------------------------*/
200-
#if defined(USER_VECT_TAB_ADDRESS)
201-
SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation */
202-
#endif /* USER_VECT_TAB_ADDRESS */
201+
SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET;
203202
}
204203

205204
/**

‎system/STM32G4xx/system_stm32g4xx.c

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -94,31 +94,32 @@
9494
*/
9595

9696
/************************* Miscellaneous Configuration ************************/
97-
#ifndef VECT_TAB_OFFSET
98-
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
99-
This value must be a multiple of 0x200. */
100-
#else
101-
#define USER_VECT_TAB_ADDRESS
102-
#endif
103-
10497
/* Note: Following vector table addresses must be defined in line with linker
10598
configuration. */
106-
/*!< Uncomment the following line if you need to relocate the vector table
107-
anywhere in Flash or Sram, else the vector table is kept at the automatic
108-
remap of boot address selected */
10999

110-
#if defined(USER_VECT_TAB_ADDRESS)
100+
/*!< Uncomment the following line and change the address
101+
if you need to relocate your vector Table at a custom base address (+ VECT_TAB_OFFSET) */
102+
/* #define VECT_TAB_BASE_ADDRESS 0x08000000 */
103+
111104
/*!< Uncomment the following line if you need to relocate your vector Table
112-
in Sram else user remap will be done in Flash. */
105+
in Sram else user remap will be done by default in Flash. */
113106
/* #define VECT_TAB_SRAM */
107+
108+
#ifndef VECT_TAB_OFFSET
109+
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
110+
This value must be a multiple of 0x200. */
111+
#endif
112+
113+
#ifndef VECT_TAB_BASE_ADDRESS
114114
#if defined(VECT_TAB_SRAM)
115115
#define VECT_TAB_BASE_ADDRESS SRAM_BASE /*!< Vector Table base address field.
116116
This value must be a multiple of 0x200. */
117117
#else
118118
#define VECT_TAB_BASE_ADDRESS FLASH_BASE /*!< Vector Table base address field.
119119
This value must be a multiple of 0x200. */
120120
#endif /* VECT_TAB_SRAM */
121-
#endif /* USER_VECT_TAB_ADDRESS */
121+
#endif /* VECT_TAB_BASE_ADDRESS */
122+
122123
/******************************************************************************/
123124
/**
124125
* @}
@@ -195,9 +196,7 @@ void SystemInit(void)
195196
RCC->CICR = 0x0000073BU;
196197

197198
/* Configure the Vector Table location add offset address ------------------*/
198-
#if defined(USER_VECT_TAB_ADDRESS)
199-
SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
200-
#endif /* USER_VECT_TAB_ADDRESS */
199+
SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET;
201200
}
202201

203202
/**

‎system/STM32H7xx/system_stm32h7xx.c

Lines changed: 22 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -64,44 +64,39 @@
6464
*/
6565

6666
/************************* Miscellaneous Configuration ************************/
67-
/*!< Uncomment the following line if you need to use initialized data in D2 domain SRAM (AHB SRAM) */
68-
/* #define DATA_IN_D2_SRAM */
6967

70-
/*!< Uncomment the following line if you need to relocate your vector Table in
71-
Internal SRAM. */
72-
/* #define VECT_TAB_SRAM */
73-
#ifndef VECT_TAB_OFFSET
74-
#define VECT_TAB_OFFSET 0x00000000UL /*!< Vector Table base offset field.
75-
This value must be a multiple of 0x200. */
76-
#else
7768

78-
#define USER_VECT_TAB_ADDRESS
7969

80-
#endif
70+
71+
#if defined(DUAL_CORE) && defined(CORE_CM4)
72+
8173

8274
/* Note: Following vector table addresses must be defined in line with linker
8375
configuration. */
84-
/*!< Define USER_VECT_TAB_ADDRESS if you need to relocate the vector table
8576

86-
anywhere in Flash or Sram, else the vector table is kept at the automatic
77+
/*!< Uncomment the following line and change the address
78+
if you need to relocate your vector Table at a custom base address (+ VECT_TAB_OFFSET) */
79+
/* #define VECT_TAB_BASE_ADDRESS 0x08000000 */
8780

88-
remap of boot address selected */
89-
#if defined(USER_VECT_TAB_ADDRESS)
90-
#if defined(DUAL_CORE) && defined(CORE_CM4)
91-
/*!< Define VECT_TAB_SRAM if you need to relocate your vector Table
81+
/*!< Uncomment the following line if you need to relocate your vector Table
82+
in Sram else user remap will be done by default in Flash. */
83+
/* #define VECT_TAB_SRAM */
84+
85+
#ifndef VECT_TAB_OFFSET
86+
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
87+
This value must be a multiple of 0x200. */
88+
#endif
9289

93-
in Sram else user remap will be done in Flash. */
90+
#if defined(DUAL_CORE) && defined(CORE_CM4)
9491
#if defined(VECT_TAB_SRAM)
9592
#define VECT_TAB_BASE_ADDRESS D2_AXISRAM_BASE /*!< Vector Table base address field.
9693
This value must be a multiple of 0x200. */
9794
#else
9895
#define VECT_TAB_BASE_ADDRESS FLASH_BANK2_BASE /*!< Vector Table base address field.
9996
This value must be a multiple of 0x200. */
10097
#endif /* VECT_TAB_SRAM */
101-
#else
102-
/*!< Define VECT_TAB_SRAM if you need to relocate your vector Table
10398

104-
in Sram else user remap will be done in Flash. */
99+
#else
105100
#if defined(VECT_TAB_SRAM)
106101
#define VECT_TAB_BASE_ADDRESS D1_AXISRAM_BASE /*!< Vector Table base address field.
107102
This value must be a multiple of 0x200. */
@@ -110,7 +105,8 @@
110105
This value must be a multiple of 0x200. */
111106
#endif /* VECT_TAB_SRAM */
112107
#endif /* DUAL_CORE && CORE_CM4 */
113-
#endif /* USER_VECT_TAB_ADDRESS */
108+
109+
114110

115111
/******************************************************************************/
116112

@@ -271,27 +267,17 @@ void SystemInit (void)
271267
(void) tmpreg;
272268
#endif /* DATA_IN_D2_SRAM */
273269

274-
#if defined(DUAL_CORE) && defined(CORE_CM4)
275-
/* Configure the Vector Table location add offset address for cortex-M4 ------------------*/
276-
#if defined(USER_VECT_TAB_ADDRESS)
277-
SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal D2 AXI-RAM or in Internal FLASH */
278-
#endif /* USER_VECT_TAB_ADDRESS */
279-
280-
#else
281-
270+
#if !defined(DUAL_CORE) || defined(CORE_CM7)
282271
/*
283272
* Disable the FMC bank1 (enabled after reset).
284273
* This, prevents CPU speculation access on this bank which blocks the use of FMC during
285274
* 24us. During this time the others FMC master (such as LTDC) cannot use it!
286275
*/
287276
FMC_Bank1_R->BTCR[0] = 0x000030D2;
277+
#endif /* !DUAL_CORE || CORE_CM7 */
288278

289-
/* Configure the Vector Table location add offset address for cortex-M7 ------------------*/
290-
#if defined(USER_VECT_TAB_ADDRESS)
291-
SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal D1 AXI-RAM or in Internal FLASH */
292-
#endif /* USER_VECT_TAB_ADDRESS */
293-
294-
#endif /*DUAL_CORE && CORE_CM4*/
279+
/* Configure the Vector Table location add offset address for cortex-M7 or for cortex-M4 ------------------*/
280+
SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET;
295281

296282
}
297283

‎system/STM32L0xx/system_stm32l0xx.c

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -63,33 +63,32 @@
6363
* @{
6464
*/
6565
/************************* Miscellaneous Configuration ************************/
66-
67-
#ifndef VECT_TAB_OFFSET
68-
#define VECT_TAB_OFFSET 0x00U /*!< Vector Table base offset field.
69-
This value must be a multiple of 0x100. */
70-
#else
71-
define USER_VECT_TAB_ADDRESS
72-
#endif
73-
7466
/* Note: Following vector table addresses must be defined in line with linker
7567
configuration. */
76-
/*!< Uncomment the following line if you need to relocate the vector table
77-
anywhere in Flash or Sram, else the vector table is kept at the automatic
78-
remap of boot address selected */
79-
/* #define USER_VECT_TAB_ADDRESS */
8068

81-
#if defined(USER_VECT_TAB_ADDRESS)
69+
/*!< Uncomment the following line and change the address
70+
if you need to relocate your vector Table at a custom base address (+ VECT_TAB_OFFSET) */
71+
/* #define VECT_TAB_BASE_ADDRESS 0x08000000 */
72+
8273
/*!< Uncomment the following line if you need to relocate your vector Table
83-
in Sram else user remap will be done in Flash. */
74+
in Sram else user remap will be done by default in Flash. */
8475
/* #define VECT_TAB_SRAM */
76+
77+
#ifndef VECT_TAB_OFFSET
78+
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
79+
This value must be a multiple of 0x100. */
80+
#endif
81+
82+
#ifndef VECT_TAB_BASE_ADDRESS
8583
#if defined(VECT_TAB_SRAM)
8684
#define VECT_TAB_BASE_ADDRESS SRAM_BASE /*!< Vector Table base address field.
87-
This value must be a multiple of 0x200. */
85+
This value must be a multiple of 0x100. */
8886
#else
8987
#define VECT_TAB_BASE_ADDRESS FLASH_BASE /*!< Vector Table base address field.
90-
This value must be a multiple of 0x200. */
88+
This value must be a multiple of 0x100. */
9189
#endif /* VECT_TAB_SRAM */
92-
#endif /* USER_VECT_TAB_ADDRESS */
90+
#endif /* VECT_TAB_BASE_ADDRESS */
91+
9392

9493
/******************************************************************************/
9594
/**
@@ -172,9 +171,7 @@ void SystemInit (void)
172171
#endif
173172

174173
/* Configure the Vector Table location add offset address ------------------*/
175-
#if defined (USER_VECT_TAB_ADDRESS)
176-
SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
177-
#endif /* USER_VECT_TAB_ADDRESS */
174+
SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET;
178175
}
179176

180177
/**

‎system/STM32L1xx/system_stm32l1xx.c

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,32 +67,31 @@
6767
/* #define DATA_IN_ExtSRAM */
6868

6969

70-
#ifndef VECT_TAB_OFFSET
71-
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
72-
This value must be a multiple of 0x200. */
73-
#else
74-
#define USER_VECT_TAB_ADDRESS
75-
#endif
76-
7770
/* Note: Following vector table addresses must be defined in line with linker
7871
configuration. */
79-
/*!< Uncomment the following line if you need to relocate the vector table
80-
anywhere in Flash or Sram, else the vector table is kept at the automatic
81-
remap of boot address selected */
82-
/* #define USER_VECT_TAB_ADDRESS */
8372

84-
#if defined(USER_VECT_TAB_ADDRESS)
73+
/*!< Uncomment the following line and change the address
74+
if you need to relocate your vector Table at a custom base address (+ VECT_TAB_OFFSET) */
75+
/* #define VECT_TAB_BASE_ADDRESS 0x08000000 */
76+
8577
/*!< Uncomment the following line if you need to relocate your vector Table
86-
in Sram else user remap will be done in Flash. */
78+
in Sram else user remap will be done by default in Flash. */
8779
/* #define VECT_TAB_SRAM */
80+
81+
#ifndef VECT_TAB_OFFSET
82+
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
83+
This value must be a multiple of 0x200. */
84+
#endif
85+
86+
#ifndef VECT_TAB_BASE_ADDRESS
8887
#if defined(VECT_TAB_SRAM)
8988
#define VECT_TAB_BASE_ADDRESS SRAM_BASE /*!< Vector Table base address field.
9089
This value must be a multiple of 0x200. */
9190
#else
9291
#define VECT_TAB_BASE_ADDRESS FLASH_BASE /*!< Vector Table base address field.
9392
This value must be a multiple of 0x200. */
9493
#endif /* VECT_TAB_SRAM */
95-
#endif /* USER_VECT_TAB_ADDRESS */
94+
#endif /* VECT_TAB_BASE_ADDRESS */
9695

9796
/******************************************************************************/
9897
/**
@@ -181,9 +180,7 @@ void SystemInit (void)
181180
#endif /* DATA_IN_ExtSRAM */
182181

183182
/* Configure the Vector Table location -------------------------------------*/
184-
#if defined(USER_VECT_TAB_ADDRESS)
185-
SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH or SRAM. */
186-
#endif /* USER_VECT_TAB_ADDRESS */
183+
SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET;
187184
}
188185

189186
/**

‎system/STM32L4xx/system_stm32l4xx.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -107,29 +107,31 @@
107107
*/
108108

109109
/************************* Miscellaneous Configuration ************************/
110+
/* Note: Following vector table addresses must be defined in line with linker
111+
configuration. */
112+
113+
/*!< Uncomment the following line and change the address
114+
if you need to relocate your vector Table at a custom base address (+ VECT_TAB_OFFSET) */
115+
/* #define VECT_TAB_BASE_ADDRESS 0x08000000 */
116+
117+
/*!< Uncomment the following line if you need to relocate your vector Table
118+
in Sram else user remap will be done by default in Flash. */
119+
/* #define VECT_TAB_SRAM */
120+
110121
#ifndef VECT_TAB_OFFSET
111122
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
112123
This value must be a multiple of 0x200. */
113-
#else
114-
#define USER_VECT_TAB_ADDRESS
115124
#endif
116125

117-
/* Note: Following vector table addresses must be defined in line with linker
118-
configuration. */
119-
/*!< Define USER_VECT_TAB_ADDRESS if you need to relocate the vector table
120-
anywhere in Flash or Sram, else the vector table is kept at the automatic
121-
remap of boot address selected */
122-
#if defined(USER_VECT_TAB_ADDRESS)
123-
/*!< Define VECT_TAB_SRAM if you need to relocate your vector Table
124-
in Sram else user remap will be done in Flash. */
126+
#ifndef VECT_TAB_BASE_ADDRESS
125127
#if defined(VECT_TAB_SRAM)
126128
#define VECT_TAB_BASE_ADDRESS SRAM1_BASE /*!< Vector Table base address field.
127129
This value must be a multiple of 0x200. */
128130
#else
129131
#define VECT_TAB_BASE_ADDRESS FLASH_BASE /*!< Vector Table base address field.
130132
This value must be a multiple of 0x200. */
131133
#endif /* VECT_TAB_SRAM */
132-
#endif /* USER_VECT_TAB_ADDRESS */
134+
#endif /* VECT_TAB_BASE_ADDRESS */
133135

134136
/******************************************************************************/
135137
/**
@@ -185,10 +187,8 @@
185187

186188
void SystemInit(void)
187189
{
188-
#if defined(USER_VECT_TAB_ADDRESS)
189190
/* Configure the Vector Table location -------------------------------------*/
190191
SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET;
191-
#endif
192192

193193
/* FPU settings ------------------------------------------------------------*/
194194
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)

‎system/STM32L5xx/system_stm32l5xx_ns.c

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,33 +70,31 @@
7070
/** @addtogroup STM32L5xx_System_Private_Defines
7171
* @{
7272
*/
73-
#ifndef VECT_TAB_OFFSET
74-
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
75-
This value must be a multiple of 0x200. */
76-
#else
77-
define USER_VECT_TAB_ADDRESS
78-
#endif
79-
8073
/* Note: Following vector table addresses must be defined in line with linker
8174
configuration. */
82-
/*!< Uncomment the following line if you need to relocate the vector table
83-
anywhere in Flash or Sram, else the vector table is kept at the automatic
84-
remap of boot address selected */
85-
/* #define USER_VECT_TAB_ADDRESS */
8675

87-
#if defined(USER_VECT_TAB_ADDRESS)
76+
/*!< Uncomment the following line and change the address
77+
if you need to relocate your vector Table at a custom base address (+ VECT_TAB_OFFSET) */
78+
/* #define VECT_TAB_BASE_ADDRESS 0x08000000 */
79+
8880
/*!< Uncomment the following line if you need to relocate your vector Table
89-
in Sram else user remap will be done in Flash. */
81+
in Sram else user remap will be done by default in Flash. */
9082
/* #define VECT_TAB_SRAM */
9183

84+
#ifndef VECT_TAB_OFFSET
85+
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
86+
This value must be a multiple of 0x200. */
87+
#endif
88+
89+
#ifndef VECT_TAB_BASE_ADDRESS
9290
#if defined(VECT_TAB_SRAM)
9391
#define VECT_TAB_BASE_ADDRESS SRAM1_BASE_NS /*!< Vector Table base address field.
9492
This value must be a multiple of 0x200. */
9593
#else
9694
#define VECT_TAB_BASE_ADDRESS FLASH_BASE_NS /*!< Vector Table base address field.
9795
This value must be a multiple of 0x200. */
9896
#endif /* VECT_TAB_SRAM */
99-
#endif /* USER_VECT_TAB_ADDRESS */
97+
#endif /* VECT_TAB_BASE_ADDRESS */
10098

10199
/******************************************************************************/
102100
/**
@@ -153,9 +151,7 @@ define USER_VECT_TAB_ADDRESS
153151
void SystemInit(void)
154152
{
155153
/* Configure the Vector Table location -------------------------------------*/
156-
#if defined(USER_VECT_TAB_ADDRESS)
157154
SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET;
158-
#endif
159155

160156
/* Reset the RCC clock configuration to the default reset state ------------*/
161157
/* Set MSION bit */

‎system/STM32U5xx/system_stm32u5xx.c

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,32 @@
121121

122122

123123
/************************* Miscellaneous Configuration ************************/
124-
/*!< Uncomment the following line if you need to relocate your vector Table in
125-
Internal SRAM. */
124+
/* Note: Following vector table addresses must be defined in line with linker
125+
configuration. */
126+
127+
/*!< Uncomment the following line and change the address
128+
if you need to relocate your vector Table at a custom base address (+ VECT_TAB_OFFSET) */
129+
/* #define VECT_TAB_BASE_ADDRESS 0x08000000 */
130+
131+
/*!< Uncomment the following line if you need to relocate your vector Table
132+
in Sram else user remap will be done by default in Flash. */
126133
/* #define VECT_TAB_SRAM */
134+
127135
#ifndef VECT_TAB_OFFSET
128-
#define VECT_TAB_OFFSET 0x00000000UL /*!< Vector Table base offset field.
129-
This value must be a multiple of 0x200. */
136+
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
137+
This value must be a multiple of 0x200. */
130138
#endif
139+
140+
#ifndef VECT_TAB_BASE_ADDRESS
141+
#if defined(VECT_TAB_SRAM)
142+
#define VECT_TAB_BASE_ADDRESS SRAM1_BASE /*!< Vector Table base address field.
143+
This value must be a multiple of 0x200. */
144+
#else
145+
#define VECT_TAB_BASE_ADDRESS FLASH_BASE /*!< Vector Table base address field.
146+
This value must be a multiple of 0x200. */
147+
#endif /* VECT_TAB_SRAM */
148+
#endif /* VECT_TAB_BASE_ADDRESS */
149+
131150
/******************************************************************************/
132151

133152
/**
@@ -211,11 +230,7 @@ void SystemInit(void)
211230
RCC->CICR = 0x00001DFFU;
212231

213232
/* Configure the Vector Table location add offset address ------------------*/
214-
#ifdef VECT_TAB_SRAM
215-
SCB->VTOR = SRAM1_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
216-
#else
217-
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
218-
#endif
233+
SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET;
219234
}
220235

221236
/**

‎system/STM32WBxx/system_stm32wbxx.c

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -101,29 +101,31 @@
101101
* @{
102102
*/
103103

104+
/* Note: Following vector table addresses must be defined in line with linker
105+
configuration. */
106+
107+
/*!< Uncomment the following line and change the address
108+
if you need to relocate your vector Table at a custom base address (+ VECT_TAB_OFFSET) */
109+
/* #define VECT_TAB_BASE_ADDRESS 0x08000000 */
110+
111+
/*!< Uncomment the following line if you need to relocate your vector Table
112+
in Sram else user remap will be done by default in Flash. */
113+
/* #define VECT_TAB_SRAM */
114+
104115
#ifndef VECT_TAB_OFFSET
105116
#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field.
106117
This value must be a multiple of 0x200. */
107-
#else
108-
#define USER_VECT_TAB_ADDRESS
109118
#endif
110119

111-
/* Note: Following vector table addresses must be defined in line with linker
112-
configuration. */
113-
/*!< Define USER_VECT_TAB_ADDRESS if you need to relocate CPU1 CM4 and/or CPU2
114-
CM0+ vector table anywhere in Sram or Flash. Else vector table will be kept
115-
at address 0x00 which correspond to automatic remap of boot address selected */
116-
#if defined(USER_VECT_TAB_ADDRESS)
117-
/*!< Define VECT_TAB_SRAM for user vector table remap in Sram else user remap
118-
will be done in Flash. */
120+
#ifndef VECT_TAB_BASE_ADDRESS
119121
#if defined(VECT_TAB_SRAM)
120122
#define VECT_TAB_BASE_ADDRESS SRAM1_BASE /*!< Vector Table base address field.
121123
This value must be a multiple of 0x200. */
122124
#else
123125
#define VECT_TAB_BASE_ADDRESS FLASH_BASE /*!< Vector Table base address field.
124126
This value must be a multiple of 0x200. */
125-
#endif
126-
#endif
127+
#endif /* VECT_TAB_SRAM */
128+
#endif /* VECT_TAB_BASE_ADDRESS */
127129

128130
/**
129131
* @}
@@ -187,10 +189,7 @@
187189
*/
188190
void SystemInit(void)
189191
{
190-
#if defined(USER_VECT_TAB_ADDRESS)
191-
/* Configure the Vector Table location add offset address ------------------*/
192192
SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET;
193-
#endif
194193

195194
/* FPU settings ------------------------------------------------------------*/
196195
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)

‎system/STM32WLxx/system_stm32wlxx.c

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -101,44 +101,40 @@
101101
* @{
102102
*/
103103

104+
/* Note: Following vector table addresses must be defined in line with linker
105+
configuration. */
106+
107+
/*!< Uncomment the following line and change the address
108+
if you need to relocate your vector Table at a custom base address (+ VECT_TAB_OFFSET) */
109+
/* #define VECT_TAB_BASE_ADDRESS 0x08000000 */
110+
111+
/*!< Uncomment the following line if you need to relocate your vector Table
112+
in Sram else user remap will be done by default in Flash. */
113+
/* #define VECT_TAB_SRAM */
114+
104115
#ifndef VECT_TAB_OFFSET
105116
#define VECT_TAB_OFFSET 0x00008000U /*!< Vector Table base offset field.
106117
This value must be a multiple of 0x100. */
107-
#else
108-
#define USER_VECT_TAB_ADDRESS
109118
#endif
110119

111-
/* Note: Following vector table addresses must be defined in line with linker
112-
configuration. */
113-
/*!< Uncomment the following line if you need to relocate CPU1 CM4 and/or CPU2
114-
CM0+ vector table anywhere in Sram or Flash. Else vector table will be kept
115-
at address 0x00 which correspond to automatic remap of boot address selected */
116-
/* #define USER_VECT_TAB_ADDRESS */
117-
#if defined(USER_VECT_TAB_ADDRESS)
118-
#ifdef CORE_CM0PLUS
119-
/*!< Uncomment this line for user vector table remap in Sram else user remap
120-
will be done in Flash. */
121-
/* #define VECT_TAB_SRAM */
120+
#if defined(CORE_CM0PLUS)
122121
#if defined(VECT_TAB_SRAM)
123122
#define VECT_TAB_BASE_ADDRESS SRAM2_BASE /*!< Vector Table base address field.
124123
This value must be a multiple of 0x100. */
125124
#else
126125
#define VECT_TAB_BASE_ADDRESS FLASH_BASE /*!< Vector Table base address field.
127126
This value must be a multiple of 0x100. */
128-
#endif
127+
#endif /* VECT_TAB_SRAM */
128+
129129
#else /* CORE_CM4 */
130-
/*!< Uncomment this line for user vector table remap in Sram else user remap
131-
will be done in Flash. */
132-
/* #define VECT_TAB_SRAM */
133130
#if defined(VECT_TAB_SRAM)
134131
#define VECT_TAB_BASE_ADDRESS SRAM1_BASE /*!< Vector Table base address field.
135-
This value must be a multiple of 0x200. */
132+
This value must be a multiple of 0x100. */
136133
#else
137134
#define VECT_TAB_BASE_ADDRESS FLASH_BASE /*!< Vector Table base address field.
138-
This value must be a multiple of 0x200. */
139-
#endif
140-
#endif
141-
#endif
135+
This value must be a multiple of 0x100. */
136+
#endif /* VECT_TAB_SRAM */
137+
#endif /* CORE_CM0PLUS */
142138

143139
/**
144140
* @}
@@ -208,10 +204,7 @@ void SystemInit(void)
208204
RCC->CIER = 0x00000000U;
209205
RCC->CICR = 0x0000033FU;
210206

211-
#if defined(USER_VECT_TAB_ADDRESS)
212-
/* Configure the Vector Table location add offset address ------------------*/
213207
SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET;
214-
#endif
215208

216209
/* FPU settings ------------------------------------------------------------*/
217210
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)

0 commit comments

Comments
 (0)
Please sign in to comment.