Write directly to usb flash device instead of using MFS

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

Write directly to usb flash device instead of using MFS

1,748 次查看
njk909
Contributor II

I am currently mounting MFS to this USB NAND flash device:

http://www.swissbit.com/images/stories/pdfs/flash/universalserial/U-110_data_sheet_UI-xxBP_Rev120.pd...

Due to file system corruption issues with FAT, I want to just seek/read/erase/write directly to the blocks on the flash device without using a file system.

Are there any examples that show how to do this?  Would I use the nandflash driver?  I am using MQX 4.1 on MCF52259.

标签 (1)
0 项奖励
回复
4 回复数

1,495 次查看
RadekS
NXP Employee
NXP Employee

Unfortunately I don’t have experience with such device.

I am not sure whether I understood correctly. Could you please clarify whether….

You mean, that you successfully used MFS on top of this device and you want read device directly because FAT table was accidentally damaged and you want save some data from flash?

Or you mean that there is some issue in MFS or device and you cannot implement MFS on top of this flash device? Could you please give us more details in this case?

I first case, shouldn’t be more simply connect device to PC and use dedicated tools?

Anyway seek/read/write functions are standard POSIX functions you can use it instead of installing MFS.

Please look at directory:

c:\Freescale\Freescale_MQX_4_1\mqx\source\fio\..

Erase function you have to implement your way.


Have a great day,
RadekS

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

0 项奖励
回复

1,495 次查看
njk909
Contributor II

I've used MFS directly over the USB flash device with the partition manager.  Our application requires writing to the flash drive every 20ms, and over the course of several days, the FAT filesystem always becomes corrupted due to inadvertent power cycles, etc...

We need a more robust way to write data to the USB flash drive, so I would like to bypass the FAT filesystem (MFS), and just write binary data directly to the flash drive.

0 项奖励
回复

1,495 次查看
RadekS
NXP Employee
NXP Employee

Thank you for clarification. Now it is clear.

You are right FAT file system isn’t enough robust against inadvertent power cycles.

There is one/two additional chance(s), but it is not 100% solution.

The main problem is that FAT table is hold in RAM and FAT table may not be updated directly after write. We have to flush for force MFS to store FAT table. There are two options:

  1. You can flush after every write. This could be good (simply) solution in case when you periodically write just small amount of data.
  2. You can use low voltage interrupt for warning against power down. I can see potential problem in case when you write some bigger piece of data (we should wait for IO operation end after that flush). Main problem is here in enough energy for emergency shutdown (by capacitors, inductances)…

Of course, in both cases we should somehow manage, that new additional MFS access will not be executed after low voltage interrupt (power down)…

0 项奖励
回复

1,495 次查看
njk909
Contributor II

I am currently flushing after every write, and we will be adding supercaps to give us time to finish writes in the event of a sudden power loss.  The main problem we are having is there seems to be some kind of bug within the USB stack or MFS that is causing USB flash drives to randomly detach mid-write after many hours of continuous writing.  This causes corruption to occur.

Is there a way to write directly to the USB flash drive without using the MFS filesystem?  We are basically just using it to store data from sensors, so I can just treat the whole flash drive as a big cyclic buffer.

0 项奖励
回复