USB Issues

Post Reply
mdilalo
Posts: 22
Joined: Fri Mar 11, 2016 6:33 am
languages_spoken: english
ODROIDs: X2+, C2, Vu7
Has thanked: 0
Been thanked: 0
Contact:

USB Issues

Unread post by mdilalo » Wed May 11, 2016 4:37 am

I am using a C2 with a VU7 and am having trouble when multiple USB devices are connected at once.

It seems that this is a known bug with Android 5.0 where only the last UsbDevice returned from UsbManager.getDeviceList() method has the correct UsbInterface count.

https://code.google.com/p/android/issue ... &id=159897

This issue has a simple fix though so I am hoping it can make it in to version 1.5 as soon as possible.

Code: Select all

diff --git a/core/java/android/hardware/usb/UsbDevice.java b/core/java/android/hardware/usb/UsbDevice.java
index d90e06e..c693af1 100644
--- a/core/java/android/hardware/usb/UsbDevice.java
+++ b/core/java/android/hardware/usb/UsbDevice.java
@@ -283,7 +283,7 @@ public class UsbDevice implements Parcelable {
             String manufacturerName = in.readString();
             String productName = in.readString();
             String serialNumber = in.readString();
-            Parcelable[] configurations = in.readParcelableArray(UsbInterface.class.getClassLoader());
+            Parcelable[] configurations = in.readParcelableArray(UsbConfiguration.class.getClassLoader());
             UsbDevice device = new UsbDevice(name, vendorId, productId, clasz, subClass, protocol,
                                  manufacturerName, productName, serialNumber);
             device.setConfigurations(configurations);
Although the C2 has four USB ports, only one of them will function correctly until this issue is resolved.

User avatar
odroid
Site Admin
Posts: 33357
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 392 times
Been thanked: 457 times
Contact:

Re: USB Issues

Unread post by odroid » Wed May 11, 2016 10:47 am

Do you connect multiple USB storages?
What USB devices did you connect to C2?

User avatar
odroid
Site Admin
Posts: 33357
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 392 times
Been thanked: 457 times
Contact:

Re: USB Issues

Unread post by odroid » Wed May 11, 2016 4:31 pm

We plugged two USB memory sticks and a USB sound card.
All of them worked well. So we need to know your test conditions.

mdilalo
Posts: 22
Joined: Fri Mar 11, 2016 6:33 am
languages_spoken: english
ODROIDs: X2+, C2, Vu7
Has thanked: 0
Been thanked: 0
Contact:

Re: USB Issues

Unread post by mdilalo » Wed May 11, 2016 11:04 pm

I believe USB devices used for storage, standard input (keyboard, mouse, etc.), etc. are handled by Android itself. In my case, I have the VU7 and a Suprema BioMini fingerprint reader connected. Their Android API requires a reference to the device's UsbInterface which I can not obtain via the UsbManager.

If you follow the steps in the issue I linked to above, you should see the same behavior where only the last device in the list has one or more UsbInterfaces.

To be sure this is the case, I disconnected the VU7 and used a standard HDMI monitor with a keyboard & mouse and there were no issues.

Most Android devices only have one usb port and not many applications make use of more than one device anyway so it's not a very high priority bug for them to fix. For a device like the C2 though, it severely limits its capabilities as only 1/5 of the USB ports currently function properly.

User avatar
odroid
Site Admin
Posts: 33357
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 392 times
Been thanked: 457 times
Contact:

Re: USB Issues

Unread post by odroid » Thu May 12, 2016 9:48 am

I see. We will try to test our USB IO board which uses the standard Android USB host APIs.
http://odroid.com/dokuwiki/doku.php?id= ... or_android
Is it a right way to test your patch?

mdilalo
Posts: 22
Joined: Fri Mar 11, 2016 6:33 am
languages_spoken: english
ODROIDs: X2+, C2, Vu7
Has thanked: 0
Been thanked: 0
Contact:

Re: USB Issues

Unread post by mdilalo » Thu May 12, 2016 10:53 pm

I think that should work.

If you'd like an easier way to test it out, I've created a simple app which lists the attached USB devices and the number of Interfaces they provide. Each device should return one or more interfaces but as seen in the screenshot, only the last one returns the correct data. (Due to an issue with the code for parcelling the UsbDevice class)

The demo app is available here: https://drive.google.com/file/d/0B-Y9NV ... sp=sharing

(Please disregard the comments about UFA_FindDevice as it was directed to the engineering team at Suprema)
Attachments
Screenshot_1970-01-01-00-07-06.png
Screenshot of demo app with a VU7, Suprema BioMini Fingerprint Reader, and a SanDisk USB drive plugged in to the C2.
(21.48 KiB) Downloaded 1511 times

User avatar
odroid
Site Admin
Posts: 33357
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 392 times
Been thanked: 457 times
Contact:

Re: USB Issues

Unread post by odroid » Fri May 13, 2016 8:46 am

We've merged your patch.
Please try V1.5 and let us know the result.
http://odroid.com/dokuwiki/doku.php?id= ... _note_v1.5

mdilalo
Posts: 22
Joined: Fri Mar 11, 2016 6:33 am
languages_spoken: english
ODROIDs: X2+, C2, Vu7
Has thanked: 0
Been thanked: 0
Contact:

Re: USB Issues

Unread post by mdilalo » Mon May 16, 2016 10:38 pm

Wow, that was fast. Thank you for your quick and effective technical support.

I'll try out the new version and report back ASAP.

mdilalo
Posts: 22
Joined: Fri Mar 11, 2016 6:33 am
languages_spoken: english
ODROIDs: X2+, C2, Vu7
Has thanked: 0
Been thanked: 0
Contact:

Re: USB Issues

Unread post by mdilalo » Tue May 17, 2016 10:19 pm

Unfortunately, it seems this didn't resolve the issue.

I plugged two usb devices (the VU7 and the BioMini Slim) into different USB ports a few times and ran the sample app I posted above.

The results showed that each time, only one device returned the correct number of interfaces while the rest return 0. Here are a couple of screenshots taken after switching which ports the devices were plugged in to:
Screenshot_1970-01-01-00-07-48.png
VU7 returns 1 interface, BioMini Slim returns 0 interfaces
(18.68 KiB) Downloaded 1445 times
Screenshot_1970-01-01-00-07-31.png
VU7 returns 0 interfaces, BioMini Slim returns 1 interface
(18.25 KiB) Downloaded 1445 times
One interesting effect your patch had was that the device which includes the correct number of interfaces isn't always the last one returned from UsbManager.getDeviceList() now.

I really don't know where to go from here and would very much appreciate any help you may be able to offer. This seems to be a problem in the Android source code so it's not a problem specific to ODROID devices but it obviously is a significant issue when trying to use more than one USB device in this way.

Also, just in case there was an issue accessing the example app I posted earlier, I put it up on dropbox as well: https://www.dropbox.com/s/pswnwkr6awyv4 ... p.zip?dl=0
Here is the relevant code snippet to see this behavior:

Code: Select all

UsbManager manager = (UsbManager) getSystemService(Context.USB_SERVICE);

// This is the function to get all USB Devices which appears to be the problem
HashMap<String, UsbDevice> deviceList = manager.getDeviceList();
int deviceNum = 1;

// Prints out the device info as well as the returned interface count
for (UsbDevice device : deviceList.values()) {
    deviceText.append("Device #" + deviceNum + "\n");
    deviceText.append("  Vendor ID:  " + device.getVendorId() + "\n");
    deviceText.append("  Product ID: " + device.getProductId() + "\n");
    deviceText.append("  Interface Count: " + device.getInterfaceCount() + "\n\n");
    deviceNum++;
}

User avatar
odroid
Site Admin
Posts: 33357
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 392 times
Been thanked: 457 times
Contact:

Re: USB Issues

Unread post by odroid » Wed May 18, 2016 9:31 am

What happens if you connect the BioMini sensor to the USB otg port via a host adapter like this?
http://www.hardkernel.com/main/products ... 0193470720

mdilalo
Posts: 22
Joined: Fri Mar 11, 2016 6:33 am
languages_spoken: english
ODROIDs: X2+, C2, Vu7
Has thanked: 0
Been thanked: 0
Contact:

Re: USB Issues

Unread post by mdilalo » Wed May 18, 2016 10:04 pm

With the BioMini Slim plugged in to the OTG port, I tried plugging the Vu7 in to each of the four USB ports.

The result was the same for each. The Touchscreen returned 1 interface and the BioMini Slim returned 0 interfaces.

Likewise, when I plugged the Vu7 in to the OTG port and the BioMini Slim in to each of the regular USB ports, the BioMini Slim returned 1 interface and the Vu7 returned 0.

I'm headed overseas on Sunday to demonstrate a few prototypes and was hoping this could be sorted out by then but at this point, I don't think I'd have time to design and print the enclosures if forced to use the OTG port for the BioMini Slim anyway. I assume others would eventually run in to the same issue though when using multiple USB devices in this way so I'm happy to help you figure out what the cause of this is in any way I can.

Can you confirm that the code snippet I posted above yielded similar results on your end? I have tried several different USB devices and it appears to exhibit the same symptoms for all devices running Android 5.0+. The folks at Suprema weren't able to reproduce the bug but I think that was because they were using an Android 4.4 device.

User avatar
odroid
Site Admin
Posts: 33357
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 392 times
Been thanked: 457 times
Contact:

Re: USB Issues

Unread post by odroid » Thu May 19, 2016 10:53 am

When we connected webcam, mouse ,keyboard, USB-IO board and Vu7 to C2, all of them worked well.
I don't know how to reproduce the issue without the BioMini Slim.

mdilalo
Posts: 22
Joined: Fri Mar 11, 2016 6:33 am
languages_spoken: english
ODROIDs: X2+, C2, Vu7
Has thanked: 0
Been thanked: 0
Contact:

Re: USB Issues

Unread post by mdilalo » Thu May 19, 2016 10:22 pm

Can you confirm that you are seeing one or more interface per device when you call the UsbManager.getDeviceList() function?

mdilalo
Posts: 22
Joined: Fri Mar 11, 2016 6:33 am
languages_spoken: english
ODROIDs: X2+, C2, Vu7
Has thanked: 0
Been thanked: 0
Contact:

Re: USB Issues

Unread post by mdilalo » Thu May 19, 2016 11:35 pm

I got a little worried when you said you couldn't reproduce the issue so I ran some tests myself to be sure.

I used a new C2, Vu7, Suprema SFU-S20 (BioMini Slim), and some other USB devices (thumb drive, keyboard, mouse, etc.)

I loaded V1.5 on to the C2 and ran my example app. This is the result:
Screenshot_1970-01-01-00-02-32.png
(30.42 KiB) Downloaded 1403 times
As shown before, only one device returned by the UsbManager.getDeviceList() method has the correct number of interfaces. If you're seeing something different, then I am really confused because I'm seeing the same behavior with a completely new set of hardware.

According to the Android documentation, "Each device contains one or more UsbInterfaces, each of which contains a number of UsbEndpoints (the channels via which data is transmitted over USB)."

That's not what we're seeing here so there's definitely an issue.

User avatar
odroid
Site Admin
Posts: 33357
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 392 times
Been thanked: 457 times
Contact:

Re: USB Issues

Unread post by odroid » Fri May 20, 2016 11:01 am

I meant the devices were worked(functionally) well.
I don't understand how UsbManager.getDeviceList() API works.

mdilalo
Posts: 22
Joined: Fri Mar 11, 2016 6:33 am
languages_spoken: english
ODROIDs: X2+, C2, Vu7
Has thanked: 0
Been thanked: 0
Contact:

Re: USB Issues

Unread post by mdilalo » Mon May 23, 2016 1:46 am

It's explained in the link I provided in the previous post.

The function is not returning UsbDevice objects with one or more UsbInterface as is described in the Android documentation. At a minimum I think this should be included in the known issues list as it means the device's USB Host functionality is limited.

mdilalo
Posts: 22
Joined: Fri Mar 11, 2016 6:33 am
languages_spoken: english
ODROIDs: X2+, C2, Vu7
Has thanked: 0
Been thanked: 0
Contact:

Re: USB Issues

Unread post by mdilalo » Thu May 26, 2016 12:18 am

Any updates on this? We were hoping to demonstrate some prototypes running on the C2 next week as part of a larger proposal but this bug breaks our solution.

User avatar
odroid
Site Admin
Posts: 33357
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 392 times
Been thanked: 457 times
Contact:

Re: USB Issues

Unread post by odroid » Thu May 26, 2016 10:53 am

We have no idea why it doesn't report the correct numbers even we already applied your patch.
Can you try to connect the BioMini Slim to the OTG port via otg-to-host adapter like this?
http://www.hardkernel.com/main/products ... 0193470720

mdilalo
Posts: 22
Joined: Fri Mar 11, 2016 6:33 am
languages_spoken: english
ODROIDs: X2+, C2, Vu7
Has thanked: 0
Been thanked: 0
Contact:

Re: USB Issues

Unread post by mdilalo » Thu May 26, 2016 10:29 pm

Yes, I tried that back on May 18th and shared the results here.

mdilalo wrote:With the BioMini Slim plugged in to the OTG port, I tried plugging the Vu7 in to each of the four USB ports.

The result was the same for each. The Touchscreen returned 1 interface and the BioMini Slim returned 0 interfaces.

Likewise, when I plugged the Vu7 in to the OTG port and the BioMini Slim in to each of the regular USB ports, the BioMini Slim returned 1 interface and the Vu7 returned 0.

User avatar
odroid
Site Admin
Posts: 33357
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 392 times
Been thanked: 457 times
Contact:

Re: USB Issues

Unread post by odroid » Sat May 28, 2016 9:40 am

Sorry.. I overlooked your posts.

We have no idea how to solve this issue. Is their any other patches we can try?

jonathanreidnz
Posts: 1
Joined: Tue Aug 16, 2016 10:45 am
languages_spoken: english
ODROIDs: C2
Has thanked: 0
Been thanked: 0
Contact:

Re: USB Issues

Unread post by jonathanreidnz » Tue Aug 16, 2016 10:48 am

Was there a solution to this problem ? We are hitting the same problem when we attached 2 USB devices (IOIO and USB to serial device)

Bruce206
Posts: 2
Joined: Fri Sep 09, 2016 4:43 am
languages_spoken: english
ODROIDs: Odroid c2
Has thanked: 0
Been thanked: 0
Contact:

Re: USB Issues

Unread post by Bruce206 » Fri Sep 09, 2016 4:53 am

I ran into this Problem too. We connected one touchscreen and a usb-serial adapter. When connected last, i can connect to the usb-serial-device without problems and the touchscreen is working too (it's handled by android itself, that seems to work). If the touchscreen is connected last, the usb-serial-device is not usable in my app!
We need a fix as soon as possible...

User avatar
odroid
Site Admin
Posts: 33357
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 392 times
Been thanked: 457 times
Contact:

Re: USB Issues

Unread post by odroid » Fri Sep 09, 2016 10:09 am

As you can see above posts, we couldn't find any solution.

Do you also have the same issue with the USB otg-host cable too?

Bruce206
Posts: 2
Joined: Fri Sep 09, 2016 4:43 am
languages_spoken: english
ODROIDs: Odroid c2
Has thanked: 0
Been thanked: 0
Contact:

Re: USB Issues

Unread post by Bruce206 » Fri Sep 16, 2016 4:57 pm

I have the Issue with the usb-otg port too. Only the last device plugged in gets recognized correctly.
I tested the app on my LG G3 with Android 6.0 and the bug seems to be fixed there. Are there any plans to bring an Android 6 Image to any of your boards in the near future so we could test if it is fixed there?

User avatar
odroid
Site Admin
Posts: 33357
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 392 times
Been thanked: 457 times
Contact:

Re: USB Issues

Unread post by odroid » Sun Sep 18, 2016 1:20 pm

We will have a trial version of Android 6.0 by middle of October. But I am not sure if it can fix the issue or not.

Post Reply

Return to “Android”

Who is online

Users browsing this forum: No registered users and 2 guests