USB-Serial, Mass Storage and More
As promised, I managed to finish the USB-Serial CDC example for the MyUSB project yesterday, with the new code uploaded. I urge all current MyUSB users (I know you’re out there, somewhere!) to re-download the latest library version. It’s a drag-drop affair – simply replace your existing MyUSB library folder with the latest one and you’ll get all the new code improvements with no compatibility issues.
Today I spent a little while trying to implement the Mass-Storage class into a new demo. That’s partially complete, with the Bulk-Only transport code done, with the SCSI decoder and dataflash driver remaining to write. During the coding of the Bulk-Only implementation I realized I had made some errors in the GetFeature and ClearFeature standard device command requests, which I’ve since corrected – so please update your library version!
Finding the correct SCSI document outlining the different commands has been a nightmare, but I think I now have the correct one. It looks quite daunting to be honest, so I’m going to start with the dataflash driver first and worry about the SCSI transport decoder last. The dataflash driver, after much internal deliberation, will be designed specifically for the dataflash used in the USBKEY – this helps keep the code as tight as possible. I may provide a generic driver at a later date, capable of addressing all the dataflash members of a single dataflash family.
Also done today was proper testing of the Mouse Host example. I’ve had issues in the past with the current draw from the peripherals causing VBUS dips, resulting in the inability to fully test the host examples. I’ve now managed to shoe-horn my regulated 12V power supply into the board, saving my unregulated 12V supply to power the STK500, which is currently itself powering my DB101 board for diagnostics.
Having a proper power supply hilighted an issue with the mouse example; while my USB keyboard would work without a hitch (obviously throwing a “invalid protocol” error when used with the mouse host example) plugging in a mouse would cause continuous device connections and disconnections. Further debugging showed that the host state machine was erroring out when performing the 100ms delay after creating the host control pipe to suit the peripheral. Oddly enough, the mouse was returning a STALL request in response to nothing more than the generation of the USB frames, with no control data being sent.
Fixing the problem just became a matter of ignoring the error condition of the 100ms wait command after the host control pipe creation. I’ve no idea of the reason behind the stall, but my solution fixes the problem perfectly.
Eventually, once the mass-storage code is finished, I will be re-visiting the host demos, and flesh them out some more. Currently much of the device implementation is assumed, rather than being determined by the returned device descriptors. I want to eventually code in a host API specifically designed to manipulate the returned descriptors from a device.
If anyone has a list of the valid standard SCSI commands in a formatted and collated electronic form, I’d love to hear from you. Re-typing all the commands and command codes from the SCSI specification I have looks to be quite tedious and time consuming.
Lastly, to make the library more complete, I’ve implemented support for multiple configurations. This removes the very last of the hard-coded values in the library which couldn’t be altered in the end-application – now a device may have more than one configuration, with the appropriate configuration descriptor being returned according to the given index.

Loading...