Page 1 of 1

FAT FS using MMC_SPI: Sync

Posted: Fri Mar 09, 2012 4:21 pm
by Florian
Hi Giovanni,
maybe that was discussed already, but I didn't find anything yet.
I want to use the FAT_FS by http://elm-chan.org/fsw/ff/00index_e.html on the MMC_SPI driver.
The FS requires a low-level function that finishes all pending write operations (or at least guarantees that no writing operation is pending anymore) but I don't see any possibility to do that using the MMC driver, except disconnecting and connecting again. It seems as if that function is called periodically and I would like to avoid the overheap.

Is there a way to get the content of the CSD register or some other way to determine the size / sector cout of the card?
Thank you!

Regards,
Florian

Re: FAT FS using MMC_SPI: Sync

Posted: Fri Mar 09, 2012 4:27 pm
by Giovanni
Good points, both are missing.

The sync could be implemented easily, the other function is present in the new SDC driver if I remember well and could be ported.

Giovanni

Re: FAT FS using MMC_SPI: Sync

Posted: Fri Mar 09, 2012 7:23 pm
by barthess
Now I am working on SDC (and fatfs) driver. Looks like there is no need of function that finishes all pending write operations because there is no buffered write operations in it.

Re: FAT FS using MMC_SPI: Sync

Posted: Fri Mar 09, 2012 7:25 pm
by Giovanni
The MMC_SPI driver requires it because it does not wait for the last write operation to finish before returning (it is done this way to speedup it a bit). I was referring to this one.

Giovanni

Re: FAT FS using MMC_SPI: Sync

Posted: Fri Mar 09, 2012 7:35 pm
by barthess
Understand.
Do you mind about providing of FatFS driver via ChibiOS repo in unpacked state? This will allow to improve diskio.c in more convenient way.

Re: FAT FS using MMC_SPI: Sync

Posted: Fri Mar 09, 2012 7:53 pm
by Giovanni
Let me think about that, I don't know if it is a good idea to have external code unpacked like ChibiOS code, I don't want to mess with copyrights. Diskio could be moved under ./os/various/fatfs_bindings like I did for lwIP stuff, is that acceptable for you?

Giovanni

Re: FAT FS using MMC_SPI: Sync

Posted: Fri Mar 09, 2012 8:06 pm
by barthess
Yes, it is acceptable.

Re: FAT FS using MMC_SPI: Sync

Posted: Mon Mar 12, 2012 12:06 pm
by Florian
yes, that sounds good.

Back to the CSD register: Would you recommend a function in the MMC driver that returns the value in the CSD (more specialized) or a function that allows to send an arbitrary command to the MMC (more generic)? A third solution was a function that reads the size of the card from the CSD by itself and returns just that size information, i.e. s.th. like mmcGetCardSize(MMCDriver).
Anyway, I have no further situation in mind, where the user app wants/should send other commands the card directly and it appears a bit risky to me.

For the sync issue, I just wrote a function mmcSync(MMCDriver) calling the internal sync function (that I think does exactly what we need, i.e. waits for all processes to finish).

Re: FAT FS using MMC_SPI: Sync

Posted: Mon Mar 12, 2012 12:25 pm
by Giovanni
Yes, it is correct, it is the internal sync, I would add some state checking before invoking it.

About size/cds, not sure what is better, we could do both.

Giovanni