cancel
Showing results for 
Search instead for 
Did you mean: 

Code generation problem for FileX

ego
Associate II

Hello,

I am using STM32H730ZBT6 with STM32 CubeMX V6.12.1 (I am not using the newest version because of the problem related in topic Downgrade STM32CubeProgrammer in STM32CubeIDE. I dont' know exactly if CubeMX would reproduce the problem, but for the case...) and I have detected 2 problems in code generation:

1. Eventhough I am using peripheral SDMMC2 the code generated in file "fx_stm32_sd_driver_glue.c" is prepared for SDMMC1. Here a code portion as example:

 

extern SD_HandleTypeDef hsd1;
#if (FX_STM32_SD_INIT == 1)
extern void MX_SDMMC1_SD_Init(void);
#endif

 

2. If the option "Generate peripheral initialization as a pair of '.c/.h' files per peripheral", some erros ocur because "fx_stm32_sd_driver_glue.c" file doen't know where to find functions and instances, and is necesary to include "sdmmc.h" file.

 

A part of those twoo problems, in functions "void HAL_SD_TxCpltCallback(SD_HandleTypeDef *hsd)" and "void HAL_SD_RxCpltCallback(SD_HandleTypeDef *hsd)" hsd is not used, so the compiler gives warnings. In other cases, "UNUSED(...)" is used to avoid these warnings, could it be applied to those two functions too?

 

Thank you and best regards.

Egoitz.

1 ACCEPTED SOLUTION

Accepted Solutions

Hello @ego ,

Further to your comment, I suggest that you change SD Instance to SDMMC2 under FileX.

MahmoudBenRomdhane_0-1739875330350.png

MahmoudBenRomdhane_1-1739875613809.png

Thanks.

Mahmoud

 

View solution in original post

5 REPLIES 5
Mahmoud Ben Romdhane
ST Employee

Hello @ego ,

 

First let me thank you for posting and welcome to the ST Community.

For more investigation, I suggest please that you provide your Ioc.File.

 

Thanks.

Mahmoud

ego
Associate II

Sure, there you have it.

Hello @ego ,

Further to your comment, I suggest that you change SD Instance to SDMMC2 under FileX.

MahmoudBenRomdhane_0-1739875330350.png

MahmoudBenRomdhane_1-1739875613809.png

Thanks.

Mahmoud

 

ego
Associate II

Hello Mahmoud,

It worked, thank you.

Egoitz.

Lily
Visitor

 

. SDMMC2 vs. SDMMC1 Issue in fx_stm32_sd_driver_glue.c

The CubeMX-generated code seems to default to SDMMC1 instead of SDMMC2. You can try the following:

  • Manually update the generated code to ensure it references hsd2 instead of hsd1. Example:

    c
    CopyEdit
    extern SD_HandleTypeDef hsd2; #if (FX_STM32_SD_INIT == 1) extern void MX_SDMMC2_SD_Init(void); #endif
  • If CubeMX keeps regenerating incorrect code, you may need to edit the fx_stm32_sd_driver_glue.c manually after each generation or check the CubeMX configuration to ensure SDMMC2 is properly selected.

2. Missing Header Files with "Generate peripheral initialization as a pair of .c/.h files per peripheral"

This issue often occurs because the auto-generated files do not include all necessary headers. To fix this:

  • Manually include the missing headers in fx_stm32_sd_driver_glue.c:

    c
    CopyEdit
    #include "sdmmc.h"
  • Ensure that all required header files are added in CubeMX under Project Manager > Advanced Settings so they are included in future code generations.

3. Compiler Warnings in HAL_SD_TxCpltCallback and HAL_SD_RxCpltCallback

To avoid warnings about unused parameters, you can use the UNUSED macro, just like in other STM32 HAL functions:

 

c
CopyEdit
void HAL_SD_TxCpltCallback(SD_HandleTypeDef *hsd) { UNUSED(hsd); } void HAL_SD_RxCpltCallback(SD_HandleTypeDef *hsd) { UNUSED(hsd); }
 

This is a clean and recommended approach to prevent warnings while keeping the code compliant with STM32 HAL coding practices.

Additional Resource for UI & Code Structure

For a practical example of well-structured UI/UX design, you can check out chipotlmenu.com  , which follows a clean and organized layout—something that can also be applied when designing embedded system interfaces for STM32-based applications.

Let me know if you need further clarification.

Best regards,