USB MSD failure when Windows host requests a zero-length read

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

USB MSD failure when Windows host requests a zero-length read

698 Views
scottm
Senior Contributor II

I'm not sure which forum this belongs in because at this point I'm not certain what version of the bare metal USB stack this project is using - the comments give a creation date of May 2009 but they also say it's for the HCS08 and this project is running on a Kinetis MK22DX256.

This device implements a USB mass storage device using a SPI flash memory. The project has been around in various forms (starting on Coldfire v1) for several years, but for some reason this K22DX version has started having problems where the Windows host freezes and acts weird when a blank device is plugged in. It's making it hard to do the initial load. This may have actually started happening with a Windows update - I'm not convinced it's something that changed on the device side.

USB packet captures show that things seem to be going off the rails when the host requests a read of LBA 2, but specifies a length of 0 LBAs to read. According to the SCSI specs it's apparently not an invalid command but the document I'm looking at doesn't say what the expected response is. What I'm seeing is that the endpoint stalls. The host then goes into a sequence of trying to reset it and nothing works after that.

As far as I can tell, the zero-length request is not being passed to the application layer. So if an invalid response is happening, it's happening within the USB stack.

Anyone seen this before? Hints on where to look to figure out which version of the stack I'm using? I don't want to replace it blindly because I know it's had some minor modifications made (e.g., the SCSI T10 ID is set to my company's ID) and it'll take some work to move those over. If this is something that's known to be fixed in later versions, though, I'll certainly do that. I'm just trying to understand what's happening and why it didn't happen earlier.

For reference, the last SCSI command block sent by the host is 28 00 00 00 00 02 00 00 00 00 00 00 00 00 00 00, which I interpret as READ(10), rdprotect = 0, DPO = 0, FUA = 0, LBA = 2, group = 0, transfer length = 0.

Thanks,

Scott

0 Kudos
0 Replies