SDIO 4 bit mode with STM32CubeMX
I would like to use SDIO with 4 bit mode with FatFS. I use STM32F429I Discovery board and I wired a micro SD card board to it. The SD card is a 16 GB SanDisk Ultra A1 card formatted to FAT32.
This is the micro SD card board: https://image.dhgate.com/0x0s/f2-albu-g4-M01-BC-F9-rBVaEVmcHSeAdh6CAAKj2N4sVnA447.jpg/3-3v-5v-micro-sd-tf-card-reader-module-spi.jpg all lines are pulled up to 3V with 10k res (even the CLK).
Version of STM32CubeMX is 4.26.1, firmware version is STM32Cube FW_F4 V1.21.0, I use Atollic TrueSTUDIO 9.0.0 and FatFS version is R0.12c.
If I generate SDIO with 1 bit mode with CubeMX it works fine, I can read, write the card.
When I generate SDIO with 4 bit mode it is not working. Function 'f_mount' is returning with error code: 13 which is 'FR_NO_FILESYSTEM'. But there is a working file system on the card, I can use it with PC and it works with 1 bit SDIO mode also.
This is the relevant part of the code (all other part is generated with CubeMX):
// ...
uint8_t myWrite[30] = "TEST STRING";
uint8_t myRead[30];
// ...
int main(void)
{
// ...
printf("Start!\r\n");
FATFS myFAT;
FIL myFile;
UINT byteCount;
printf("path: '%s'\r\n", SDPath);
FRESULT fRet = 0;
fRet = f_mount(&myFAT, SDPath, 1);
if(fRet == FR_OK){
f_open(&myFile, "test.txt", FA_WRITE | FA_CREATE_ALWAYS);
f_write(&myFile, myWrite, 30, &byteCount);
f_close(&myFile);
f_open(&myFile, "test.txt", FA_READ);
f_read(&myFile, myRead, 5, &byteCount);
f_close(&myFile);
}else{
printf("mount fail :(\r\n");
printf("err. code: %d\r\n", fRet);
}
// ...
while (1)
{
// ...
}
}The same code works if I generate SDIO 1 bit mode with CubeMX, but I get the above mentioned 'FR_NO_FILESYSTEM' error with 4 bit SDIO mode.
Please help me how can I solve this.
Thank you in advance!
