2024-08-19 09:44 AM
Hello,
I am currently experiencing issues with compiling a Makefile project for the STM32F103C8T6, generated by STM32CubeMX. The project has the FreeRTOS middleware enabled, with CMSIS V2.
Compilation of the generated code results in these errors:
I believe the first error has something to do with a missing symbol/definition for CMSIS_device_header, but I am unsure as to which header file should be there instead. The other error seems to be a configuration error, but I, once again, have no idea what to do to fix it.
It's also worth noting that I was able to generate a project with the same settings and compile it previously. I don't recall tampering with anything that could have caused this breakage.
2024-08-20 02:57 AM
Hello @j0of, welcome to ST Community,
Please re-attach the compilations errors, the link doesn't work! Or simply copy paste/paste, post a screenshot..
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-08-20 03:14 AM
Hey, thanks for letting me know. I have copy-pasted the error messages below.
In file included from Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c:34:
Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/freertos_os2.h:31:10: error: #include expects "FILENAME" or <FILENAME>
31 | #include CMSIS_device_header
| ^~~~~~~~~~~~~~~~~~~
Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/freertos_os2.h:141:2: error: #error "Definition INCLUDE_xTaskGetCurrentTaskHandle must equal 1 to implement Thread Management API."
141 | #error \
| ^~~~~
Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c: In function 'SVC_Setup':
Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c:179:3: error: implicit declaration of function 'NVIC_SetPriority' [-Wimplicit-function-declaration]
179 | NVIC_SetPriority (SVCall_IRQ_NBR, 0U);
| ^~~~~~~~~~~~~~~~
Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c:80:36: error: 'IRQn_Type' undeclared (first use in this function)
80 | #define SVCall_IRQ_NBR (IRQn_Type) -5 /* SVCall_IRQ_NBR added as SV_Call handler name is not the same for CM0 and for all other CMx */
| ^~~~~~~~~
Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c:179:21: note: in expansion of macro 'SVCall_IRQ_NBR'
179 | NVIC_SetPriority (SVCall_IRQ_NBR, 0U);
| ^~~~~~~~~~~~~~
Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c:80:36: note: each undeclared identifier is reported only once for each function it appears in
80 | #define SVCall_IRQ_NBR (IRQn_Type) -5 /* SVCall_IRQ_NBR added as SV_Call handler name is not the same for CM0 and for all other CMx */
| ^~~~~~~~~
Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c:179:21: note: in expansion of macro 'SVCall_IRQ_NBR'
179 | NVIC_SetPriority (SVCall_IRQ_NBR, 0U);
| ^~~~~~~~~~~~~~
Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c: In function 'OS_Tick_GetCount':
Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c:401:19: error: 'SysTick' undeclared (first use in this function)
401 | uint32_t load = SysTick->LOAD;
| ^~~~~~~
Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c: In function 'OS_Tick_GetOverflow':
Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c:407:12: error: 'SysTick' undeclared (first use in this function)
407 | return ((SysTick->CTRL >> 16) & 1U);
| ^~~~~~~
Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c: In function 'OS_Tick_GetInterval':
Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c:412:11: error: 'SysTick' undeclared (first use in this function)
412 | return (SysTick->LOAD + 1U);
| ^~~~~~~
Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c: In function 'OS_Tick_GetOverflow':
Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c:408:1: warning: control reaches end of non-void function [-Wreturn-type]
408 | }
| ^
Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c: In function 'OS_Tick_GetCount':
Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c:403:1: warning: control reaches end of non-void function [-Wreturn-type]
403 | }
| ^
Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c: In function 'OS_Tick_GetInterval':
Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c:413:1: warning: control reaches end of non-void function [-Wreturn-type]
413 | }
| ^
make: *** [Makefile:183: build/cmsis_os2.o] Error 1
2024-08-20 03:49 AM - edited 2024-08-20 03:52 AM
In file included from Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c:34:
Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/freertos_os2.h:31:10: error: #include expects "FILENAME" or <FILENAME>
31 | #include CMSIS_device_header
| ^~~~~~~~~~~~~~~~~~~
As the message says, the #include directive needs to have the filename in either "double-quotes" or <angle-brackets>; ie,
#include "CMSIS_device_header"
or
#include <CMSIS_device_header>
EDIT:
Presumably, CMSIS_device_header is (or should be) #defined somewhere - so that #define should include the quotes.
Maybe it is (or should be) a command-line define?
2024-08-20 05:37 AM
Hello Andrew, thank you for your response.
I also believe `CMSIS_device_header` was supposed to be defined somewhere else, but it may have not been defined/generated due to some sort of bug within CubeMX.
Upon further inspection, I concluded that the correct header is located within `Drivers/CMSIS/Devices/STM32F1xx/Include`, so I temporarily replaced the line `#include CMSIS_device_header` with `#include "stm32f103x6.h"` from this directory. This seems to have fixed a large majority of the errors, but compilation still resulted in the following:
In file included from Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c:34:
Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/freertos_os2.h:141:2: error: #error "Definition INCLUDE_xTaskGetCurrentTaskHandle must equal 1 to implement Thread Management API."
141 | #error \
| ^~~~~
make: *** [Makefile:183: build/cmsis_os2.o] Error 1
I tried to fix it by changing the definition of `INCLUDE_xTaskGetCurrentTaskHandle` located in file `Middleware/Third_Party/FreeRTOS/Source/include/FreeRTOS.h` from 0 to 1. It then resulted in this compilation error once again:
/home/joof/projects/testete/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3/port.c:427: multiple definition of `SysTick_Handler'; build/cmsis_os2.o:/home/joof/projects/testete/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c:159: first defined here
/usr/lib/gcc/arm-none-eabi/14.1.0/../../../../arm-none-eabi/bin/ld: warning: build/testete.elf has a LOAD segment with RWX permissions
collect2: error: ld returned 1 exit status
make: *** [Makefile:191: build/testete.elf] Error 1
Any other ideas? Was there a step I missed when generating the project, or is this just ST's problem?
2024-08-31 04:37 AM
Did you select the proper configuration parameters? Please check the freeRTOSConfig.h. this is w.r to your previous error
2024-08-31 12:40 PM
#include CMSIS_device_header is valid syntax, it means that CMSIS_device_header is defined as "string" or <string>. In Keil toolchain this macro is defined as name of the MCU-specific .h file. For STM32 these .h files are in STM32Cube_FW_XXXX/Drivers/CMSIS/Device/ST/STM32XXxx\Include\stm32*.h