cancel
Showing results for 
Search instead for 
Did you mean: 

STM32Cube FatFS USB disk Problem

jowen
Associate II
Posted on December 07, 2015 at 17:13

Hi have a SRAM Disk working using FATFS and USB. I can read and write files to the disk from my processor (STM32f427zit)  but the files do not get updated in windows explorer on the PC. If if unplug the USB and then plug it back in I get to see all the log files i have created, but then no new ones get added and again I have to unplug it and plug it in again - I guess it so something simple but I can't find it

  if(FATFS_LinkDriver(&SRAMDISK_Driver, SRAMDISK_Path) == 0)

  {

    if(f_mount(&RAMDISKFatFs, (TCHAR const*)SRAMDISK_Path, 0) == FR_OK)

    {

      f_mkfs((TCHAR const*)SRAMDISK_Path, 0, 0);

    }    

  }    

  while(1)

  {

....

    sprintf(FileName,''LPD%d.csv'',Cnt);

     if (f_open(&NewFile, FileName, FA_CREATE_ALWAYS | FA_WRITE) == FR_OK)

     {

       for (i=0; i<2000; i+=4)

        {    

             sprintf(DataStr,''%d,'',(short)(DMACodecData[i+1]<<8)+DMACodecData[i]);

            err=f_write(&NewFile, DataStr, sizeof(DataStr), (void *)&byteswritten);

            if (err!=FR_OK)

          {

             sprintf(LcdBuffer, ''Failed %d'',err);

             WriteXYLcd(0,3,LcdBuffer);

         }

         if (byteswritten!=sizeof(DataStr))

         {

             sprintf(LcdBuffer, ''full %d'',byteswritten);

            WriteXYLcd(0,4,LcdBuffer);

         }

        }

        f_close(&NewFile);

     }    

.....

  }

Thanks for any Ideas.
1 REPLY 1
Posted on December 07, 2015 at 17:20

Wouldn't that be because there are cache coherency issues? If you are changing the content of the disk you will need to propagate that up the chain, probably by using a MEDIUM CHANGED type of sense code on the first READ/WRITE that occurs after you alter the the file system and it's structures.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..