31
utFAT / Re: SD Card questions
« on: February 23, 2011, 04:22:36 PM »
Hi Dave,
I too hit your point1 here is the text from an email I sent to Mark about this, it also gives a possible solution to detecting a changed card by using its serial number.
Point 2, I would think would be easy to add, not sure about point 3
Thanks Mark,
I understand about the switches, it would be good not to have to use them. But it would be useful to detect card changes, I can’t guarantee what the user will do.
Do SD cards have unique serial numbers that could be checked? A quick google seemed to talk about the SD cards serial number stored in the CID register, could this be polled periodically to check if it exits / has changed, which would indicate a change?
Page 60 of this document http://www.sdcard.org/developers/tech/sdcard/pls/Simplified_Physical_Layer_Spec.pdf talks about CMD10 being used to read the CID of a card.
With your demo is there any command to re-mount the card?
Maybe the info command could read the CID and remount the card if a different CID is found
FAT16 support would be nice, as I can see that some user devices would be preformatted this way. I agree with you about FAT12. I presume you would support read and write under FAT16.
Just compiled V1.8 and confirmed it works as before
Would it be helpful to transfer this conversation to the forum, for the benefit of other users or just post a summary at the end?
Cheers
Martin
From: Mark Butcher [mailto:Mark@uTasker.com]
Sent: 05 January 2011 13:45
To: Martin Honeywill
Subject: AW: Testing utFAT - more stuff
Hi Martin
I attached a V1.8 (it doesn’t have anything that will change things – just NAND FLASH interface and a couple of minor features as in the thread).
The problem is the following: SD card insertion and removal is detected by switches on the SD card sockets. The Luminary board has these switches connected to GND so they can’t be used (also the write protect switch cannot be detected). Some of the sockets also don’t have these switches physically. 90% of boards don’t connect them and so I didn’t put any generic support for them in the code for this reason.
Detection is achieved the first time due to the fact that the interface is regularly trying to mount the card. When a card is inserted it can be mounted and subsequently used.
If the card is removed the SW doesn’t know this. It will be detected only the next time that accesses are attempted, which fail. Then it would be possible to restart the mounting/detection process if required. If the mounted card is removed and a different one inserted this will not be seen. It can result in strange effects if files are open and especially if the card is different.
That means that it is essentially designed for a fixed inserted card – mainly since there is often no switch available (as on the LM boards).
Only FAT 32 is supported – in fact I will add FAT 16 soon since I don’t think that Windows likes working with FAT32 when the file system is small (eg. When a small NAND Flash is used). It should only be a few lines of code. I don’t think that FAT12 is of any use though (it is more complicated and FAT16 seems small enough anyway for typical FLASH chips).
Regards
Mark
I too hit your point1 here is the text from an email I sent to Mark about this, it also gives a possible solution to detecting a changed card by using its serial number.
Point 2, I would think would be easy to add, not sure about point 3
Thanks Mark,
I understand about the switches, it would be good not to have to use them. But it would be useful to detect card changes, I can’t guarantee what the user will do.
Do SD cards have unique serial numbers that could be checked? A quick google seemed to talk about the SD cards serial number stored in the CID register, could this be polled periodically to check if it exits / has changed, which would indicate a change?
Page 60 of this document http://www.sdcard.org/developers/tech/sdcard/pls/Simplified_Physical_Layer_Spec.pdf talks about CMD10 being used to read the CID of a card.
With your demo is there any command to re-mount the card?
Maybe the info command could read the CID and remount the card if a different CID is found
FAT16 support would be nice, as I can see that some user devices would be preformatted this way. I agree with you about FAT12. I presume you would support read and write under FAT16.
Just compiled V1.8 and confirmed it works as before
Would it be helpful to transfer this conversation to the forum, for the benefit of other users or just post a summary at the end?
Cheers
Martin
From: Mark Butcher [mailto:Mark@uTasker.com]
Sent: 05 January 2011 13:45
To: Martin Honeywill
Subject: AW: Testing utFAT - more stuff
Hi Martin
I attached a V1.8 (it doesn’t have anything that will change things – just NAND FLASH interface and a couple of minor features as in the thread).
The problem is the following: SD card insertion and removal is detected by switches on the SD card sockets. The Luminary board has these switches connected to GND so they can’t be used (also the write protect switch cannot be detected). Some of the sockets also don’t have these switches physically. 90% of boards don’t connect them and so I didn’t put any generic support for them in the code for this reason.
Detection is achieved the first time due to the fact that the interface is regularly trying to mount the card. When a card is inserted it can be mounted and subsequently used.
If the card is removed the SW doesn’t know this. It will be detected only the next time that accesses are attempted, which fail. Then it would be possible to restart the mounting/detection process if required. If the mounted card is removed and a different one inserted this will not be seen. It can result in strange effects if files are open and especially if the card is different.
That means that it is essentially designed for a fixed inserted card – mainly since there is often no switch available (as on the LM boards).
Only FAT 32 is supported – in fact I will add FAT 16 soon since I don’t think that Windows likes working with FAT32 when the file system is small (eg. When a small NAND Flash is used). It should only be a few lines of code. I don’t think that FAT12 is of any use though (it is more complicated and FAT16 seems small enough anyway for typical FLASH chips).
Regards
Mark