2012-01-09 01:38 AM
Hi,
I've a problem with my STM32. I need to use fat filesystem on SD card to read/write/create files. I tried to use Chan FatFs module but it didn't working at all ... I use SD card in SDIO and 4 wires mode. When I debug, check_fs() function can't retrieve 0x55 0xAA on boot sector, but, when I read sector n�0 in the main(), I can correctly read all datas on boot sector. If someone can help me with this problem ... Thanks. #sdio-fatfs #sdio-chan-fatfs2013-03-05 06:40 AM
i don't inderstand you.my question is there a fatfs library that i can use it without modification.(standard library).
2013-03-05 07:00 AM
Perhaps, I'd just port it, embedded sw devs are expected to do that for custom platforms. The FatFs code is cross platform, the bulk of it you leave alone and will compile just fine, the platform specific code to do the sector/block IO is in DISKIO.C
If you have routines to access the card, integration is relatively straight forward. If you can't find a drop in example via Google/Bing, assume you're going to have to do the port yourself, or contract someone.2013-03-05 07:16 AM
my problem is there is any available exapmle using the stm32F10b and the fatfs library to control the micro sd card even if it use the SDIO interface.
2013-03-05 07:25 AM
Magic 8 Ball says ''ask again later'', I guess you can wait for other responses.
So what is this STM32F10B, are you talking about the STM3210B-EVAL?2013-03-05 07:53 AM
yes i am using the stm32f10b eval board and it is connected to the micro sd card with spi protocol.
2013-03-05 09:16 AM
Drop the 'F' when Googling, it's not in the board name, you'll get better results.
2013-03-07 12:36 AM
Hi Clive1
I used the exapmle that you have posted in wich you use the stm32f4 discovery and a micro sd card connected to the STM32 by the SDIO interface.My question is that we don't have the same functions for example: SD_ReadMultiBlocksFIXED i have this function:uint8_t MSD_ReadBuffer(uint8_t* pBuffer, uint32_t ReadAddr, uint32_t NumByteToRead){ uint32_t i = 0, NbrOfBlock = 0, Offset = 0; uint8_t rvalue = MSD_RESPONSE_FAILURE; /* Calculate number of blocks to read */ NbrOfBlock = NumByteToRead / BLOCK_SIZE; /* MSD chip select low */ MSD_CS_LOW(); /* Data transfer */ while (NbrOfBlock --) { /* Send CMD17 (MSD_READ_SINGLE_BLOCK) to read one block */ MSD_SendCmd (MSD_READ_SINGLE_BLOCK, ReadAddr + Offset, 0xFF); /* Check if the MSD acknowledged the read block command: R1 response (0x00: no errors) */ if (MSD_GetResponse(MSD_RESPONSE_NO_ERROR)) { return MSD_RESPONSE_FAILURE; } /* Now look for the data token to signify the start of the data */ if (!MSD_GetResponse(MSD_START_DATA_SINGLE_BLOCK_READ)) { /* Read the MSD block data : read NumByteToRead data */ for (i = 0; i < BLOCK_SIZE; i++) { /* Read the pointed data */ *pBuffer = MSD_ReadByte(); /* Point to the next location where the byte read will be saved */ pBuffer++; } /* Set next read address*/ Offset += 512; /* get CRC bytes (not really needed by us, but required by MSD) */ MSD_ReadByte(); MSD_ReadByte(); /* Set response value to success */ rvalue = MSD_RESPONSE_NO_ERROR; } else { /* Set response value to failure */ rvalue = MSD_RESPONSE_FAILURE; } } /* MSD chip select high */ MSD_CS_HIGH(); /* Send dummy byte: 8 Clock pulses of delay */ MSD_WriteByte(DUMMY); /* Returns the reponse */ return rvalue;}so i have changed something in the file ff.c when calling the function f_read i put the 4th varaible to 512 to read 512 bytes.
But it returns FR_NO_FILE2013-03-07 12:38 AM
This is my main code
void main(void){ /*!< At this stage the microcontroller clock setting is already configured, this is done through SystemInit() function which is called from startup file (startup_stm32f30x.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f30x.c file */ /* Configure PC12 pin: CS pin */ // GPIO_InitTypeDef GPIO_InitStructure; /* Initializes the SD/SPI communication */ Status = MSD_Init(); Get_Medium_Characteristics(); memset(&fs32, 0, sizeof(FATFS)); res1 = f_mount(0, &fs32); res2 = f_open(&fil, ''essai1.txt'', FA_WRITE); res0 = f_close(&fil); // LENGTH.TXT while (1) { }}2013-03-07 07:01 AM
You should not have to touch FF.C, all you IO abstraction should be in DISKIO.C
res2 = f_open(&fil, ''essai1.txt'',FA_OPEN_ALWAYS | FA_WRITE); // Surely?2013-03-07 07:27 AM
Thank you Clive1 my problem was resolved.Just i modified the file diskio.c (disk functions).
Once again i want to thank you.