[HACKING] USB Host Driver For Ext HDD

Search This thread

coooolboyz

Member
Jun 23, 2010
45
8
London
Samsung's press release for the processor confirmed USB host capabilities. But it doesnt look like that functionality is exposed at an OS level yet.

As done similarly for Nexus One, will it be possible to write up a driver or something like that for Samsung Galaxy S?

It would be too good to have an external HDD connected to this device!!! (That means, practically unlimited storage!!)

I know that there could be problems with power required to spin a drive, but my Creative Zen Vision M (60 GB) player had USB host (badly implemented) capabilities - and it was able to spin hard drives.

Is it worth a try with SGS?
 
Last edited:

coooolboyz

Member
Jun 23, 2010
45
8
London
SGS USB Host Documentation

Guess What!! I was going through the bundled "Documentation" along with the SGS i9000 code and I found this!!

Code:
			S3C24XX USB Host support
			========================



Introduction
------------

  This document details the S3C2410/S3C2440 in-built OHCI USB host support.

Configuration
-------------

  Enable at least the following kernel options:

  menuconfig:

   Device Drivers  --->
     USB support  --->
       <*> Support for Host-side USB
       <*>   OHCI HCD support


  .config:
    CONFIG_USB
    CONFIG_USB_OHCI_HCD


  Once these options are configured, the standard set of USB device
  drivers can be configured and used.

That is very encouraging. But I haven't done any kernel compiling (hell, I haven't even done any Android coding, this being my first Android phone!!). So its gonna a be a while before I can put this to a good use.

Now, I am not sure if this is just "Host" or if it would support "OTG" also. I found the documentation on S5PC110 [Dev Sheet] a bit confusing also. It does show that the microprocessor has both HOST and OTG capabilities, but I am not sure to what the USB port has been wired to.

May be somebody can put this to a good use.
 

coooolboyz

Member
Jun 23, 2010
45
8
London
Well if this as easy as it sounds, it beats any logic whatsoever, why Samsung didn't put in this functionality out-of-the-box with SGS. This device seems severely constricted in features which the S5PC110 chip init readily supports.
 

futaris

Senior Member
Jul 27, 2004
100
2
44
You have a s5pc110 processor, in the Galaxy S.

Any talk about usb host drivers (for that processor / s5pc series) would probably be done on the linux-samsung-soc mailing list.
 

brunes

Senior Member
Dec 9, 2006
668
54
What do people use this feature for? I guess I am having a hard time envisioning why this would be useful on a phone.
 

19arek93

Member
Aug 5, 2010
28
0
Anyone? Sorry for spaming, but i really need it. Maybe someone have got some links explaining how to enable usb host? I'm not a dev. but i can try do something, anything to get this to work!
What we have to do? Some drivers, or new kernel?

Right now I'm going to buy 2-female USB adapter. Please, reply!
 

brunes

Senior Member
Dec 9, 2006
668
54
Anyone? Sorry for spaming, but i really need it. Maybe someone have got some links explaining how to enable usb host? I'm not a dev. but i can try do something, anything to get this to work!
What we have to do? Some drivers, or new kernel?

Right now I'm going to buy 2-female USB adapter. Please, reply!

If you are this desperate why not just use a bluetooth keyboard...
 

forcedv

Senior Member
Mar 7, 2006
460
24
Has it been officially confirmed that the Galaxy S can't do USB host ?

This would be an amazing feature on an already amazing device.
 

imparator

Senior Member
Mar 14, 2006
282
133
From what I know a about jpc rom it now installs a cdrom drive when plugged in to windows. Seems to that there's soms sort of host capabilities are built in

Sent from my GT-I9000 using XDA App


Sent from my GT-I9000 using XDA App
 
Sep 3, 2010
14
1
samsung source code

Hi!
I too find this feature very useful. However, I found little information about it on the net. So I started digging through the source code provided by Samsung (GT-I9000_OpenSource.zip). From this and from the specs of the chip (S5PC110_EVT1_UM10.pdf), I take it that the phone does support USB host. The problem is, it can only do either client or host, not both at the same time. Now here is where it gets tricky.

The Samsung kernel source is not as neatly separated into independent modules as you would expect from a Linux kernel. The USB client stuff (usb-storage, modem...) is connected with the driver that checks for cable plugging and unplugging which in turn is connected with the driver for the voltage regulator that starts charging the battery and supplies the cpu with power as soon as you connect the phone to your computer. Consequently you can't just build the USB client stuff as a module to be able to unload it and load the USB host module instead.

I have started to write a workaround for that, separating these interconnected drivers from each other. The easiest point to take it apart seems to be the driver of the voltage regulator. It has the fewest external dependencies. It does, however, pose the problem that the phone won't charge if something goes wrong...

Well, I got as far as being able to compile the source with the USB client stuff as bunch of modules and the independent part compiled into the kernel. I got that flashed on the phone. It boots, it doesn't blow up, and USB client is disabled. So far, so good.

Problem is, the client modules won't load. I don't know why, yet. Having to work with the on screen keyboard and a terminal instead of getting a shell via "adb shell" isn't helping either...

Well. That's as far as I got today.

Suggestions? Comments?
 

coooolboyz

