2024-11-20 12:18 PM - edited 2024-11-21 06:21 AM
Hello Everyone,
I am a beginner with STM32 (student).
In TouchGFX 4.24.1 Designer, I created a simple project (two buttons and a bitmap).
Then, I launch this project in STM32CubeIDE and initialize SDMMC1 and FatFS according to the AN5200 - Getting started with STM32H7 MCUs SDMMC guide. Unfortunately, I get errors, probably related to memory.
When I create a project without FreeRTOS and TouchGFX, only basic handling of SDMMC1 and FatFS, everything works fine.
Perhaps someone is able to help me with the correct configuration of TouchGFX + FreeRTOS + SDMMC1 on STM32H747I-DISCO or could share a working application?
Thank you in advance for all the suggestions.
I have added the project as an attachment.
Solved! Go to Solution.
2024-11-22 08:11 AM - edited 2024-11-25 06:38 AM
Hello @ArturG2020 and welcome to the community! :smiling_face_with_smiling_eyes:
From your project, I assume you started by creating a project in TouchGFX Designer, then designed your GUI, then generated code in TouchGFX Designer, then went back to STM32CubeMX to enable the SDMMC1, generated code there and from there it did not work for you.
However, you have selected "Generated peripheral as a pair of c/h" which seemed to create the issue.
Because in our TBS (TouchGFX Board Setup), we manually add user code, that user code was lost when selecting that option.
To fix that, you simply have to copy the user code in the c and h files that are impacted.
There is 4 files, you will find the modified version attached.
Also, find the full project attached.
Make sure to have a, SD card inserted when running your program.
Finally, I assume you want to store assets in the SD card. For this, I invite you to check these 3 resources :
I hope this helps! :smiling_face_with_smiling_eyes:
If this comment answers your question, I invite you to select it as "best answer".
Regards,
2024-11-20 12:27 PM
Hello @ArturG2020 ,
Kindly attach your project here instead of using Google drive or other means.
Use drag and drop:
Thank you for your understanding
2024-11-22 08:11 AM - edited 2024-11-25 06:38 AM
Hello @ArturG2020 and welcome to the community! :smiling_face_with_smiling_eyes:
From your project, I assume you started by creating a project in TouchGFX Designer, then designed your GUI, then generated code in TouchGFX Designer, then went back to STM32CubeMX to enable the SDMMC1, generated code there and from there it did not work for you.
However, you have selected "Generated peripheral as a pair of c/h" which seemed to create the issue.
Because in our TBS (TouchGFX Board Setup), we manually add user code, that user code was lost when selecting that option.
To fix that, you simply have to copy the user code in the c and h files that are impacted.
There is 4 files, you will find the modified version attached.
Also, find the full project attached.
Make sure to have a, SD card inserted when running your program.
Finally, I assume you want to store assets in the SD card. For this, I invite you to check these 3 resources :
I hope this helps! :smiling_face_with_smiling_eyes:
If this comment answers your question, I invite you to select it as "best answer".
Regards,
2024-11-25 10:51 AM
Thank you for your help, GaetanGodart!
Your fix and tutorials allowed me to take a step forward with this project. :)
Below, I’ve included additional information and a simple test code for STM32H747I-DISCO users:
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN Variables */
FATFS fs;
FIL file;
FRESULT res;
/* USER CODE END Variables */
void StartSDTask(void *argument)
{
/* USER CODE BEGIN StartSDTask */
char wtext[] = "Test f_write uSD Card";
UINT byteswritten;
res = f_mount(&fs, "", 1);
if (res != FR_OK) {
printf("f_mount failed: %d\n", res);
}
res = f_open(&file, "testABCD.txt", FA_OPEN_ALWAYS | FA_WRITE);
if (res != FR_OK) {
printf("f_open failed: %d\n", res);
} else {
f_write(&file, wtext, sizeof(wtext), &byteswritten);
}
f_close(&file);
f_mount(NULL, "", 1);
/* Infinite loop */
for(;;)
{
osDelay(1);
}
/* USER CODE END StartSDTask */
}
The FR_NO_FILESYSTEM error was related to the MPU configuration for address 0x24000000.
Below is the configuration that works for me:
MPU_InitStruct.Number = MPU_REGION_NUMBER3;
MPU_InitStruct.BaseAddress = 0x24000000;
MPU_InitStruct.Size = MPU_REGION_SIZE_512KB;
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE;
MPU_InitStruct.IsBufferable = MPU_ACCESS_BUFFERABLE;
2024-11-26 09:22 AM
Hello @ArturG2020 ,
I am glad you have been able to move forward. :smiling_face_with_smiling_eyes:
Thank you for sharing your solution in the forum, that will help other people facing the same issue.
Don't hesitate if you have other TouchGFX related questions!
Regards,