Hi Dave, Martin
Just a quick overview:
- presently I am working on FAT16 support since it has turned out to be necessary to get Windows XP to co-opertae with NAND Flash smaller that 32M (Vista and Win 7 are OK working with FAT32 even in such small memory but it will be necessary to have XP working with it too for some time).
- I was suprised at how few SD card holders have switches integrated into them. Some which do, just had them shorted to ground in the boards and so I hardly had a development board which allowed them to be used, so I left this out. However the utFAT does have a flag (utDisks[ucDrive].usDiskFlags & WRITE_PROTECTED_SD_CARD) which can be set by any code that is capable of reading the switch state of the write protection. It actually only blocks formatting (not writing or deleting, for some reason) at the moment but this will be quite easy to add at the start of any routines that attempt to write.
In may cases the application code, which calls writes, deletes etc. can also check the switch and avoid calling these (rather than calling and checking the return value to see whether it failed due to this). Write protected files on a card should already be protected (due to their read-only state in the file attributes).
Finally there is also a write proect setting in the SD card registers themselves. I didn't try using this though, and don't actually know how it gets set - possibly requires a special utility for PC user's to actually set it themselves(?)
- The utFAT module is about 1 year old now. In its first version it has a few constraint (like not being able to manage cards being removed and re-inserted during normal operation) and it generally does takes a year or so of first users doing real work with it to identify in which direction further development should be channeled (this is also quite typical of introduction times for new processor packages too, before real work begins to be done with them).
- There is a lot that can be done with file systems like this; USB MSD is available in newer Beta versions - as SD-card and as NAND Flash - these are being refined in first projects and maybe a number of LUNs (the logical units; eg. SD card seen as Disk E:, internal Flash as disk F:, external SPI Flash as disk G: and external NAND Flash as disk H:) will be possible with time - it does however take quite a lot of development effor to get that far though...)
- It is already possible to use SD-card (utFAT) and uFileSystem (internal FLASH or external SPI Flash) at the same time. Not yet to have these two areas seen as different FAT disks, but utFAT is basically build so that it should be possible (with corresponding development effort).
- Since SD cards are often shared between embedded system and PCs I decided that LFN would be essential, at least being able to read them in the embedded system.
The compilcations with writing (and deleting) are:
- there is the patent issue when writing LFN and probably the Linux workaround would have to be used (presuming that this doesn't get involved in a court-case in the near future). Such a problem would effectively mean any LFN write users would suddenly have potential problems too. Playing safe, it was not done (also it made life simpler for the first version). Technically it is however not that difficult but small embedded systems will (in my opinion) usually be able to live with writing 8:3 format without big restrictions.
- the utFAT can not delete LFN due to the fact that LFN are stored in multiple clusters. Reading them is no problem but deleting them requires working through clusters in the reverse direction. Clusters are easy to search in the forward direction but haven't any support for searching in the reverse direction apart from simple brute-force (meaning lots of search time). Windows actually reads the complete FAT from the card as first job when it connects and so has the advantage that the FAT is in local RAM, where it can of course search quite fast - embededed systems don't usually have the luxury of being able to cache the FAT (it would typically need several MBytes of RAM to do this) and so has to search by reading the card (which is slow) and may need to actually first search several MByte of data to be able to delete a LFN....for the first instance I decided to avoid this complexity. Of course, with the right motivation (and time and test projects) there is nothing to stop us performing the next steps and also achieving this.
- I do see NAND Flash based FAT as potentially very interesting in the near future - more and more single-chip processors have NAND Flash controllers in them (like the new Kinetis and STM devices, as well as established SAM7SE). The complication is that the processor needs to do memory management (mapping virtual sections to physical memory) and also level-wear (ensuring that the write/deletes are spread across the phyical memory area to avoid wear-out of high-useage sectors) and also bad-block management (NAND is not 100% reliable and so needs to error checking and management of sectors that fail early or are also defect on delivery - the manufacturer guaranties that there are a minimum number of operational sectors and not that they all work).
This is quite complicated (especially to get 100% right) but a new document will be appearing soon on the doc page detailing exactly the solution used - adapting to different chips is then quite easy.
Regards
Mark