Skip to main content
ABENA.1
Associate
May 20, 2022
Solved

Inconsistant code generation in STM32CubeMX when using FATFS and FreeRTOS middlewares

  • May 20, 2022
  • 3 replies
  • 1264 views

The prototype of the generated function by STM32CubeMx when using FATFS is:

int32_t MX_FATFS_Process(void)

This cannot be used with FreeRTOS as a task entry function since it has the wrong return and argument type.

The function prototype should be :

void MX_FATFS_Process(void *argument)

So that it could be accepted while creating FATFS task:

 FatFsTaskHandle = osThreadNew(MX_FATFS_Process, NULL, &FatFsTask_attributes);

In the example project provided in STM32Cube MCU Package for STM32L5 series, the function prototype is correct. The code generated by STM32CubeMX does not match this example.

This topic has been closed for replies.
Best answer by Sara BEN HADJ YAHYA

Hello @ABENA.1​ ,

Unfortunately we cannot accept this request, it is not possible to change the prototype of MX_FATFS_Process to void.

Since the beginning, the functions prototype was declared as int32_t and it was not targeted to be used by FreeRTOS threads. The prototype was changed to void in the FW examples for FreeRTOS use.

The recommended way to define FreeRTOS tasks is by adding them to FreeRTOS configuration using CubeMX (for example void StartTaskxx(void *argument) ).

The FatFS task can be created while configuring FreeRTOS. It can be named StartTaskFatFS and you can copy or use the code of MX_FATFS_Process given in the example in the generated void StartTaskFatFS(void *argument).

I hope this helps :smiling_face_with_smiling_eyes:

If your issue is solved, please close this post by clicking the "Select as Best" button. This will help other members of the community find this response more quickly :)

Sara.

3 replies

Sara BEN HADJ YAHYA
ST Technical Moderator
May 23, 2022

Hello @ABENA.1​ ,

Thanks for having reported,

I submitted your request internally for further check, I will keep you posted.

Internal ticket number: 128982(This is an internal tracking number and is not accessible or usable by customers).

Sara.

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question.
Sara BEN HADJ YAHYA
ST Technical Moderator
May 25, 2022

Hello @ABENA.1​ ,

Unfortunately we cannot accept this request, it is not possible to change the prototype of MX_FATFS_Process to void.

Since the beginning, the functions prototype was declared as int32_t and it was not targeted to be used by FreeRTOS threads. The prototype was changed to void in the FW examples for FreeRTOS use.

The recommended way to define FreeRTOS tasks is by adding them to FreeRTOS configuration using CubeMX (for example void StartTaskxx(void *argument) ).

The FatFS task can be created while configuring FreeRTOS. It can be named StartTaskFatFS and you can copy or use the code of MX_FATFS_Process given in the example in the generated void StartTaskFatFS(void *argument).

I hope this helps :smiling_face_with_smiling_eyes:

If your issue is solved, please close this post by clicking the "Select as Best" button. This will help other members of the community find this response more quickly :)

Sara.

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question.
ABENA.1
ABENA.1Author
Associate
May 30, 2022

Thanks @Sara BEN HADJ YAHYA​