FAT FS using MMC_SPI: Sync

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
Post Reply
Florian
Posts: 18
Joined: Fri Sep 09, 2011 3:19 pm

FAT FS using MMC_SPI: Sync

Post 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
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: FAT FS using MMC_SPI: Sync

Post 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
User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Been thanked: 7 times

Re: FAT FS using MMC_SPI: Sync

Post 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.
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: FAT FS using MMC_SPI: Sync

Post 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
User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Been thanked: 7 times

Re: FAT FS using MMC_SPI: Sync

Post 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.
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: FAT FS using MMC_SPI: Sync

Post 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
User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Been thanked: 7 times

Re: FAT FS using MMC_SPI: Sync

Post by barthess »

Yes, it is acceptable.
Florian
Posts: 18
Joined: Fri Sep 09, 2011 3:19 pm

Re: FAT FS using MMC_SPI: Sync

Post 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).
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: FAT FS using MMC_SPI: Sync

Post 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
Post Reply