Page 1 of 1

Problem With USB MSD application

PostPosted: Tue Jul 29, 2014 9:59 am
by Tight Yorky
Hello,
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.

Regards
T Yorky