Problems when reading large files from USB stick.

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

Problems when reading large files from USB stick.

Jump to solution
1,901 Views
m4l490n
Contributor V

I'm facing problems when reading large files. I have some code that copies one file from a USB stick to an SD Card. But I'm facing issues when copying large files, larger than 10MB. Here is how I'm doing it:

  1. I open the file I want to copy in the "source" media as "r"
  2. I open a file on the "dest" device with attributes as "wb"
  3. I allocate an 8192 byte buffer that is the one I will use for reading from the source file and writing to the destination file.
  4. I read 8192 bytes from the source file and write them to the destination file. I do this as many times as bytes there are.

Everything goes well for the first couple of megs, but then randomly, the "read" function returns 0 and the source device stops responding, even when I close the file and try to open it again. I have done this copying successfully with files under 10 MB but it doesn't work with files larger than that. I'm reading from USB and immediately writing to the SD Card without interruption or delays, I don't know if I need to introduce a delay in between read and write or something.

What I'm trying to know if this is the correct way of doing it, just opening both files, read from one and write to the other. I mean, it works just fine for files up to 10MB so I'm not sure.

Labels (2)
0 Kudos
1 Solution
1,764 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Manuel:

This is an MFS filesystem issue, and fixed in MQX 4.2, and patch 4.2.0.2.  Please refer to the attached release notes for the MFS bug fix.

I would suggest you update to MQX 4.2.0 + patch if possible.

Or you can try to merger the new MFS part to your project.

Regards

Daniel

View solution in original post

0 Kudos
3 Replies
1,763 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Manuel:

Could you please let me know your MQX version?

Regards

Daniel

0 Kudos
1,763 Views
m4l490n
Contributor V

danielchen@fsl‌ my MQX version is 4.1.1

0 Kudos
1,765 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Manuel:

This is an MFS filesystem issue, and fixed in MQX 4.2, and patch 4.2.0.2.  Please refer to the attached release notes for the MFS bug fix.

I would suggest you update to MQX 4.2.0 + patch if possible.

Or you can try to merger the new MFS part to your project.

Regards

Daniel

0 Kudos