2025-12-14 5:38 PM - last edited on 2025-12-15 2:37 AM by Andrew Neil
I’m working on an STM32H7R7 project using SDMMC1 + FreeRTOS (CMSIS-RTOS v2) + FatFs, all generated with STM32CubeMX.
I’m facing an issue where f_mount(opt=0) works, but the system blocks inside f_open() and never returns, so the return value cannot be checked.
A key aspect of the problem is that the behavior depends on how the device is started:
After flashing the firmware with a debugger connected and running immediately, the system behaves differently.
After a cold power-up (power removed and re-applied, no debugger connected), the same binary consistently freezes when reaching f_open().
In both cases:
The code is identical
The clock configuration and FreeRTOS setup are unchanged
No additional initialization is performed when the debugger is attached
This suggests a timing-, initialization-, or peripheral-state-related issue that manifests only on a true power-on reset and not after a debugger-initiated reset.
Additional observations:
f_mount(&SDFatFs, "0:", 1) initially caused a block, but changing to f_mount(..., opt = 0) resolved the mount stage.
The freeze now occurs only when f_open() is called.
GPIO instrumentation shows that the SDMMC1 interrupt fires during f_open(), but the system never exits the function.
Because the failure happens only after a cold start and not after flashing/debug reset, it appears that some SDMMC, DMA, cache, or RTOS interaction behaves differently between power-on reset and debug reset, even though the application code is the same.
Does anybody have any solution?
Note: I used the newest cubemx (6.16.1)
2025-12-15 12:04 AM
Setting f_mount(..., opt = 0) is NO solution, because it does not mount here/now !
Set f_mount(&SDFatFs, "0:", 1) , = mount NOW ; this has to work, otherwise it shows : no working access to sd-card.
So first check/modify your hardware and settings , because most problems arise from there.
Try:
- set all pins for sdmmc to medium speed , pullup on.
- set using no DMA
- custom board? check all lines cpu->card short and about equal lenght
- set 1 bit mode (at least at first, because more forgiving ...)
- set clock for sdmmc (and internal divider) to something < 50MHz , maybe try 10M until its working.