2017-01-11 05: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??
2017-01-11 06:28 AM
Reinitialize the SDIO layer?
2017-01-11 07: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.
2017-01-11 08: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'.
2017-01-11 09: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.
2017-01-11 09: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.
2017-01-17 05: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 ??