2017-11-02 10:40 AM
Hey Guys,
I am setting up some STM32F407VETx on a chinese breakout board with �SD-card-slot.
I try to read data from the sd card with SDIO (SD 4 bits Wide bus) and FatFs.
The Basic-Project is build with STM32 CubeMx and programmed in the OpenSTM32 Workbench.
My Problem:
The SD Card is ALWAYS in 'FR_NOT_READY'. I am not able to mount / open / write any data, because the �C is always stuck in the following function:
/**
* @brief Checks for error conditions for R1 response. * @param hsd SD handle * @param SD_CMD The sent command index * @retval SD Card error state */static uint32_t SDMMC_GetCmdResp1(SDIO_TypeDef *SDIOx, uint8_t SD_CMD, uint32_t Timeout){...
}
Because of the timeout in this function i get an errorcode '1' (R/W Error ) in diskio.c
I've tried 3 boards, 3 SD-cards - nothing is broken! I have no clue, what to do...
I am just using the 'basic' fatfs functions, as you can the in the attachment.
Please help me!
:(
Greets!
Ps.: If you need more information, please write some comment!
#sdio #error #sd #stm32f407 #sd-card #fatfs2017-11-02 11:46 AM
Can you link to a vendor page, or insert a picture of the board?
Any schematic available/provided?
Is there a card detect on the socket?
2017-11-02 02:15 PM
Ok, i got the following news:
When i build my project with an older version of CubeMx (4.22.1) then it uses an older version of FatFs (R0.11). With this setting everything works fine!
But when i use the latest version of CubeMx (4.23.0) there is a newer version of FatFs (R0.12c) with it.
I think the problem comes with the
FatFs (R0.12c), ...
I have to use the newest version of CubeMx, so i have to fix this...
:(
2017-11-03 04:11 AM
I added some schematic on the top.
2017-11-09 10:07 AM
Hi Jakob,
can you share the sd_diskio.c from your project?
are you calling the BSP_SD_Init() in your main application?
regards
2017-11-09 11:10 AM
So a board like this
https://community.st.com/0D50X00009XkgXwSAJ
2017-11-09 11:14 AM
The code the OP uses in the .PNG attach to the top post
Seem to be some problems with the Cube release
https://community.st.com/0D50X00009XkZk8SAF
https://community.st.com/0D50X00009Xkf8PSAR
2017-11-10 01:43 AM
Hi Jakob and all,
the issue is that BSP_SD_Init() is not called in the sd_diskio.c file.This is a bug that is going to be fixed in the next release. Could you please modify the generated sd_diskio.c, in particular the SD_Initiaize() function as following and retest?
DSTATUS SD_initialize(BYTE lun)
{
Stat = STA_NOINIT;
if (BSP_SD_Init() == MSD_OK){
Stat = SD_CheckStatus(lun);
}
return Stat;
}
regards
Haithem.2017-11-10 05:04 AM
Hi Haithem,
I modified the sd_diskio.c as you described, but the program now gets stuck in ff.c at
/* Find an FAT partition on the drive. Supports only generic partitioning rules, FDISK and SFD. */
bsect = 0; fmt = check_fs(fs, bsect); /* Load sector 0 and check if it is an FAT-VBR as SFD */And after a while it quits with
if (fmt == 4) return FR_DISK_ERR; /* An error occured in the disk I/O layer */
Greets,
Jakob
Ps.: And yes, the SD Card has a working FAT system on it.
2017-11-10 07:39 AM
Hi Jakob,
the issue seems to be related to an error in the SD_read()/SD_Write() functions in the sd_dikio.c file.
Could you do the following:
in the function move_window() in the file ff.c check the res value after the sync_window():
different
fromFR_OK
then rerun the program and put a break point in the functionSD_Write() in the sd_diskio.c and check whether there is an issue in the BSP_SD_WriteBlocks_DMA()
equal
toFR_OK
then check the whether the call below is successful or not:
if (disk_read(fs->drv, fs->win.d8, sector, 1) != RES_OK)
if
it is not
then put a break point in the SD_Read in the sd_diskio.c file and check theBSP_SD_ReadBlocks_DMA()
regards