cancel
Showing results for 
Search instead for 
Did you mean: 

stm32F746G Discovery + TouchGFX + FreeRTOS and SDMMC (SD card)

GreenTooth
Associate

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:

  • 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.

I’d really appreciate any guidance or suggestions on what might be causing this or how to approach debugging it.

Thanks in advance!

3 REPLIES 3
Saket_Om
ST Employee

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:

  1. FatFS + SDMMC + FreeRTOS
  2. FatFS + SDMMC + FreeRTOS + I2C
  3. FatFS + SDMMC + FreeRTOS + I2C + TouchGFX

At each step, please verify whether SD card logging still works correctly.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om
GreenTooth
Associate

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.

Hello @GreenTooth 

Please refer to the FatFs_uSD_RTOS example, which demonstrates how to use the FatFs middleware component with FreeRTOS.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om