Connect USB device via Terminal?

Discussions about using Linux guests in VirtualBox.

Connect USB device via Terminal?

Postby El Loco » 1. Jun 2015, 22:13

Hi,

I do a lot of Android hardware development and to do this I frequently upload a modified library to my device, and then reboot it so it will load. Long story short, this drops the connection to the device, so after the device boots, I have to click "Devices->USB Devices->Android [0228]". I have to do this hundreds of times per day and it's really annoying!

Is there any command I could issue via a command prompt (Terminal) to connect to this USB device?

Thanks!
El Loco
 
Posts: 4
Joined: 29. Apr 2015, 21:28

Re: Connect USB device via Terminal?

Postby Perryg » 1. Jun 2015, 23:15

You can always create a filter for it in the guest settings and it will always be attached when the guest is running.

Or if you really want the command line

Code: Select all   Expand viewCollapse view
VBoxManage controlvm  <uuid|vmname>  usbattach <uuid>|<address> |


By the way you can see all of the VBoxManage commands in your users guide.
Perryg
Site Moderator
 
Posts: 34373
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Connect USB device via Terminal?

Postby El Loco » 2. Jun 2015, 00:46

Thank you! Appreciate it. But, how do I get the uuid or address? If I do "VBoxManage list usbhost", it says "<none>". However I am definitely connected - the Devices->USB Devices->Android [0228] is checked, and I can successfully execute "adb devices" or "adb shell".

I've actually tried creating a filter, several times, but it causes the device to be considered attached when it is not.

For instance, if I do:
Code: Select all   Expand viewCollapse view
adb root

VirtualBox will show the device as connected, but adb devices will list nothing. I will not be able to shell into the device.

Worse, if I reflash the device (which causes it to become "Android [0100]" instead of "Android [0228]" until the flash is complete), the filter will cause the USB device to be permanently in use or something...I forget the exact error. At that point, the only solution is to restart VirtualBox entirely.
El Loco
 
Posts: 4
Joined: 29. Apr 2015, 21:28

Re: Connect USB device via Terminal?

Postby Perryg » 2. Jun 2015, 00:51

I honestly can't say. I don't have an android device. Perhaps someone else will. I was just answering your original question on how to attach it.
Perryg
Site Moderator
 
Posts: 34373
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Connect USB device via Terminal?

Postby El Loco » 2. Jun 2015, 01:00

OK, I understand. I'm not sure why the filters don't work, but the VBoxManage would be a great workaround.

Still a little stuck with the VBoxManage method though. I did find the Android USB uuid by running VBoxManage in my Windows host. I also found the uuid of the VM.

Then, in my Ubuntu guest, I tried:
Attempt 1:
Code: Select all   Expand viewCollapse view
VBoxManage controlvm usbattach f9d3e8f8-a909-40e1-96c2-5de68af5cfde
VBoxManage: error: Could not find a registered machine named 'usbattach'
VBoxManage: error: Details: code VBOX_E_OBJECT_NOT_FOUND (0x80bb0001), component VirtualBox, interface IVirtualBox, callee nsISupports
VBoxManage: error: Context: "FindMachine(Bstr(a->argv[0]).raw(), machine.asOutParam())" at line 95 of file VBoxManageControlVM.cpp


Attempt 2: Here I also provided my VM uuid
Code: Select all   Expand viewCollapse view
VBoxManage controlvm  71be104f-530c-4c74-b546-3bb16fc35931 usbattach f9d3e8f8-a909-40e1-96c2-5de68af5cfde
VBoxManage: error: Could not find a registered machine with UUID {71be104f-530c-4c74-b546-3bb16fc35931}
VBoxManage: error: Details: code VBOX_E_OBJECT_NOT_FOUND (0x80bb0001), component VirtualBox, interface IVirtualBox, callee nsISupports
VBoxManage: error: Context: "FindMachine(Bstr(a->argv[0]).raw(), machine.asOutParam())" at line 95 of file VBoxManageControlVM.cpp
El Loco
 
Posts: 4
Joined: 29. Apr 2015, 21:28

Re: Connect USB device via Terminal?

Postby Perryg » 2. Jun 2015, 01:01

VBoxManage is operated from the host. You can't use it in the guest.
Perryg
Site Moderator
 
Posts: 34373
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX


Return to Linux Guests

Who is online

Users browsing this forum: No registered users and 25 guests