2025-02-13 10:41 PM
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.
Solved! Go to Solution.
2025-02-18 02:48 AM
Hello @ego ,
Further to your comment, I suggest that you change SD Instance to SDMMC2 under FileX.
Thanks.
Mahmoud
2025-02-14 02:09 AM
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
2025-02-14 02:22 AM - edited 2025-02-14 02:23 AM
2025-02-18 02:48 AM
Hello @ego ,
Further to your comment, I suggest that you change SD Instance to SDMMC2 under FileX.
Thanks.
Mahmoud
2025-02-18 10:33 PM
Hello Mahmoud,
It worked, thank you.
Egoitz.
2025-02-18 11:46 PM - edited 2025-02-18 11:47 PM
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:
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.
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:
Ensure that all required header files are added in CubeMX under Project Manager > Advanced Settings so they are included in future code generations.
To avoid warnings about unused parameters, you can use the UNUSED macro, just like in other STM32 HAL functions:
This is a clean and recommended approach to prevent warnings while keeping the code compliant with STM32 HAL coding practices.
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,