FTP/NFS to MSD bridge?

04 Jan 2012

As topic says. Has anyone attempted this, to emulate mass storage device (FAT/FAT32) that was really a remote share? Would it work? How slow would it be?

Regards, David

04 Jan 2012

This is quite tricky, since MSD works on a sector level and FTP works on a file level. Your program would have to emulate a FAT filesystem and substitute remote file data when the corresponding sectors are requested by the host. I guess it's not impossible, but pretty difficult to implement.

04 Jan 2012

Sounds like a challenge. Do you think it would cope with high speed throughput?

04 Jan 2012

Interesting!

On the speed side of things, I think the limiting factor for the implementation of such functionality on a mbed device would be the 12 Mb/sec limit of the full-speed USB connection to provide mass storage functionality to the PC. In theory the ethernet connection should be quite a bit faster than that but if you look around this forum, you will notice that people have had difficulty getting top end performance with decent reliability out of the networking stack on mbed.

I could see how you might be able to implement such a MSD to FTP mapping layer for read-only access to remote files but even then it wouldn't work for an arbitrary remote share. You would be limited to the size of the file system you could simulate and present to the PC since you would need to create a file allocation table and associated directory entries somewhere on the mbed device. With a total of 64K of SRAM available on the device, you would be limited to how big of a file system you could simulate. You could use a SD card to augment the RAM and allow for much larger file system simulations.

I thinks supporting write access on such a device would be pretty complicated. The PC could start writing to random sectors and you wouldn't know if it was doing this to append data to an existing file or creating a new file since the associated directory writes would probably not come until later. I guess you might be able to get it to work if you has a SD card attached to the mbed device so that such writes could be cached there and then pushed out to the remote share once you had enough information to know which writes were associated with which files and at which offsets within those files. You would probably want to make sure that write caching was turned off on the PC for this mass storage device as well so that it doesn't hold onto the FAT and directory sector writes for too long in its cache.