MFS on USB flash drive - sector not found error

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MFS on USB flash drive - sector not found error

1,236 Views
gorakk
Contributor IV

I am working on a project that is using a USB flash drive.  It saves data to a file one character at a time. 

The system will run fine for some amount of time, writing characters to the flash drive.  At some point though, the write() will result in an MFS_SECTOR_NOT_FOUND error.

I have a test running where a 1000 character string is written to the file on the flash drive every 5 seconds. Different drives will fail after different a number of writes.  Some drives will go for several hours before there is an error and others will fail after a couple of minutes.  Each drive is fairly consistent with how long it will run before it fails.

Below is the code that handles the write.  The file is opened before calling this function.  After all characters are written the file is closed.

void addCharacterToFile( char *c )

{

    uint32_t error = MFS_NO_ERROR;

    if ( filePointer != NULL )

    {

        write( filePointer, c, 1 );

   

        error = _io_ferror( filePointer ); 

       

        if ( MFS_SECTOR_NOT_FOUND == error )

            printf( "sector not found\n" );

        else if ( MFS_NO_ERROR != error )

            printf( "mfs error\n" );

    }

}

Could writing the string to the file one character at a time be part of the problem?  The ability to save data to a flash drive is a change to an existing system - it previously sent this data to a serial port and the code outputs the data one character at a time.  If anyone thinks it would help - I could buffer up some arbitrary number of characters before writing to the flash drive.

Using CodeWarrior 10.5, MQX 4.0, MFS, USB host

0 Kudos
4 Replies

651 Views
asmith
Contributor III

Has any work arround or explanation of this been found ?

I am having pretty much exactly the same problem in MQX 3.8 with a K70.

The problem is totally reproducable.

Though it occurs faster with some USB sticks than others.

0 Kudos

651 Views
gorakk
Contributor IV

David,

Sorry about the delay in responding.

We did not find a workaround or explanation.  We actually put the feature that uses a USB flash drive on hold in our product - we may revisit at some time in the future.

Allen

0 Kudos

651 Views
CarlosCasillas
NXP Employee
NXP Employee

Hi Allen,

Maybe you are getting a Start of Frame (SOF) condition at the same time that an OUT transaction.

Below you can find a tread talking about such condition and a workaround for it:

https://community.freescale.com/thread/320848


Hope this will be useful for you.
Best regards!
/Carlos

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

651 Views
gorakk
Contributor IV

Carlos,

Unfortunately the solution in the linked thread did not solve the issue.

I've created another thread that details what appears to be the same issue when using the HVAC demo:

https://community.freescale.com/thread/323315

Regards,

Allen

0 Kudos