cancel
Showing results for 
Search instead for 
Did you mean: 

STMCubeMX replace the app_freertos.c. How to avoid

nico23
Senior II

I'm developing an app on the demo board STM32U5A9J-DK

I've created the project from TouchGFX 4.25.0 project STM32U5A9J-DK FreeRTOS

It perfectly works, compile and debug with both TouchGFX and CubeIDE 1.18.1

I then opened the .ioc file of the project with Open CubeMX 6.14.1. It says the project was set up with 6.14.0 and FW_U5 V1.7.0, so I migrated it.

I've updated the Software Packs from X-CUBE-FREERTOS 1.0.0 to 1.3.1. CubeMX says no issue found and upgraded.

Then I generated the code. There, the new code rewrote the app_freertos.c file deleting the initialization of the TouchGFX task

/* Definitions for defaultTask */
osThreadId_t defaultTaskHandle;
const osThreadAttr_t defaultTask_attributes = {
  .name = "defaultTask",
  .priority = (osPriority_t) osPriorityNormal,
  .stack_size = 128 * 4
};
/* Definitions for GUI_Task */
osThreadId_t GUI_TaskHandle;
const osThreadAttr_t GUI_Task_attributes = {
  .name = "GUI_Task",
  .priority = (osPriority_t) osPriorityNormal,
  .stack_size = 8192 * 4
};

and the implementations of MX_FREERTOS_Init where it starts the tasks

/* creation of defaultTask */
  defaultTaskHandle = osThreadNew(StartDefaultTask, NULL, &defaultTask_attributes);

  /* creation of GUI_Task */
  GUI_TaskHandle = osThreadNew(TouchGFX_Task, NULL, &GUI_Task_attributes);

Is there a way to avoid it?

2 REPLIES 2
ahsrabrifat
Senior

Instead of adding the GUI_Task directly in app_freertos.c, you should create and launch the TouchGFX_Task within a user-defined function inside App_TouchGFX.c or a new source file.

Then, in MX_FREERTOS_Init(), call that function via the /* USER CODE BEGIN RTOS_THREADS */ section, which CubeMX preserves.

nico23
Senior II

Hi @ahsrabrifat 

the app_freertos.c comes directly from the ST project available on TouchGFX, and it has not been modified by me.

Thanks for the suggestion, tho, I'll try it. I think ST should document it and publish guidelines to avoid such an issue