2026-05-08 6:39 PM - last edited on 2026-05-09 1:23 PM by mƎALLEm
IN short, it's not working.
I normally use the standard (not x-cube) and L5 processors. I'm going to the U5 processors for a larger project. I've gone to Cube MX 6.17.0 and CubeMXIDE 2.1.1.
Starting with a blank project, I configure the pins as usual and enable xcube-FreeRTOS. Go to CubeIDE, and without FreeRTOS, everything compiles properly. With FreeRTOS, I get 237 errors, some understandable, and some of the following:
./Middlewares/Third_Party/FreeRTOS/Source/include/task.h:34:6: error: #error "include FreeRTOS.h must appear in source files before include task.h"
34 | #error "include FreeRTOS.h must appear in source files before include task.h"
| ^~~~~
In file included from ../Middlewares/Third_Party/FreeRTOS/Source/include/task.h:37:
../Middlewares/Third_Party/FreeRTOS/Source/include/list.h:62:6: error: #error "FreeRTOS.h must be included before list.h"
62 | #error "FreeRTOS.h must be included before list.h"
| ^~~~~
../Middlewares/Third_Party/FreeRTOS/Source/include/list.h:147:25: error: unknown type name 'TickType_t'; did you mean 'osTimerType_t'?
147 | configLIST_VOLATILE TickType_t xItemValue; /**< The value being listed. In most cases this is used to sort the list in ascending order. */
| ^~~~~~~~~~
| osTimerType_t
../Middlewares/Third_Party/FreeRTOS/Source/include/list.h:175:25: error: unknown type name 'UBaseType_t'
175 | configLIST_VOLATILE UBaseType_t uxNumberOfItems;
Which indicates to me that something fundamental is wrong somewhere.
Any ideas?
Harvey
Solved! Go to Solution.
2026-05-25 8:17 AM
attached Duplicate task has already been removed.
Note that the problem is in the repository file, not the IOC file.
To duplicate, I'd suggest a very simple FreeRTOS project for the U575 and see what you get, possibly with the dual default tasks, possibly not.
I am less concerned with the duplicate main tasks, more concerned that they are not checked for. Once that extra main task is deleted, it stays that way.
I am more concerned with the lack of the #include "freertos.h" in the cmsis_os.h file. That requires changing the repository file to fix.
2026-05-10 10:17 AM
Well, I have A solution.
To reproduce the error: generate code under cubemx, go to cubeIDE and build. Get 237 errors most of which are the result of FreeRTOS not finding stuff. For example, task.h fails because FreeRTOS.h is not defined yet.
rebuilding and cleaning the project does not help.
The first error is the clue. Going through IDE 1.19 and comparing to 2.1.1 I get the following.
Both projects use CMSIS-V2, so I'd expect a somewhat similar structure. Obviously, someone has been improving a few things. (hence the problem).
under middlewares/third party there's only a single directory /freertos/source/CMSIS_RTOS_V2 under
1.19.
under 2.1.1, under third party, there are two directories one is CMSIS, the other is FreeRTOS.
the main program includes cmsis_os2.h. cmsis_os2.c includes FreeRTOS.h and task.h in the proper order. Apparently, though, this is not good enough.
To fix the problem, add a line of code to #include "FreeRTOS.h" in cmsis_os.h. It can be either before or after the include for cmsis_os2.h.
For some reason, I get
* Definitions for defaultTask */
osThreadId_t defaultTaskHandle;
const osThreadAttr_t defaultTask_attributes = {
.name = "defaultTask",
.priority = (osPriority_t) osPriorityNormal,
.stack_size = 128 * 4
};
defaultTaskHandle = osThreadNew(StartDefaultTask, NULL, &defaultTask_attributes);
void StartDefaultTask(void *argument)
{
/* USER CODE BEGIN defaultTask */
/* Infinite loop */
for(;;)
{
osDelay(1);
}
/* USER CODE END defaultTask */
}duplicated in app_freertos.c.
Still puzzled.
but it compiles properly
2026-05-24 10:19 AM
As an addendum to the duplicate code.
Look for the tasks and queues section of XCUBE-Freertos
if there are two default tasks, delete one.
Apparently the setup firmware doesn't check for this, however the extra task was generated.
For the add freertos.h addition
note the version of cmsis_os.h,
under username/.stm32cubemx/stm32cube/repository/packs/stMicroelectronics/X-CUBE_FREERTOS/
there are version numbers, I use 1.5.0
pick that, then under middlewares/third_party/freertos/source/cmsis_rtos_v2
I find cmsis_os.h That's where the source file lives. Add the line #include "freertos.h" before or after the cmsis_os2.h entry.
verify that you find the right one by generating code in CubeMX, and then making sure that the line shows up in the code where needed.
If you change or update the version of FreeRTOS, or the processor firmware, you'll need to do this again.
2026-05-25 1:18 AM
Hello @Harvey White
Let me thank you for posting.
For more investigation, I recommend that you provide your Ioc.File.
Thanks.
Mahmoud
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.
2026-05-25 8:17 AM
attached Duplicate task has already been removed.
Note that the problem is in the repository file, not the IOC file.
To duplicate, I'd suggest a very simple FreeRTOS project for the U575 and see what you get, possibly with the dual default tasks, possibly not.
I am less concerned with the duplicate main tasks, more concerned that they are not checked for. Once that extra main task is deleted, it stays that way.
I am more concerned with the lack of the #include "freertos.h" in the cmsis_os.h file. That requires changing the repository file to fix.
2026-05-25 8:43 AM
Hello @Harvey White
Further to your comment.
I did not get build errors.
Thanks.
Mahmoud
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.
2026-05-25 9:43 AM
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.