2026-04-27 7:47 AM
Hi everyone,
I’m relatively new to embedded systems, so apologies if this has already been discussed elsewhere. I’ve tried searching, but haven’t been able to find a clear solution.
I’m currently developing a system based on the STM32F746G Discovery board using TouchGFX for the touchscreen UI. In addition, I’m interfacing with a distance sensor over I2C. My goal is to log data (timestamp + sensor value, already formatted) to an SD card.
The issue I’m facing is the following:
I’d really appreciate any guidance or suggestions on what might be causing this or how to approach debugging it.
Thanks in advance!
2026-04-28 2:34 AM
Hello @GreenTooth
@GreenTooth wrote:
The issue I’m facing is the following:
- When I enable only SDMMC and FatFS in CubeMX, I can successfully open a file and write data to it.
- However, when I integrate this functionality into my full project (which includes TouchGFX, FreeRTOS, and I2C), the SD card logging no longer works.
Could you please clarify at which exact step the SD card logging stops working in the full application?
What "issues", exactly, do you encounter?
What tests/investigations/debugging have you done to find out what's going on?
You could try to integrate the project features step by step, in order to identify exactly which middleware or peripheral combination introduces the issue.
For example, we suggest testing in this order:
At each step, please verify whether SD card logging still works correctly.
2026-04-28 7:46 AM - edited 2026-04-28 1:13 PM
Hi,
Thank you for the quick reply. I followed your suggestion, but the SD card functionality fails as soon as I introduce FreeRTOS.
I’m using a serial port to monitor debug printouts from the code. Based on those logs, the system appears to successfully mount the card, but it fails when calling f_open(). The FatFS return code is 3 (FR_NOT_READY). To be more specific it fails during the SD initialization.
As mentioned earlier, without FreeRTOS the entire sequence (mount → open → write) works correctly.
In the meantime, I did some more debugging and it seems the error is within SD_initialization (sd_diskio.c). To be more precise, I am getting HAL_SD_Init fail within BSP_SD_Init (bsp_driver_sd.c); Hal sd state = 1, which stands for HAL_ERROR. However, I'm not sure how to go about it. Any suggestion is highly appreciated.
2026-04-30 8:02 AM
Hello @GreenTooth
Please refer to the FatFs_uSD_RTOS example, which demonstrates how to use the FatFs middleware component with FreeRTOS.