2016-06-30 04:02 AM
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, ''STMTXT'', 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 thatHAL_SD_ReadBlocks returns an Error. I have created multiple project with FreeRTOS and without. Always works in Keil but not with Truestudio and SW4STM
Does somebody know what I am doing wrong?
Best Regards,
Kevin
#!stm32-!fatfs-!keil-!truestudio
2016-06-30 04:38 AM
Hi,
Could you please precise which version of HAL, STM32CubeMx and toolchain are you using?Regards2016-06-30 04:47 AM
Hello,
sorry that I have not noticed it.I am using STM32CubeMX v4.15.1 and Firmware Package 1.12.0TrueStudio 5.5.2 SW4STM32 v1.8 from May 4, 2016.Keil 5.17Best RegardsKevin2016-06-30 05:39 AM
How about SDIO and DMA interrupt handlers?
Not compiler error/failure? You sure? Does behaviour change with optimization off vs on? Check also statics are being cleared.2016-06-30 06:22 AM
Hi lange.kevin,
It's better to compare your generated code with one of the provided FatFS applications working with SD-Card, as this example:STM32Cube_FW_F4_V1.12.0\Projects\STM32F412G-Discovery\Applications\FatFs\FatFs_uSD
Regards2016-07-01 04:28 AM
Thank you guys. You got me in the right direction.
I have made mistakes with DMA.Sometimes you need to talk to somebody to solve the obvious mistakes.