ARMmbed / mbed-os

Arm Mbed OS is a platform operating system designed for the internet of things
https://mbed.com
Other
4.67k stars 2.98k forks source link

USB device disconnect & delete doesn't cleanup (FRDM-KL25Z) #225

Closed larsgk closed 10 years ago

larsgk commented 10 years ago

We are in a situation, where we would like to bring down the USBSerial device and bring it up again with a different VID/PID. However, it seems that just calling disconnect and delete on the USBSerial object (followed by a new object construction) is not enough. We have even tried with a 2 sec delay between all calls.

example:

USBSerial* serial = new USBSerial(OLDVID, OLDPID, 0x0001, false); ... serial->disconnect(); delete serial; serial = new USBSerial(NEWVID, NEWPID, 0x0001, false);

The result in dmesg is:

[83207.507577] usb 1-1.2: new full-speed USB device number 52 using ehci-pci
[83207.601690] usb 1-1.2: New USB device found, idVendor=xxOLDVIDxx, idProduct=xxOLDPIDxx
[83207.601701] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[83207.601707] usb 1-1.2: Product: CDC DEVICE
[83207.601711] usb 1-1.2: Manufacturer: mbed.org
[83207.601716] usb 1-1.2: SerialNumber: 0123456789
[83207.602476] cdc_acm 1-1.2:1.0: ttyACM3: USB ACM device
[83208.076002] usb 1-1.2: USB disconnect, device number 52
[83212.109597] usb 1-1.2: new full-speed USB device number 53 using ehci-pci
[83212.181370] usb 1-1.2: device descriptor read/64, error -32
[83212.357118] usb 1-1.2: device descriptor read/64, error -32
[83212.533016] usb 1-1.2: new full-speed USB device number 54 using ehci-pci
[83212.604863] usb 1-1.2: device descriptor read/64, error -32
[83212.780560] usb 1-1.2: device descriptor read/64, error -32
[83212.956277] usb 1-1.2: new full-speed USB device number 55 using ehci-pci
[83213.363562] usb 1-1.2: device not accepting address 55, error -32
[83213.435790] usb 1-1.2: new full-speed USB device number 56 using ehci-pci
[83213.842899] usb 1-1.2: device not accepting address 56, error -32
[83213.843300] hub 1-1:1.0: unable to enumerate USB device on port 2
logxen commented 10 years ago

You need to use the USB soft-connect feature to disable the pull-up on the USB lines for at least a second. This makes it a appear to the host that the device was disconnected and reconnected and so it will be re-enumerated. This might take adding some extra hardware to your schematic, specifically a fet or transistor to control the pull-up.