Release Notes

MDD File System Interface Library

MDDFS Interface Library Help
Release Notes

Microchip Memory Disk Drive File System Release Notes 

Description 

This library is intended to provide an interface to file systems compatible with ISO/IEC specification 9293 (commonly referred to as FAT12 and FAT16). The FAT32 file system is also supported, along with Long File Name(LFN) support for files and directories. This library includes four different physical interface files:

  • SecureDigital card interface using the SPI module
  • CompactFlash card interface using manual bit toggling
  • CompactFlash card interface using the Parallel Master Port module included on several PIC24/PIC32 microcontrollers.
  • and one template interface file that can be modified by the user to create a custom interface layer to an unsupported device.

In addition, Microchip’s USB Host stack (available from www.microchip.com/usb can be used as a physical layer. 

Latest version - 1.4.2 Log 

  1. FSIO.c Modifications:-
    • Minor Modification in "CreateFileEntry" function to fix a bug for file name lengths of 26,39....characters (multiples of 13).
    • Fixed the LoadMBR() function to scan all of the MBR entries and return success on the first supported drive or fail after the 4 table entries.

Compiler Version Used 

This library was compiled using MPLAB C18 v.3.42, XC16 v1.00, and XC32 v1.00 complier. 

Memory Size 

Unoptimized memory usage for the file interface library using the SD-SPI physical layer is given in Table 1. 512 bytes of data memory are used for the data buffer, and an additional 512 are used for the file allocation table buffer. Additional data memory will be needed based on the number of files opened by the user at once. The default data 

memory values provided include space for two files opened in static allocation mode. The 

C18 data memory value includes a 512 byte stack. The first row of the table indicates the smallest amount of memory that the library will use (for read-only mode), and each subsequent row indicates the increase in memory caused by enabling other functionality. Optimized and unoptimized totals for program and data memory with all functions enabled are listed after the table. This data was compiled while allowing two file objects to be opened simultaneously. 

Table 1: Memory Usage (Unoptimized) 

 

Total memory usage* 

  • C18 ( without LFN support ):

Unoptimized Program memory- 73702 bytes Unoptimized Data memory- 1976 bytes Optimized Program memory- 38834 bytes Optimized Data Memory- 1976 bytes

  • XC16 ( with LFN support ):

Unoptimized Program memory- 60606 bytes Unoptimized Data memory- 5104 bytes Optimized Program memory- 32903 bytes Optimized Data memory- 5104 bytes

  • XC32 ( with LFN support ):

Unoptimized Program memory- 80192 bytes Unoptimized Data memory- 6096 bytes Optimized Program memory- 41236 bytes Optimized Data memory- 6096 bytes 

*Note: C18 total memory usage does not include FSfprintf functionality. Since FSfprintf requires integer promotion to be enabled, using it greatly increases the code size of all functions. 

More Information 

More detailed information about the operation of this library is available in Application Note 1045, available from www.microchip.com. 

Previous Versions Log 

version 1.4.0

  1. FSIO.c Modifications:-
    • While creating files in LFN format with file name length as 13,26,39,52...etc(multiples of 13), MDD library was creating incorrect directory entries. To fix this issue, functions "FILEfind", "CreateFileEntry", "Alias_LFN_Object", "FormatFileName", "FormatDirName", "FSgetcwd", "GetPreviousEntry" & "rmdirhelper" were modified. Now "utf16LFNlength" variable part of "FSFILE" structure, indicates LFN length excluding the NULL word at the last.
    • When creating large number of files in LFN format, some files were not getting created in disk. To fix this issue,function "FILEfind" was modified.
    • Modified "FSformat" function to initialize "disk->sectorSize" to default value.
    • Modified "CreateFileEntry" & "FindEmptyEntries" functions to remove unnecessary assignments & optimize the code.
    • Modified "FSfopen" function to prevent creating an empty file in the directory, when SD card is write protected.
    • Variable "entry" in "writeDotEntries" function is made volatile & properly typecasted in it's usage.
    • Modified "FSFopen" function so that when you try to open a file that doesn't exist on the disk, variable "FSerrno" is assigned to CE_FILE_NOT_FOUND.

version 1.3.8

  1. Internal Flash.c Modifications:-
    • Modified "MDD_IntFlash_SectorRead" to write the correct word data in 'buffer' pointer.

version 1.3.6

  1. SD-SPI.c Modifications:-
    • Modified "FSConfig.h" to "FSconfig.h" in '#include' directive.
    • Moved 'spiconvalue' variable definition to only C30 usage, as C32 is not using it.
    • Modified 'MDD_SDSPI_MediaDetect' function to ensure that CMD0 is sent freshly after CS is asserted low. This minimizes the risk of SPI clock pulse master/slave syncronization problems.
  2. FSIO.c Modifications:-
    • The function "FILEget_next_cluster" is made public.
    • Modified "FILEfind" function such that when using 8.3 format the file searches are not considered as case sensitive
    • In function 'CacheTime', the variables 'ptr1' & 'ptr0' are not used when compiled for PIC32. So there definitions were removed for PIC32.
    • Modified "rmdirhelper", "FormatDirName" & "writeDotEntries" functions to remove non-critical warnings during compilation.
    • Updated comments in most of the function header blocks.
  3. FSIO.h Modifications:-
    • The function "FILEget_next_cluster" is made public.

version 1.3.4

  1. SD-SPI.c Modifications:-
    • Added support for dsPIC33E & PIC24E controllers.
    • #include "HardwareProfile.h" is moved up in the order.
    • "#define SPI_INTERRUPT_FLAG_ASM PIR1, 3" is removed from SD-SPI.c. "SPI_INTERRUPT_FLAG_ASM" macro has to be defined in "HardwareProfile.h" file for PIC18 microcontrollers.
    • Replaced "__C30" usage with "__C30__"
  2. FSIO.c Modifications:-
    • Initialized some of the local variables to default values to remove non-critical compiler warnings for code sanitation.
      • In function "FILEfind", local variables "fileFoundLfnIndex", "fileFoundMaxLfnIndex", "fileFoundDotPosition", "lfnMaxSequenceNum" & "reminder" initialized to '0'.
      • In function "FindEmptyEntries", local variable "a" initialized to '0'.
      • In function "FILEerase", local variable "clus" initialized to '0'.
      • In function "FormatFileName", local pointer variable "localFileName" initialized to 'NULL'.
    • The sector size of the media device is obtained from the MBR of media. So, instead of using the hard coded macro "DIRENTRIES_PER_SECTOR", the variables "dirEntriesPerSector" & "disk->sectorSize" are used in the code. The above mentioned variables use the sector size from the media rather than depending upon predefined macro "MEDIA_SECTOR_SIZE". Refer "Cache_File_Entry", "EraseCluster" & "writeDotEntries" fucntions to see the change.

version 1.3.2

  1. Modified SD-SPI.c, MDD_SDSPI_AsyncWriteTasks() so pre-erase command only gets used for multi-block write scenarios. .

version 1.3.0

  1. Supported LFN entries for files and directories.
  2. Implemented new functions to improve the previous performance/flexibility issues in SD- SPI.c and .h files.
  3. Fixed SD Card Initialization Issues, especially with SDHC.

version 1.2.4

  1. Add a software mechanism for the card detection to be used when the connectors does not provide a card detect signal (e.g. MicroSD connectors).
  2. Optimize some code by collapsing duplicated code into a single for loop.
  3. Update to use the CSD register data to calculate the SD card capacity.
  4. Fixed compatibility problems in SD-SPI.c that was preventing it from working with some of the cards.
  5. Make modifications to allow dynamic sector size giving the possibility to use thumb drives with different sector sizes.
  6. Corrected a bug that prevented the last two clusters of a drive to be able to be written to.
  7. Add the GetDiskProperties function to allow the users to get the disk properties (size of disk, free space, etc)

version 1.2.3

  1. Added FSGetDiskProperties() function. This function gets the remaining disk space as well as other properties such as sector size, clusters per sector, partition format, etc.
  2. Fixed bug that prevented the last two clusters in a partition from being allocated.
  3. Added SDHC support for the MDD file system.
  4. Fixed the problem where on an append to a file that is smaller than a sector.
  5. Fixed TODO that limited internal flash to PSV page boundaries in on PIC24 and only PSVPAG = 1.
  6. Fixed an issue with the FSattrib function that was changing the wrong cached file object.

version 1.2.2

  1. Improved the SPI code operation and prescaler calculation.
  2. Cast the root directory size value determination to a double word for devices in which the root directory begins after 0xFFFF clusters.
  3. Changed the size of the index variable in the FSformat function to allow calculation in devices with larger FATs.
  4. Replaced several hard-coded values with references to MEDIA_SECTOR_SIZE.
  5. Changed the return mechanism of the MediaInitialize function to provide compatibility with the USB stack. This function will now return a pointer to a MEDIA_INFORMATION structure, which contains an error code and (for the USB stack) the size of a sector (in bytes) and the number of LUNs on the device. This structure’s definition is located in FSDefs.h.
  6. Added a new error code: CE_UNSUPPORTED_SECTOR_SIZE indicates that the sector size of the device is not supported by the file system.

version 1.2.1

  1. Fixed an issue with the calculation of the SPI prescaler value for 16-bit microcontrollers.
  2. Changed the ‘cwdclus’ type in the SearchRec structure to ‘unsigned long’
  3. Fixed a potential null-pointer reference in the Cache_File_Entry() function
  4. Improved PIC32 reliability.
  5. Changed PIC32 code to allow the user to select which SPI module to use. Selection is performed using #define macros in HardwareProfile.h.
  6. Changed PIC32 code to allow the user to define the desired SPI clock frequency. Selection is performed by setting #define SPI_FREQUENCY to the desired value in HardwareProfiles.h.
  7. Changed the return type of MDD_SDSPI_ShutdownMedia to match the USB Host ShutdownMedia function.
  8. Replaced instances of C18XX with 18CXX
  9. Added the packed attribute to several structures in FSDefs.h.

version 1.2.0

  1. Fixed a bug that prevented the library from correctly loading the boot sector on devices with no Master Boot Record.
  2. Added support for 8.3 format directory names (up to 8 name characters and 3 extension characters.) To create or access directories with extensions, use path strings with radix characters (e.g. FSmkdir (“EXAMPLE.DIR”)).
  3. Added checks to the FSmkdir function to prevent the user from creating files with too many radix characters (‘.’). Radixes at the beginning of the directory name will cause the FSmkdir function to fail.
  4. Added a check to the FSrmdir function to prevent the user from using it to delete non- directory files or the current working directory.
  5. Added the question mark (‘?’) partial string search operator to the FindFirst and FindNext functions. Now when calling FindFirst or FindNext, you can skip checks of individual characters by replacing them with question marks in the search string. For example, calling FindFirst (“F?L?.TX?, ATTR_ARCHIVE, &rec); would let you find the files “FILE.TXT,” “FOLD.TXT,” “FILM.TXM,” etc.
  6. Modified the FindFirst and FindNext functions to correctly output directory names with extensions.
  7. Modified the FSgetcwd function to correctly insert directory names with extensions in a path string.
  8. Merged the functions to validate file/directory name characters together.
  9. Added three new methods of opening files. To use these methods, just specify the new strings as the mode argument in the FSfopen function. The new modes are:
    • “r+”: File will be opened for reading or writing
    • “w+”: File will be opened for reading or writing. If the file exists, its length will be truncated to 0.
    • “a+”: File will be opened for reading or writing. If the file exists, the current location within the file will be set to the end of the file.
  10. Modified the FSfopen function to allow the user to open directories in the read mode.
  11. Modified the FSrename function. Now, to rename a directory, open the directory in read mode with FSfopen and pass the pointer to that open directory into FSrename.
  12. Added a new function. The FSattrib function will allow the user to change the attributes of files and directories.
  13. Modified the SD Data Logger project to include a new shell command; the ‘ATTRIB’ command will let the user change or display the attributes of a file.
    • Example 1: ATTRIB +R +S –H –A FILE.TXT This command will give the file FILE.TXT the read-only and system attributes, and remove the hidden and archive attributes, if they’re set.
    • Example 2: ATTRIB FILE.TXT This example will display the attributes of FILE.TXT.
  14. Added a new function. The FSferror function will provide information about why a previously called function failed.
  15. Revised most of the comment headers in the library.
  16. Generated a CHM help file for the library. This file can be found in the (default) directory “…\Microchip Solutions\Microchip\Help”
  17. Removed extraneous macros and definitions.
  18. Added a new Microchip standard header file (Compiler.h) to the library.
  19. Removed the architecture-type configuration from the sample HardwareProfile.h files. This will now be taken care of automatically within the source files.

version 1.1.2

  1. Fixed a bug that prevented the allocation of new clusters to the root directory in FAT32 implementations.
  2. Fixed a bug that prevented writing more than one cluster’s worth of file entries to the root directory in FAT16/FAT12 implementations.
  3. Fixed a bug that returned an incorrect date for directory entries located in the first directory entry after a cluster boundary of a FAT32 root directory.
  4. Fixed a bug with FSrename that would cause the function to improperly fail if the directory entries in the current working directory (or previous directory, when renaming the CWD) completely filled a cluster (and no data clusters were allocated to the directory after that).

version 1.1.1

  1. Fixed a bug with the PIC24 clock divider that was causing the interface to run more slowly than intended.
  2. Added support for PIC32 microcontrollers.

version 1.1.0

  1. Added support for FAT32. To enable this functionality, make sure the SUPPORT_FAT32 macro is uncommented in FSconfig.h.
  2. Added functions to provide support for the USB Mass Storage Host code.
  3. Moved pin and hardware definitions from physical interface files to HardwareProfiles.h.
  4. Created function pointers for functions that vary between interface files. These are located in FSconfig.h.
  5. Moved macros to select the correct physical layer to HardwareProfiles.h.
  6. Modified the SD-SPI physical layer to ensure that communication speed during startup falls between 100 kHz and 400 kHz
  7. Created a new example project: MDD File System-PIC24-SD Data Logger. This project contains code for a shell-style program based on the USB Thumb-drive shell demonstrated in Application Note 1145.
  8. Decreased the delay in the SD-SPI media initialization from 100 ms to 1 ms. i. Added the ability to change directories when writes are disabled.

version 1.01

  1. FindFirst and FindNext will now return the create time/data in the timestamp field of a SearchRec object when they return values for a directory.
  2. Corrects a bug in the FindEmptyCluster function when searching for files beyond the end of a storage device.
  3. Automatically aligns buffers for 16-bit architectures.
  4. For the SPI interface, prescaler divides will now be determined dynamically based on the system clock speed defined in FSconfig.h.
  5. The DiskMount, LoadMBR, LoadBootSector, and FSFormat functions, as well as the gDiskData, gFATBuffer, and gDataBuffer structures are now located in FSIO.c instead of in the interface files.
  6. The SectorRead function will now do a dummy read of the sector and discard the data if it is called with NULL as the data pointer.
  7. Replaced the device initialization code in the FSFormat function with calls to InitIO and MediaInitialize.
  8. The MediaDetect function is not de-bounced. In order to determine that a device is available, you must call MediaDetect, wait for an appropriate amount of time, and then call it again.
  9. The sample linker script in the MDD File System-PIC18-CF-DynMem-UserDefClock project has been modified. Previously, several databanks were merged together; this caused an issue accessing variables that spanned multiple data banks. C18 only allows users to access variables like these using pointers.
  10. Added a new user function. The FSrename function will allow the user to rename files and directories. A version that accepts a ROM filename is available for PIC18 (FSrenamepgm).
Microchip MDD File System Interface 1.4.2 - [Oct 15, 2012]
Copyright © 2012 Microchip Technology, Inc.  All rights reserved.