USB Host Support for Custom Devices

Search This thread

terranim

Member
Nov 9, 2009
31
34
blog.teadriven.me.uk
The SGS2 supports USB OTG which means it can play host to certain low-powered USB devices. Unfortunately the kernel is configured with a whitelist that means it will only connect to HIDs, printers, PTP cameras and mass storage devices.

I wanted to begin developing an application using custom (vendor specific) USB hardware and so started experimenting to see if it was possible. There is a full description of how I went about it on my blog. To summarise, one of the ways to enable vendor specific USB devices is to edit the file "drivers/usb/core/sec_whitelist.h" and add the following to both whitelist tables:

Code:
{ USB_DEVICE_INFO(0xff, 0x0, 0x0) },   /* vendor specific USB devices */

There are two reasons for this post, the first is to provide information to help others that may want to do the same thing. The second is to try and encourage kernel modders to include my changes (or disable the whitelists altogether) thereby providing application developers the means with which to communicate with custom hardware.

Regards,
Dan
 

MacaronyMax

Senior Member
Aug 27, 2008
13,722
582
Oxford
Nice idea, I may be completely wrong, but if you remove the white list it, will accept other hardware? or is it dependant on it being there?

Sent from my GT-I9100 using Tapatalk
 
  • Like
Reactions: inistine

terranim

Member
Nov 9, 2009
31
34
blog.teadriven.me.uk
@MacaronyMax: As I mentioned in my blog post, it is possible to disable the whitelist entirely via the kernel options which I assume would allow any device to connect, but I have not tested this and so am unsure.

@xlanhackerx: The ADK relies on accessories that have been designed to act as host and use an Android specific protocol, whereas I am interested in the SGS2 acting as host so that I can connect custom third-party slave devices to it. Therefore I have not looked at the ADK at all and I do not have the hardware available to even play with it.

Regards,
Dan
 
  • Like
Reactions: inistine

letsdream

Member
Sep 27, 2011
23
4
Thank you. Maybe a custom ROM has it built in?

Thank you so much terranim for this discovery, and for posting it.
I have been struggling on that for a week now, not understanding why my driver was apparently not even called.

I was thinking it could exist a ROM that has this whitelist removed... anyone has a clue? (Lite'ning 6.1 / ninphetamin 2.0.5 or .11 have is using sec_whitelist.h)
 

terranim

Member
Nov 9, 2009
31
34
blog.teadriven.me.uk
I don't think that any kernel developers have disabled this whitelist yet! However there is now another major problem: In the latest ROM from Samsung it is reported that they have removed the USB host related libraries in the Android SDK!

My hack to the kernel will still work and allow devices to be connected, but we will no longer be able to communicate with custom USB devices via an Android application (unless we write a C library to talk to the devices directly or via libusb).

Hopefully developers will restore these libraries in their own custom ROMS.
 

letsdream

Member
Sep 27, 2011
23
4
I guess I am not too far from running this whitelist with your new line on a home compiled version of ninphetamine... see http://xdaforums.com/showpost.php?p=18123923&postcount=2828 and http://xdaforums.com/showpost.php?p=18123923&postcount=2833

I just got to to compile completely a minute ago, and will test it on Thursday.

I think I will stick to custom ROMs / kernel now... and possibly some I compile myself.

Did you read about libftdi? That could help you. Also that Samsung removed USB API might not harm as long as you use a serial port created by the serialusb driver.

edit / ps: nice to work in a team
 
Last edited:

pankov

Senior Member
Mar 9, 2008
54
6
Sofia
guys,
is there any chance this USB Host mode could work with a headphones USB DAC/Amp like the FiiO E7?
I really envy the iPod/Pad/Phone users and their ability to have pure sound of their devices while on the go. I know we have HDMI/MHL but sadly there are no headphones amps using this link
:(
 
  • Like
Reactions: inistine

alias_neo

Senior Member
Jun 9, 2006
2,081
205
London
it is correct that Samsung have removed the USB Host API,

As far as I can tell, they never intended to leave it there to begin with, but I do know that the particular API was introduced in API 11 (Honeycomb).

Sent from my GT-I9100 using Tapatalk
 

AdamOutler

Retired Senior Recognized Developer
Feb 18, 2011
5,224
9,826
Miami, Fl̨̞̲̟̦̀̈̃͛҃҅͟orida
What kernel options are required for this and what is needed to test connectivity? I have an older Galaxy S device and I'm trying to reproduce what you've done here. I just got an ADK for christmas and I've been working with Cyanogenmod kernel source in an attempt to get things operating. From what I can see I need a kernel driver. It would appear that it's begining to recognize that *something* is plugged in, but it's not enumerating.

Anything you can show me would be helpful. What do you see in dmesg when ADK or any other device is connected?
 

luketanti

Member
Jun 5, 2012
33
2
Balzan
Hi. I know this is an old thread but I want to know if there is some patch to enable USB DACs on the S2. I can not find anything that can enable this like the S3. If some one knows some thing please reply.
Thanks
 

Top Liked Posts

  • There are no posts matching your filters.
  • 8
    The SGS2 supports USB OTG which means it can play host to certain low-powered USB devices. Unfortunately the kernel is configured with a whitelist that means it will only connect to HIDs, printers, PTP cameras and mass storage devices.

    I wanted to begin developing an application using custom (vendor specific) USB hardware and so started experimenting to see if it was possible. There is a full description of how I went about it on my blog. To summarise, one of the ways to enable vendor specific USB devices is to edit the file "drivers/usb/core/sec_whitelist.h" and add the following to both whitelist tables:

    Code:
    { USB_DEVICE_INFO(0xff, 0x0, 0x0) },   /* vendor specific USB devices */

    There are two reasons for this post, the first is to provide information to help others that may want to do the same thing. The second is to try and encourage kernel modders to include my changes (or disable the whitelists altogether) thereby providing application developers the means with which to communicate with custom hardware.

    Regards,
    Dan
    1
    Nice idea, I may be completely wrong, but if you remove the white list it, will accept other hardware? or is it dependant on it being there?

    Sent from my GT-I9100 using Tapatalk
    1
    @MacaronyMax: As I mentioned in my blog post, it is possible to disable the whitelist entirely via the kernel options which I assume would allow any device to connect, but I have not tested this and so am unsure.

    @xlanhackerx: The ADK relies on accessories that have been designed to act as host and use an Android specific protocol, whereas I am interested in the SGS2 acting as host so that I can connect custom third-party slave devices to it. Therefore I have not looked at the ADK at all and I do not have the hardware available to even play with it.

    Regards,
    Dan
    1
    guys,
    is there any chance this USB Host mode could work with a headphones USB DAC/Amp like the FiiO E7?
    I really envy the iPod/Pad/Phone users and their ability to have pure sound of their devices while on the go. I know we have HDMI/MHL but sadly there are no headphones amps using this link
    :(