Problem With USB MSD application

Problem With USB MSD application

Postby Tight Yorky » Tue Jul 29, 2014 9:59 am

Had a problem with one of the MChip applications last week while expanding the functionality.
Thought that somebody may benefit from identifying the solution.
Just as a background the application is the internal MSD from MAL (2012). 2012, because this is when the development diverged from the MC library.
The expansion was adding a facility to access the MSD on an RS485 network for logging data and events. A very simple file server. However, during a long period of testing, very rare corruptions were found in the files on the MSD (flash drive). After hours spent testing the communications, the issue was within the MSD layer of the MChip application.

It appears that MChip have chosen to construct the SCSI command responses in the disk buffer rather than implement a separate buffer. I have attached a jpg of the bit of code.
The 'msd_buffer' variable is the 'disk sector buffer' (512/1024/etc) for the flash drive.
I can not call this an error as the application works as it is but falls down when wanting to expand the MSD facility. The references to 'msd_buffer' require changing to a dedicated buffer. After trawling through the code, the buffer size needed to match the Bulk Endpoint Out size (64 bytes in this case). No SCSI responses exceeded this size.
The file corruption was caused by the infrequent USB 'drive status' requests from the host coinciding with a 'flash disk' write from the network.

T Yorky
part of MChip usb_function_msd_c
Post_BufferUsage.jpg (143.48 KiB) Viewed 1248 times
Tight Yorky
Posts: 22
Joined: Thu Jun 19, 2014 10:32 pm
PIC experience: Professional 2-5 years with MCHP products

Return to USB

Who is online

Users browsing this forum: No registered users and 1 guest