AnsweredAssumed Answered

STM32CubeMX + FatFS - Keil works, TrueStudio not

Question asked by lange.kevin on Jun 30, 2016
Latest reply on Jul 1, 2016 by lange.kevin
Hello my friends,

I am new to FatFs and I want to write something on the SD-Card.
I initialize SDIO and FatFs over STM32CubeMX.
I am using the STM32F4 Discovery and the Baseboard which has a SD-Connector.
If I create the project for Keil I can write to the SD-Card.
But if I create the project for Truestudio or SW4STM32 I can not write to SD-Card.
/* USER CODE BEGIN 2 */
MX_FATFS_Init();
if (f_mount(&SDFatFs, (TCHAR const*) SD_Path, 0) != FR_OK) {
    /* FatFs Initialization Error */
    Error_Handler();
}
 
if (f_open(&MyFile, "STM32.TXT", FA_CREATE_ALWAYS | FA_WRITE) != FR_OK) {
    Error_Handler();
}
 
res = f_write(&MyFile, wtext, sizeof(wtext), (void *) &byteswritten);
 
if ((byteswritten == 0) || (res != FR_OK)) {
    Error_Handler();
}
 
f_close(&MyFile);
/* USER CODE END 2 */

I put exact the same Code in to all three projects but only Keil works.
It is not a compilation error. Mount works too but always get stucked in f_open.
I have noticed that HAL_SD_ReadBlocks returns an Error. I have created multiple project with FreeRTOS and without. Always works in Keil but not with Truestudio and SW4STM32.

Does somebody know what I am doing wrong?

Best Regards,
Kevin

Outcomes