power reset / restart USB Device

q9on8

New Member
Nov 26, 2022
14
1
3
In case a USB device hangs, the virtual machine to which this device is passed through often hangs as well. Is there an easy way, preferably through the Proxmox interface, to restart the device (turn off the USB device power and immediately turn the power back on)? It's just inconvenient to reboot the entire server.
 
This is the ChatGPT`s answer:
TurnOff:::: echo '1-1' | sudo tee /sys/bus/usb/drivers/usb/unbind
TurnOn:::: echo '1-1' | sudo tee /sys/bus/usb/drivers/usb/bind

Another option: Hubpower application.

Since ChatGPT often lies, and the Proxmox server is now far from me, I’m afraid to check the functionality of this method.
 
The commands you've been given by ChatGPT are to turn off/on the drivers for the USB - not what you requested to turn off/on the power.
 
I believe I've resolved the issue with the specific device in my case.


PROXMOX 7.4-18 + E1550 Huawei USB DEVICE REBOOT / RESTART

Code:
add USB DEVICE to VM using UI. Run VM. Make the label in the PROXMOX LOG under ROOT:
# echo "Test log entry $(date)" | tee -a /dev/kmsg
Check the label:
# dmesg | tail -2
>>>>>[73899.039588] Test log entry Mon 03 Jul 2023 10:00:22 PM UTC

STOP VM

Check the logs
# dmesg | tail -30
>>>>[73899.433272] usb 2-2.1: GSM modem (1-port) converter now attached to ttyUSB0
>>>>[73899.457266] usb 2-2.1: GSM modem (1-port) converter now attached to ttyUSB1
>>>>[73899.493275] usb 2-2.1: GSM modem (1-port) converter now attached to ttyUSB2

double check:
# ls /dev/ttyUSB*
/dev/ttyUSB0  /dev/ttyUSB1  /dev/ttyUSB2

another check:
# usb-devices
T:  Bus=02 Lev=02 Prnt=03 Port=00 Cnt=01 Dev#=  7 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=12d1 ProdID=1001 Rev=00.00
S:  Manufacturer=HUAWEI Technology
S:  Product=HUAWEI Mobile
C:  #Ifs= 5 Cfg#= 1 Atr=e0 MxPwr=500mA
I:  If#=0x0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
I:  If#=0x1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
I:  If#=0x2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
I:  If#=0x3 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
I:  If#=0x4 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage


Install minicom and reboot modem with AT-commands

# apt-get install minicom
# minicom -D /dev/ttyUSB0 -b 115200
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
>>>>Welcome to minicom 2.8
>>>>OPTIONS: I18n
>>>>Port /dev/ttyUSB0, 00:00:36
>>>>Press CTRL-A Z for help on special keys


ENTER AT-commands end press Enter:
ATZ
>>>>OK
ATI
>>>>Manufacturer: huawei
>>>>Model: E1550
>>>>Revision: 10.600.00.00.00
>>>>IMEI: 320043000029000
>>>>+GCAP: +CGSM,+DS,+ES

Reboot modem AT-command:
AT+CFUN=1,1
>>>> Cannot open /dev/ttyUSB0!
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>

Press CTRL-A and X after that => for Exit
 
Last edited:
Despite the modem on the host being rebooted, upon VM startup, problematic operation of the passed-through modem from the host to the VM continues to be observed. This is resolved by performing the same reboot using AT commands, but within the VM.
 
In terms of a general solution to the USB reboot issue, this is feasible for specific types of devices. More information can be found by referring to the documentation of the uhubctl application.
 
Your posts appear to be "bot generated" & aren't specific to your problem.

1. How have you accomplished the passthrough of the USB device to your VM?
2. If you don't passthrough the device, does it still "misbehave" in the host?
 
Your posts appear to be "bot generated" & aren't specific to your problem.
Possibly, it is because I am not a native English speaker.

1. How have you accomplished the passthrough of the USB device to your VM?
Through Proxmox UI: Add >> USB device >> "Use USB Vendor/Device ID"
2. If you don't passthrough the device, does it still "misbehave" in the host?
This question is difficult to answer because a Windows application is being used on the VM with the Modem, while the host runs Debian. I do plan to perform a similar check, but on a VM with Linux or FreeBSD instead of the host.


*yes. part of the answer was translated by translators :(
 
Through Proxmox UI: Add >> USB device >> "Use USB Vendor/Device ID"
How about trying the same but with Use USB Port

>>>>[73899.433272] usb 2-2.1: GSM modem (1-port) converter now attached to ttyUSB0 >>>>[73899.457266] usb 2-2.1: GSM modem (1-port) converter now attached to ttyUSB1 >>>>[73899.493275] usb 2-2.1: GSM modem (1-port) converter now attached to ttyUSB2
Does this device (modem?) actually have 3 USB Ports? (USB0, USB1 & USB2).
 
Does this device (modem?) actually have 3 USB Ports? (USB0, USB1 & USB2).
YES. :) AS you can see usb-devices above - this device has "#Ifs= 5" - five interfaces.
 
The USB port changes with each device reboot.
I realize that. But for testing (on same bootup) give it a try. Your problem may be linked to this. You are going to have to passthrough every port/device of the modem.
 
Last edited:
Something else I feel I must point out:

USB passthrough causes a lot of CPU overhead & in addition isn't well suited for all USB devices, like a device that requires a low-latency response, your USB Modem maybe such an example. Bandwidth can also be a game-changer.

Also I believe there is a limit on how many USB's can be passed through to a VM. AFAIK the limit is 5.
 
Last edited:
  • Like
Reactions: q9on8
How about trying the same but with Use USB Port

The same behavior.
It's starting to seem to me that the problem is not only in the hardware. There may be a problem with the GSM operator. I found another modem management application, in it I was able to start interacting with the modem, but I had to choose another GSM operator (roaming).

I suggest we conclude the discussion of the specific case and return to the general topic: "resetting the USB".

What I know now:
  1. A Mikrotik router can reboot a USB port. You can specify the number of seconds without power.
  2. There is an application called uhubctl that allows power control for certain USB hubs. The list of supported devices is provided on its GitHub page.
  3. The USB 2.0 protocol includes the ability to manage power. However, it seems this capability has been lost in newer Linux kernels. Google provides a lot of details on this query: "/sys/bus/usb/devices/usbX/power/control."
  4. There is a device called "mega4 (for Raspberry Pi 4b)" that allows power control through an application and even via the web. But this is not entirely a software solution.
Basically, since I found out that Mikrotik will solve my problems, my interest in trying to solve the problem through software has waned.
 
If you want you could use one of these. Its basically a smart switch (Zigbee) for a usb port. You could then quite easily control the power/port from the server.
 
  • Like
Reactions: q9on8

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!