Problems when reading large files from USB stick.

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Problems when reading large files from USB stick.

跳至解决方案
2,307 次查看
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.

标签 (2)
0 项奖励
回复
1 解答
2,170 次查看
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 项奖励
回复
3 回复数
2,169 次查看
danielchen
NXP TechSupport
NXP TechSupport

Hi Manuel:

Could you please let me know your MQX version?

Regards

Daniel

0 项奖励
回复
2,169 次查看
m4l490n
Contributor V

danielchen@fsl‌ my MQX version is 4.1.1

0 项奖励
回复
2,171 次查看
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 项奖励
回复