Correct Method to Reset USB?

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm using a UC3A3 and trying to jump between two different USB setups. Both are MassStorage Class devices, but one will identify as a "block device" (typical read/write drive) and the other will identify as a CD-ROM. I'm switching between states based on a SCSI command, START STOP UNIT, which is typically used to stop and eject a SCSI device.

Since both instances are MSC I believe I can leave the USB descriptors alone, and only change the SCSI INQUIRY response. I'm not sure how to reset the USB interface to force the host to completely re-enumerate the USB device though. I'm using ASF 2.8.1, and basing my project off of a modify USB Device MSC Example (EVK1104).

I've discovered some functions such as udc_reset() or udc_detach(), but they don't seem to actually completely reset the USB interface, the host doesn't appear to be re-enumerating the USB device. Are there other functions I should be looking at?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi iwoloschin.

I have just asked a very similar question, although Im trying to switch to the DFU USB setup from the CDC used in my application.

If you get an answer I would really appreciate it as well.

Good luck and if I find out anything I will let you know too.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You're in luck! I found what appears to be a working solution, though I hesitate to call it "the right way" until someone else can verify it. Also, this was tested with ASF 2.8.1, but I don't believe the USB code has changed significantly in the 2.X branch.

All I did (I think, my code isn't in front of me at the moment) is:

udc_detach();
udc_stop();
udc_start();
udc_attach();

That seems to successfully force the USB host to re-enumerate the device.

!! CAVEAT !!

I'm switching between two Mass Storage Class devices, so my USB descriptors are (as of now) remaining exactly alike, my devices are only different in the SCSI transport layer. If you're swapping between different USB classes I suspect you'll need to do something between the udc_stop & udc_start, but I haven't explored this yet.

Also somewhere to look may be the USB DFU Appnote, I don't remember the number offhand, but it's mentioned fairly regularly in here.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi iwoioschin

Thanks for the update, but you guessed right, as I am changing USB classes this does not work for me. Interesting though is that it appears that the USB shuts down OK, as the device disappears from the OS, its just that the bootloader USB doesn't then enumerate and appear.

I suspect I'm pushing a loosing cause with it at this time.

Thanks again for your help.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Bummer. I wonder if you need to do something with a "composite" device but only have one device ever active, swapping when you disable the USB device.