This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

File System fopen() Problem

I get into this problem. I have a thread that process a message queue. One of my possible action on reception of a message is to open a file with the function fopen(). The file is located on a USB flashdisk and I am opening it with the option "w" :
Logfile = fopen("U:\\Log.txt", "w");

I am using this file for logging. For testing purpose I am entering 200 values coming from ADC and then closing the file.

The first time the message is processed everything is fine. Now , the second time the message is received and process, the fopen() function is stalling for at least a minute then return with success and complete the following processing. I have noticed also that the connect and disconnect detection is not functioning normally too after the first fopen()/fclose().

Any ideas what could be the problem? Anything I need to know when opening, writing and closing a file?

Thank you

  • Which version of the File System are you using?
    What is your target hardware?

  • Hi,

    I am using the version 6.4.0 of the file system. I am working on 3 different boards : STM32F4-Discovery, STM32429i-Eval and MCBST32F400. The media is a 8 GB USB key connected on USB Full Speed port.

  • Hello Keaven,

    I have tried with the following code on the 429I-Discovery board:

    void Thread (void const *argument ) {
      static unsigned int result;
      static FILE *f;
      uint8_t i = 0;
    
      USBH_Initialize (0);
    
      while (1) {
        result = USBH_MSC_DriveMount ("U0:");
        if (result == USBH_MSC_OK) {
          memset(fbuf, ++i, sizeof(fbuf));
          f = fopen ("Test.txt", "w");
          if (f != NULL) {
            LED_On(0);
            fwrite (fbuf, sizeof(fbuf), 1, f);
            fclose (f);
            LED_Off(0);
          }
        }
        osDelay (1);
      }
    }
    


    Everything works as expected. Have you changed anything in the FS_Config_USB_0.h? What are your settings for the thread stacks (Default, Main, Total) in RTX_Conf_CM.c?

    Kind regards,

    Christopher