Member
Jun 23, 2010
45
8
London
Woah!!! You've gone forward way farther than I have!! :)

I took a lot of time trying to get around to a proper working kernel itself! :-( I am a complete noob at this - SGS being my first phone. [Not to mention the fact that I almost got my phone bricked once and got into infinite boot sequence on another instance.]

I had been trying to add modules built-in into the kernel itself - without making any code changes. I find when I plug-in my Mircro USB OTG cable - dmesg gives out 4 lines of log entries -

Code:
[s3c_usb_cable]done_clk_enable
[s3c_usb_cable]done_udc_reinit
[s3c_usb_cable]done_udc_enable
FSA INTR = dev1 : 0x80, dev2 : 0x0, Attach : 0x1

Of the above 4 lines - for the first 3 I was able to find the code in the file -

Code:
<Path_to_source_code>/GT-I9000_OpenSource/GalaxyS_Kernel.tar/GalaxyS/linux-2.6.29/drivers/usb/gadget/s3c_udc_otg.c

Now these entries come up only when I connect my OTG cable. Normal cable does not give this. May be the SGS can do both OTG and Device mode at the same time?

To understand more of this I tried to enable DEBUG. But apart from getting in to infinite boot loop, I was not able to move ahead much.

Another interesting thing that I noticed was that -

Code:
CONFIG_USB_S3C_OTGD=y

is set in the normal/unmodified .config file obtained from OpenSource website of Samsung.

From what I understand, this means that the OTG module is directly compiled and linked in to all of our kernels. But for some reason, it is not working as expected.

Well I am stumped!!! May be I will look more in to this during this weekend.
 

Finguz

Senior Member
Feb 14, 2009
121
12
Scarborough
Samsung's press release for the processor confirmed USB host capabilities. But it doesnt look like that functionality is exposed at an OS level yet.

As done similarly for Nexus One, will it be possible to write up a driver or something like that for Samsung Galaxy S?

It would be too good to have an external HDD connected to this device!!! (That means, practically unlimited storage!!)

I know that there could be problems with power required to spin a drive

Is it worth a try with SGS?

If you used an SSD you wouldn't have to worry about power to spin it up ;) Although I don't think I've seen a USB one anywhere...

Best of luck, this would be an awesome and very useful feature to have!
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 6
    4
    we can buy S2 instead of discussing about something, which is not possible

    'We' don't want an S2. I could have one free of charge within 3 days if I wanted. But I don't.

    I think this post should be disregarded unless the poster can prove or demonstrate it is not possible.
    3
    After 1 day of struggling trying to understand this linux ****ty kernel/modules compiling managed to get this:

    Code:
    <6>[  945.208118] usbcore: registered new interface driver usbfs
    <6>[  945.212032] usbcore: registered new interface driver hub
    <6>[  945.213724] usbcore: registered new device driver usb
    
    
    <6>[  968.245592] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
    <7>[  968.245638] ehci_hcd: block sizes: qh 60 qtd 96 itd 160 sitd 96
    
    <6>[ 1027.498783] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
    <7>[ 1027.498931] ohci_hcd: block sizes: ed 64 td 64
    and some more...
    Code:
    <6>usbcore: registered new interface driver libusual
    <6>Initializing USB Mass Storage driver...
    <6>usbcore: registered new interface driver usb-storage
    <6>USB Mass Storage support registered.

    Code:
    <6>usbcore: registered new interface driver usbhid
    <6>usbhid: v2.6:USB HID core driver
    3
    Hi there. There is also another source code but I never tried it. You can check it out and download here: http://www.hackchina.com/en/cont/96900
    Never tried this code in my kernel, but I guess it should be somewhat compatible.

    Anyway, in regards to your question. After I read the documentation, I've seen:
    The Core Global and Host Port control and status registers are accessed in both Host and Device modes. If the OTG Link operates in either Device or Host mode, the application must not access registers from other modes. If an unauthorized access occurs, a Mode Mismatch interrupt is generated and value is reflected in the Core Interrupt register. If the core switches from one mode to another, reprogram the registers in the new mode of operation to match state after a power-on reset.

    In GUSBCFG register you have something like ForceHstMode.

    Force Host Mode
    Writing a 1 to this bit forces the core to host mode irrespective of utmiotg_iddig input pin.
    ? 1’b0: Normal Mode
    ? 1’b1: Force Host Mode
    After setting the force bit, the application must wait at least 25 ms before the change to take effect.

    So in order to do the above thing all you have to do is to jump to the file s3c-otg-oci.c and look at:
    int oci_core_init(void)
    and at the end of the /*PHY parameters*/
    just before if(oci_core_reset() == USB_ERR_SUCCESS)
    add:

    Code:
    	usbcfg.b.forcehstmode = 1;
    	//so we sleep
    	//After setting the force bit, the application must wait at least 25 ms before the change to take effect..
    	write_reg_32 (GUSBCFG, usbcfg.d32);
    	mdelay(100);


    P.S. Keep us updated with your success. :D
    3
    Some Android tablet pc with 2.1 or 2.2 are support USB flash memory ( It called UDISK in android ). That means android os is able to be a host for USB cool disks and ...
    just need some seroius works for this revolution