From ca68e12516480532ce1b260dcc221e1d44461774 Mon Sep 17 00:00:00 2001 From: patacongo Date: Wed, 27 May 2009 21:44:20 +0000 Subject: [PATCH] Fix FAT32 bug git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@1829 7fd9a85b-ad96-42d3-883c-3090e2eb8679 --- nuttx/ChangeLog | 8 +++++++- nuttx/Documentation/NuttX.html | 9 +++++++-- nuttx/TODO | 7 +------ nuttx/drivers/mmcsd/mmcsd_spi.c | 2 -- nuttx/fs/fat/fs_fat32util.c | 21 +++++++++++++-------- 5 files changed, 28 insertions(+), 19 deletions(-) diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 51abe18d0..7aed46af7 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -734,8 +734,14 @@ * examples/nsh: Added MMC/SD support for the LM3S6918 * arch/arm/src/lm3s: Fix logic for setting and clearing output GPIOs (critical fix!). - * drivers/mmcsd: Found numerous errors in current MMC/SD SPI driver. Bad frequency + * drivers/mmcsd: Found numerous errors in current MMC/SD SPI driver. Bad frequency calculation based on CSD settings, inappropriate timeouts, odd code that looks like a bad search and replace. Also needs support for SDHC ver 2.x. New MMC/SD is largely redesigned and probably non-functional in the first check-in. + * drivers/mmcsd: Changes verified on 4Gb Kingston SHDC card. Still having + issues with 2Gb SanDisk SDC card. + * fs/fat: With the 4Gb card, the first tests of FAT32 were (finally) performed. + Found a correct a problem that prevented use of FAT32: It was not updating + the sector cache before checking the FAT32 FSINFO sector. + diff --git a/nuttx/Documentation/NuttX.html b/nuttx/Documentation/NuttX.html index 7c22f7ea0..05a6ca377 100644 --- a/nuttx/Documentation/NuttX.html +++ b/nuttx/Documentation/NuttX.html @@ -8,7 +8,7 @@

NuttX RTOS

-

Last Updated: May 26, 2009

+

Last Updated: May 27, 2009

@@ -1424,10 +1424,15 @@ nuttx-0.4.7 2009-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> * examples/nsh: Added MMC/SD support for the LM3S6918 * arch/arm/src/lm3s: Fix logic for setting and clearing output GPIOs (critical fix!). - * drivers/mmcsd: Found numerous errors in current MMC/SD SPI driver. Bad frequency + * drivers/mmcsd: Found numerous errors in current MMC/SD SPI driver. Bad frequency calculation based on CSD settings, inappropriate timeouts, odd code that looks like a bad search and replace. Also needs support for SDHC ver 2.x. New MMC/SD is largely redesigned and probably non-functional in the first check-in. + * drivers/mmcsd: Changes verified on 4Gb Kingston SHDC card. Still having + issues with 2Gb SanDisk SDC card. + * fs/fat: With the 4Gb card, the first tests of FAT32 were (finally) performed. + Found a correct a problem that prevented use of FAT32: It was not updating + the sector cache before checking the FAT32 FSINFO sector. pascal-0.1.3 2009-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> diff --git a/nuttx/TODO b/nuttx/TODO index 679077b22..6f3c9f809 100644 --- a/nuttx/TODO +++ b/nuttx/TODO @@ -10,7 +10,7 @@ NuttX TODO List (Last updated April 12, 2009) (12) Network (net/, netutils/) (1) USB (drivers/usbdev) (4) Libraries (lib/) - (6) File system/Generic drivers (fs/, drivers/) + (7) File system/Generic drivers (fs/, drivers/) (2) Graphics subystem (graphics/) (1) Pascal add-on (pcode/) (0) Documentation (Documentation/) @@ -289,11 +289,6 @@ o File system / Generic drivers (fs/, drivers/) Priority: Low. I have mixed feelings about if NuttX should pay a performance penalty for better data integrity. - Description: FAT: FAT32 is untested -- because I don't have any large - enough devices yet to support a FAT32 FS. - Status: Open - Priority: Medium - Description: The simple SPI based MMCS/SD driver in fs/mmcsd does not yet handle multiple block transfers. Status: Open diff --git a/nuttx/drivers/mmcsd/mmcsd_spi.c b/nuttx/drivers/mmcsd/mmcsd_spi.c index da18cca80..e7f81e16f 100644 --- a/nuttx/drivers/mmcsd/mmcsd_spi.c +++ b/nuttx/drivers/mmcsd/mmcsd_spi.c @@ -1575,7 +1575,6 @@ static int mmcsd_mediainitialize(FAR struct mmcsd_slot_s *slot) result = mmcsd_sendcmd(slot, &g_cmd55, 0); if (result == MMCSD_SPIR1_IDLESTATE || result == MMCSD_SPIR1_OK) { - SPI_SEND(spi, 0xff); result = mmcsd_sendcmd(slot, &g_acmd41, 0); if (result == MMCSD_SPIR1_OK) { @@ -1586,7 +1585,6 @@ static int mmcsd_mediainitialize(FAR struct mmcsd_slot_s *slot) else { fvdbg("%d. Send CMD1\n", i); - SPI_SEND(spi, 0xff); result = mmcsd_sendcmd(slot, &g_cmd1, 0); if (result == MMCSD_SPIR1_OK) { diff --git a/nuttx/fs/fat/fs_fat32util.c b/nuttx/fs/fat/fs_fat32util.c index 16f47727b..7353dee88 100644 --- a/nuttx/fs/fat/fs_fat32util.c +++ b/nuttx/fs/fat/fs_fat32util.c @@ -262,15 +262,20 @@ static inline int fat_path2dirname(const char **path, struct fat_dirinfo_s *diri static int fat_checkfsinfo(struct fat_mountpt_s *fs) { - /* Verify that this is, indeed, an FSINFO sector */ + /* Make sure that the fsinfo sector is in the cache */ - if (FSI_GETLEADSIG(fs->fs_buffer) == 0x41615252 && - FSI_GETSTRUCTSIG(fs->fs_buffer) == 0x61417272 && - FSI_GETTRAILSIG(fs->fs_buffer) == BOOT_SIGNATURE32) + if (fat_fscacheread(fs, fs->fs_fsinfo) == OK) { - fs->fs_fsinextfree = FSI_GETFREECOUNT(fs->fs_buffer); - fs->fs_fsifreecount = FSI_GETNXTFREE(fs->fs_buffer); - return OK; + /* Verify that this is, indeed, an FSINFO sector */ + + if (FSI_GETLEADSIG(fs->fs_buffer) == 0x41615252 && + FSI_GETSTRUCTSIG(fs->fs_buffer) == 0x61417272 && + FSI_GETTRAILSIG(fs->fs_buffer) == BOOT_SIGNATURE32) + { + fs->fs_fsinextfree = FSI_GETFREECOUNT(fs->fs_buffer); + fs->fs_fsifreecount = FSI_GETNXTFREE(fs->fs_buffer); + return OK; + } } return -ENODEV; } @@ -697,7 +702,7 @@ int fat_mount(struct fat_mountpt_s *fs, boolean writeable) ret = fat_checkfsinfo(fs); if (ret != OK) { - goto errout_with_buffer; + goto errout_with_buffer; } }