what is wrong with the file system on stm32f411?
I have two boards designed for stm32f405 and stm32f411 to test uSD card.
The problem of using uSD on STM32F405 was fixed as discussed earlier:
https://community.st.com/thread/35991-microsd-card-problem-bug-in-the-filestm32f4xxhalsdc
Reading file/writing file are totally fine withut any problem on the STM32F405.Then I study the another board with a chip stm32f411ret6. These two boards are very similar because these two chips has very close pin configration.
Here is what is going on on the board with the chip stm32f4
I generated the code with cubemx, copy the testing code, and fixed the bug in the file mentioned above.
Low level io writing/reading has been tested. Pass!
Can I say that hardware problem (such as connection)is out of question?
But when I try to use file system to read/write file, there is an error in the line:
fmt = check_fs(fs, bsect); /* Load sector 0 and check if it is an FAT boot sector as SFD */
returns FR_DISK_ERR.
Tried two sd card, 1g and 32g. Both works on the board with chip stm32f
What is wrong? Any instructions please.
The code for reading/writing testing is as followings
void SD_Test_LowLevel(void) { uint8_t SD_state = MSD_OK; static uint8_t prev_status = 0; char usbbuffer[200]; SD_state = BSP_SD_Init(); if(SD_state != MSD_OK) { sprintf(usbbuffer,'\n---initialize failed ---\n');//export it to char buffer first. SendTextMsgToUSB(usbbuffer); //send the txt back Error_Handler(); } //initialization is done. Now go ahead for SD operation in low level SD_state = BSP_SD_Erase(BLOCK_START_ADDR, (BLOCKSIZE * NUM_OF_BLOCKS)); if(SD_state != MSD_OK) { sprintf(usbbuffer,'\n---erase failed ---\n');//export it to char buffer first. SendTextMsgToUSB(usbbuffer); //send the txt back Error_Handler(); } /* Fill the buffer to write */ Fill_Buffer(aTxBuffer, BUFFER_WORDS_SIZE, 0x22FF); SD_state = BSP_SD_WriteBlocks(aTxBuffer, BLOCK_START_ADDR, BLOCKSIZE, NUM_OF_BLOCKS); if(SD_state != MSD_OK) { Error_Handler(); } SD_state = BSP_SD_ReadBlocks(aRxBuffer, BLOCK_START_ADDR, BLOCKSIZE, NUM_OF_BLOCKS); if(SD_state != MSD_OK) { sprintf(usbbuffer,'\n---reading failed ---\n');//export it to char buffer first. SendTextMsgToUSB(usbbuffer); //send the txt back } else { sprintf(usbbuffer,'\n---Reading OK ---\n');//export it to char buffer first. SendTextMsgToUSB(usbbuffer); //send the txt back if(Buffercmp(aTxBuffer, aRxBuffer, BUFFER_WORDS_SIZE) > 0) { sprintf(usbbuffer,'\n---reading/writing compare failed ---\n');//export it to char buffer first. SendTextMsgToUSB(usbbuffer); //send the txt back } else { sprintf(usbbuffer,'\n---Testing is done, OK ---\n');//export it to char buffer first. SendTextMsgToUSB(usbbuffer); //send the txt back } } GREEN_LED_ON;//Good while (1) { } }�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�? #stm32f411 #sdio #stm32f405
Note: this post was migrated and contained many threaded conversations, some content may be missing.