Skip to content

Commit 3d96020

Browse files
fpistmABOSTM
authored andcommitted
Fix SysTick_Handler definition for CM33 and CMSIS V2
SysTick_Handler() from stm32duino core is calling weak osSystickHandler(). Both CMSIS-RTOSv2 and CMSIS-RTOS override osSystickHandler() which is calling xPortSysTickHandler(), defined in respective CortexM-x port Note: It is necessary to go through this function (osSystickHandler()) that checks whether scheduler is started otherwise there are issue when systick interrupt fires before FreeRTOS is started Signed-off-by: Alexandre Bourdiol <[email protected]>
1 parent adba678 commit 3d96020

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ CMSIS-RTOSv2.
111111
| --- | :---: | :---: | :---: | :---: | :---: |
112112
| [Nucleo F091RC (Cortex-M0)](http://www.st.com/en/evaluation-tools/nucleo-f091rc.html) | PASSED | PASSED | FAILED | PASSED | PASSED |
113113
| [Nucleo G071RB (Cortex-M0+)](http://www.st.com/en/evaluation-tools/nucleo-g071rb.html) | PASSED | PASSED | FAILED | PASSED | PASSED |
114-
| [Nucleo L476RG (Cortex-M3)](http://www.st.com/en/evaluation-tools/nucleo-l476rg.html) | PASSED | PASSED | PASSED | PASSED | PASSED |
114+
| [Nucleo F103RB (Cortex-M3)](http://www.st.com/en/evaluation-tools/nucleo-f103rb.html) | PASSED | PASSED | PASSED | PASSED | PASSED |
115115
| [Nucleo L476RG (Cortex-M4)](http://www.st.com/en/evaluation-tools/nucleo-l476rg.html) | PASSED | PASSED | PASSED | PASSED | PASSED |
116116
| [Nucleo H743ZI (Cortex-M7)](https://www.st.com/en/evaluation-tools/nucleo-h743zi.html) | PASSED | PASSED | PASSED | PASSED | PASSED |
117+
| [Nucleo L552ZE-Q (Cortex-M33)](https://www.st.com/en/evaluation-tools/nucleo-l552ze-q.html) | PASSED | PASSED | PASSED | PASSED | PASSED |
118+
| [Nucleo U575ZI-Q (Cortex-M33)](https://www.st.com/en/evaluation-tools/nucleo-u575zi-q.html) | PASSED | PASSED | PASSED | PASSED | PASSED |

portable/CMSIS_RTOS_V2/cmsis_os2.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ extern void xPortSysTickHandler (void);
156156
SysTick handler implementation that also clears overflow flag.
157157
*/
158158
/* SysTick handler implementation done in the core and call osSystickHandler */
159-
#if !defined(ARDUINO_ARCH_STM32) && (USE_CUSTOM_SYSTICK_HANDLER_IMPLEMENTATION == 0)
160-
void SysTick_Handler (void) {
159+
#if (USE_CUSTOM_SYSTICK_HANDLER_IMPLEMENTATION == 0)
160+
void osSystickHandler (void) {
161161
/* Clear overflow flag */
162162
SysTick->CTRL;
163163

@@ -166,7 +166,7 @@ void SysTick_Handler (void) {
166166
xPortSysTickHandler();
167167
}
168168
}
169-
#endif /* !ARDUINO_ARCH_STM32 && (USE_CUSTOM_SYSTICK_HANDLER_IMPLEMENTATION == 0)*/
169+
#endif /* USE_CUSTOM_SYSTICK_HANDLER_IMPLEMENTATION == 0*/
170170
#endif /* SysTick */
171171

172172
/*

portable/GCC/ARM_CM33_NTZ/non_secure/port.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,9 @@ void vPortExitCritical( void ) PRIVILEGED_FUNCTION;
333333
/**
334334
* @brief SysTick handler.
335335
*/
336-
void SysTick_Handler( void ) PRIVILEGED_FUNCTION;
336+
/* Fix for STM32 core */
337+
/* void SysTick_Handler( void ) PRIVILEGED_FUNCTION; */
338+
void xPortSysTickHandler( void ) PRIVILEGED_FUNCTION;
337339

338340
/**
339341
* @brief C part of SVC handler.
@@ -733,7 +735,9 @@ void vPortExitCritical( void ) /* PRIVILEGED_FUNCTION */
733735
}
734736
/*-----------------------------------------------------------*/
735737

736-
void SysTick_Handler( void ) /* PRIVILEGED_FUNCTION */
738+
/* Fix for STM32 core */
739+
/* void SysTick_Handler( void ) */ /* PRIVILEGED_FUNCTION */
740+
void xPortSysTickHandler( void ) /* PRIVILEGED_FUNCTION */
737741
{
738742
uint32_t ulPreviousMask;
739743

src/FreeRTOSConfig_Default.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -215,15 +215,11 @@ header file. */
215215

216216
/*
217217
* IMPORTANT:
218-
* osSystickHandler is called in the core SysTick_Handler definition and is defined as weak.
219-
* For CMSIS-RTOSv2: osSystickHandler is defined as xPortSysTickHandler
220-
* For CMSIS-RTOS: osSystickHandler is defined by the cmsis_os and xPortSysTickHandler
221-
* must not be defined to prevent overwriting SysTick_Handler
218+
* SysTick_Handler() from stm32duino core is calling weak osSystickHandler().
219+
* Both CMSIS-RTOSv2 and CMSIS-RTOS override osSystickHandler()
220+
* which is calling xPortSysTickHandler(), defined in respective CortexM-x port
222221
*/
223222
/* #define xPortSysTickHandler SysTick_Handler */
224-
#if defined(configUSE_CMSIS_RTOS_V2) && (configUSE_CMSIS_RTOS_V2 == 1)
225-
#define xPortSysTickHandler osSystickHandler
226-
#endif
227223

228224
#endif /* FREERTOS_CONFIG_DEFAULT_H */
229225

0 commit comments

Comments
 (0)