The thread may drop in geeks chat. We have to come back from the "dark room" :-)
I suggest you two options for the Microchip Host MSC stack.
1) Multi-sector read/write
Microchip's FAT system (MDD File System\FSIO.c) always issues single sector read/write, for simplicity. But for greater transfer size, more than two sectors at a time, and for contiguous sector allocation on the media, multi-sector read/write in single READ10/WRITE10 reduces the protocol overhead. For 512 bytes/sector file system, the sectors in a cluster are allocated in contiguous, at least.
Therefore, I recommend you to modify Microchip FSIO to support multi-sectors (hard), or to replace it to another FAT system (easier). Fortunately, ChaN's FatFs supports multi-sector. Marc Coussement has implemented FatFs on top of Microchip host MSC.
ChaN's FatFs http://elm-chan.org/fsw/ff/00index_e.html
FatFs on Microchip host MSC by Marc Coussementhttp://www.microchip.com/forums/fb.ashx?m=501402
Marc has implemented it fine. But maybe, he didn't like to touch to Microchip original code so much. disk_read()/ disk_write() (fatfs_usb.c) repeatedly call single sector read/write routines of the stack (USBHostMSDSCSISectorRead() / USBHostMSDSCSISectorWrite()). To get better performance, modify USBHostMSDSCSISectorRead() / USBHostMSDSCSISectorWrite() directly for multi-sector read/write, too. It's easy.
- Copy USBHostMSDSCSISectorRead() / USBHostMSDSCSISectorWrite() (usb_host_msd_scsi.c) and rename them for new functions of multi-sector read/write
- Add a parameter of sector count to the copied functions
- Assign the sector count to commandBlock (Number of blocks) for READ10/WRITE10
commandBlock = count;
- Increase the dataLength parameter of USBHostMSDRead() - for CBW
errorCode = USBHostMSDRead( deviceAddress, 0, commandBlock, 10, dataBuffer, mediaInformation.sectorSize * count);
- Replace the loop in disk_read()/disk_write() with these new functions.
With this mods, you'll get better speed performance on read/write for the size of more than two sectors.
2) Bus scheduling improvement
For quick and dirty implementation,
_USB_FindNextToken() (usb_host.c) traverses the schedule list, and it puts new transaction on the bus. You may need to disable USB interrupt around this extra call.
void start_bulk_transfer_ASAP( void )
#if defined( __C30__ )
#elif defined( __PIC32MX__ )
interrupt_mask = U1IE; // guard from USB interrupt
U1IE = 0;
usbBusInfo.flags.bfBulkTransfersDone = 0;
usbBusInfo.lastBulkTransaction = 0;
U1IE = interrupt_mask; // recover USB interrupt
The calls to this function are inserted just after every USBHostRead() and USBHostWrite() call on usb_host_msd.c
- in USBHostMSDTasks() STATE_RUNNING - SUBSTATE_SEND_CBW case
- in USBHostMSDEventHandler() STATE_CBW_WAIT and STATE_TRANSFER_WAIT cases
I believe these mods improve the speed performance 3-4 times. But not for 10 times, as you expect.