Skip to main content
Associate
August 19, 2024
Question

Unable to compile FreeRTOS project

  • August 19, 2024
  • 2 replies
  • 3745 views

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:

https://pastebin.com/WJEXLh09

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.

2 replies

ST Employee
August 20, 2024

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..

j0ofAuthor
Associate
August 20, 2024

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
Andrew Neil
Super User
August 20, 2024

 

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?

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Pavel A.
Super User
August 31, 2024

#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