fatfs disk error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-01-11 5:59 AM
Hi,
I am using fatfs sdio with my stm32f429 mcu , i can, open read, write files correctly. When i plug out the sd card from my board at runtime, the f_open, f_write and f_read functions do not work and so i can not open or write anything to file, until i reset the mcu. I use for open and write sequence with my code below:
if(f_mount(&SDFatFs, '0:', 0) == FR_OK)//sd kart yazma iÅŸlemleri
{ if(f_open(&MyFile, 'STM32.TXT', FA_CREATE_ALWAYS | FA_WRITE) == FR_OK) { if(f_write(&MyFile, (const void *)wtext, sizeof(wtext), (void *)&wbytes) == FR_OK); { f_close(&MyFile); } } }Any advise??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-01-11 6:28 AM
Reinitialize the SDIO layer?
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-01-11 7:34 AM
Hi Clive One,
Yes i have called the 'MX_SDIO_SD_Init();' function when i re-plug the sdcard, but it doesnt work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-01-11 8:24 AM
Just pulling the card during operation is not a supported use case.
What do other OSs do when 'unmounting' a SD card ?
Pretty sure you need to incorporate that procedure - SD cards have a controller on their own, and thus are asynchronous.
I have several projects with fatfs usage, but none is ready for 'hot plugging'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-01-11 9:03 AM
Then evidently you'll need to dig into that and make it more robust in terms of it's ability to get the peripheral/interface/card into an agreeable state. I'm not sure what is supplied is a commercially robust solution. There is no code to determine what state things are in, or retry, or reset the interface.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-01-11 9:54 AM
Pulling a card during active usage is a whole level of grief in terms of tearing down the system and recovering. It also runs significant risk of destroying or corrupting content.
Getting something into a safe state where you can 'eject' the card, and then remount a new one, is more achievable, but does require a lot of work and thought. The code as supplied by ST has very poor error handling or recovery, and has a lot of expectations about initial conditions, and run-once usage.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-01-17 5:33 AM
Hi,
when i have tried fatfs with spi, it works well for this situation. I think the problem is about the sdio layer. I have used the sdio_init function when i have re-ejected the sdcard but it does not work. Do you know any extra init or reset condition for sdio layer ??
