USB Host MSD and working with files > 512 Bytes

08 Mar 2012

Hi -

I've been trying to make a very basic function that takes the contents of a file from a USB flash drive and turns the file into HEX/text for sending over a serial link (eg UART)

As a test, I've tried copying the file, a JPG image file to a Text file. When I host the image file, a 125kB file, in the MBED's LocalFileSystem, the conversion works flawlessly. I effectively can use fgetc and fputc for the entire file.

But - My issue is this:

When I am using MSCUsbHost, I am only able to read 4096 bits/512 bytes - which I'm pretty sure is the first block of the flash drive - and nothing more using fread before I get to an EOF. Is it possible to read files using fread and write them using fwrite on USB mass storage devices?

08 Mar 2012

Solved!

My system was grabbing a different file than expected - which was only 512 kbytes!

Sorry!