yashsingh1/xdaforums huggingface dataset:
[Optimus One, P500 Android Development] spaic:
@haoto

Done it, no luck (no output in dmesg whatsoever)... maybe some insmod should be in order?

My cable is a hacked one, with the sense pin "floating"

I used a external usb hub, and a Y cable (with a second usb for PC-style plug) to provide the power to the hub.

Could you please post a version of the kernel that is flashable via recovery (maybe more people - including me - would find it easier to do)?

I tried to connect the camera both directly and with the usb hub in between. Not even the usb hub was detected.

Maybe the sense pin in the micro plug, that in my hacked adapter is floating...

And also, do these drivers look at the sense pin on the usb cable? I haven't found a "proper" USB OTG adapter (using a pathed one, made fom am micro data cable and a usb extender), and in the cable that I have, pin 4 (the sense pin) is floating, it's not grounded.

I think that the conflict between host and client is solved in the ZTE Blade (with an official froyo update), and, if I remember correctly, the sources for the kernel are released (I think I have seen them here on XDA). And I think that it is solved by the means of the sense pin in the usb connector. Even in the Optimus the sense pin is connected, as far as I remember from the schematics in the service manual (also found here on XDA), and it could be watched/read... but then it would not work with hacked cables.

As for the charging, I'm not sure how the charging circuit works, but, if what I'm saying about the sense pin in the USB port (I'm obsessed with that pin, it seems...) being floating (not strapped to GND) in the charger cable, it might trigger the charging circuit to start charging.

And now to explain my "obssesion" with the sense pin:

I bought a Nokia CA-157 cable (USB OTG adapter) and, not being very careful, I did not notice that it is micro USB A, not B and it does not fit (same size, but it has squared ends, so it is a bit too big...). So I tried to "bend" it i order to fit, but I destroyed it. But then I read a bit more about the pins in the usb port, and measured it (very carefully, cause the pins are so small) and found that pins 4 an 5 are strapped together (zero ohms). Then I tried to measure the pins on the normal micro usb cable, and found out that they are not strapped. So I figured that, in order to have a OTG adapter working correctly (charging, usb host and usb gadget) you need to have that 4 pin strapped to pin 5 in order to get the chipset in host mode.

@DJoptimus-One:

USB host (or rather USB OTG) is the posibility to connect devices to your android just like connecting them to a PC, eg. connecting a photo camera to the phone directly (no PC) for copying photos, or connecting a PC keyboard directly to the phone, or connecting... a USB memory stick directly to your phone for file copy... etc.

@moderators:

Maybe this thread should be moved to the development section, as it has a bit of recompiling and testing, and maybe it could get more people involved in the development of this?
[Optimus One, P500 Android Development] spaic:
Tried the latest kernel, but still does not work...

I will try to hack the cable a bit more, see if I can get any change in behavior.

I hope someone else reads this thread and and comes with some more input...

My only input so far is testing... (I do lack some knowledge about kernel building...)

Maybe looking into the ZTE Blade kernel and apps would help... (it's here)
[Optimus One, P500 Android Development] haoto:
Oops, I just noticed the build I uploaded doesn't work for me either; I changed some configuration and assumed it was harmless. They are updated now, sorry for the blunder :o
[Optimus One, P500 Android Development] spaic:
Will try it again (I assume it is in the older post).

Also, maybe a "software switch" (either app or simply a touch or something) could be made to switch from host to gadget mode like here? (Better after we get it working, though...)
[Optimus One, P500 Android Development] haoto:
Oh no, it's in the newer post :)

If you have the time, could you also try to measure the following with that kernel installed:

1) voltage between VCC and GND when nothing is connected

2) voltage between D- and GND and the voltage between D+ and GND when only a charger is connected

3) resistance between D- and GND, and resistance between D+ and GND when nothing is connected

I'm not sure I know what to do next, but this might help us clear up a couple things.

I'll try to have a look at the ZTE Blade kernel source later, thanks.

Update: it's suddenly working!!!

I successfully mounted a USB stick! So either the driver is unstable, or there indeed is something wrong with my hacked cable! :o

(And then I burned my USB charger! Thankfully my phone is alright. Looks like there is definitely something wrong with my cabling :o:o)
[Optimus One, P500 Android Development] spaic:
With my cable did not work, so I managed to completely destroy the micro part of my cable trying to find a way to short pins 4 and 5.

As I understand it, you have your cable with pins 4 and 5 shorted (sense - gnd).

I am still trying to find a proper adapter, but all I can find is the CA157 from nokia, which is A and does not fit...

And I could not find another standard otg cable (at least the part number, in order to find it faster) from a big manufacturer (htc, noika, samsung, whatever...).

I will get another micro and hack it once more, though, and try to measure the voltage on the pins. Maybe a noname cable is easier to mod...

As for the burnt charger... I don't think that there should be any problem... Here are some prints from the service manual.

Did you use the charger for powering the USB bus? Or did you just plug in the power?

I don't have issues with the charger connected just for charging the phone (I'm using a nokia micro USB charger, and it's working perfectly... even with the modded kernel)
[Optimus One, P500 Android Development] haoto:
I actually got a micro-B to mini-B adapter with all 5 lines connected, so I can cut the cable at any place to solder the ID and GND lines. Please do let me know when you get it working (or not...:) mine seems to work from time to time now)

The charger burned when I was using it to power the USB devices. I guess it's most likely caused by a short in my hacked OTG cable :o, it was a cheap USB charger which probably doesn't have any over-current protection.
[Optimus One, P500 Android Development] scorpionking674:
sorry for this noobie question but did u meant we could attach usb devices directly to phone?
[Optimus One, P500 Android Development] 4silvertooth:
Ya.

Sent from LG P500.
[Optimus One, P500 Android Development] unxiguru88:
This seems very interesting! Can you guys write a short tutorial on the steps needed to get OTG working?
[Optimus One, P500 Android Development] spaic:
It is not fully working yet (at least not in a very friendly way).

Anyway, I'm still trying to hack a cable with the sense pin grounded, in order to do some testing at least...

Steps to be taken:

WARNING!

Rooting the phone and installing a new kernel and some other stuff presented here voids warranty, and MAY brick your phone!

Also, this requires connecting to your phone a cable that is HACKED and not supported by the manufacturer; it MAY (and is not very unlikely) FRY YOUR PHONE

We do not take ANY responsibility if you brick/fry your phone; this is only what we are doing or trying to do.

Also, the mod is not yet complete, as in the last version only the usb HOST is included (connect devices to Optimus), not the USB device is included (connecting the optimus to the PC does not work any more, not as sync nor mass storage, and there is no mode switching yet). Charging does work.

Also, after boot you get a message that some settings app does not work (we ignore that).

So, if you are willing to risk bricking or frying your phone at your own responsibilty, here is what we are trying to do...

0. Do a full backup. This is the firs step, no matter what you do to the phone (well, at least after rooting and installing custom recovery...), in order to have a WORKING restore point. (it will help if something that you have been warned might happen actually happens - except a fried phone)

1. a. Get a micro USB B male to USB A female OTG cable (that has pins 4 ans 5 straped together)

1. b. Alternatively, you can hack a cable like that, if you find the parts (one micro usb b male to mini usb male/female cable with all 5 wires inside and a normal usb a male to usb a female, and hack the cable)

2. root your phone (!! at your own risk !! only YOU are responsible for what you do to your phone)

3. install the latest kernel version posted here. Same warning as above.

4. make some hack on the cable (eg. get a y usb cable from an external hdd or something) in order to get +5V to the USB bus (at this time the phone does not supply +5V to the devices connected, maybe some state on the usb driver chip must be changed, or maybe the phone does not support providing power via the USB port). Connecting this cable to your phone may fry your phone, so double check, triple check and remember that YOU DO THIS AT YOUR OWN RISK...

5. connect a usb stick and... (from this point I could not test, as I do not have yet a cable with the sense pin grounded) make it work... (probably like in the steps below; NOTHING IS AUTOMATED YET, I GUESS)

6. open a terminal, type "su" (get root access), type "dmesg" (lots of lines will appear) and then identify the block device that the stick is (probably something like "sda").

7. make a folder somewhere where will mount the USB stick

8. mount the usb stick and see if it works properly.

From step 5 onward I did not test anything, so please correct me if I said something wrong.
[Optimus One, P500 Android Development] scorpionking674:
nexus one supports usb host mode, a guy modded it and stuff, did u checked it out?
[Optimus One, P500 Android Development] spaic:
Did see it, but it is a different chipset, but on the site with the Nexus One there is also a mod for ZTE Blade that has the same chipset. Posted in the first page of this thread.

Also, the ZTE has USB support in an official update, from what I read, and posted a link to the kernel source.
[Optimus One, P500 Android Development] ahmadfarisfs:
I think u should move this thread to the dev's section
[Optimus One, P500 Android Development] spaic:
Finally got a usb otg cable... bought another CA-157 (with micro USB A plug) and managed to grind the corners that were in the way.

Also hacked a Y cable with two usb A male and one usb A female connectors (one of the male plugs is there only for the power - attached picture)

The bad thing is that my dmesg output looks nothing like the ones in the first kernel post...

Tried usb sticks, a usb hub and a camera...

there is nothing in the dmesg output except some

<7>[ 599.272943] usb usb1: usb resume
<6>[ 599.272981] msm_otg_resume: is_host()=0, replaced with 1
<6>[ 599.273008] msm_otg_resume: usb exited from low power mode
<7>[ 599.273039] msm_hsusb_host msm_hsusb_host.0: resume root hub
<7>[ 599.305779] hub 1-0:1.0: hub_resume

and

<7>[ 604.995753] hub 1-0:1.0: hub_suspend
<7>[ 604.995824] usb usb1: bus auto-suspend
<7>[ 604.995853] msm_hsusb_host msm_hsusb_host.0: suspend root hub
<6>[ 604.996803] msm_otg_suspend: USB_CHG_TYPE = USB_CHG_TYPE__SDP
<6>[ 604.996843] msm_otg_suspend: usb in low power mode

I have attached a file containing a longer dmesg.

I have no idea why it does not work...

If someone else can give e a hint...
[Optimus One, P500 Android Development] spaic:
1) ~150mV (voltage only goes from the usb port to the phone not vice versa; maybe there is some way to activate the power flow from the phone to the usb port to enable sensing on pin 4 of the micro usb port and to power external devices? I've seen it somewhere)

2) -120 mV dc, 40mV ac on D-; -120mV dc 40mV ac on D+; some 1.2V AC without power connected

3) very high with no power, both on D- and D+;

EDIT:

Regarding enabling power from te phone to the usb port:

"The next problem is that as far as I know the hero cannot supply power on the USB bus, and I'm not daring to try enabling the USB bus power hardware registers until I know more about how the charging circuitry is implemented."

Found here, also on am MSM chipset, but it's the 7201.

And by the way (offtopic) this thread is all about this...
[Optimus One, P500 Android Development] 4silvertooth:
Well I am not good at this but I just had a look at the thunderg kernel on github (getitnowmarketing) and I think there's drivers for cd-rom in the kernel. A USB cd-rom (self powered) would be great to work on.
[Optimus One, P500 Android Development] haoto:
Hi,

I did a bit more testing and figured out why it didn't work for me right from the start, and most likely why it doesn't work for you.

Here are the exact steps one needs to follow to make the hardware act as USB host:

1. Turn off your phone (reboot doesn't work.)

2. Turn on your phone with both the microUSB-A cable and power source connected. It doesn't matter whether any USB device is connected or not.

Now you should be able to connect and use any USB device. I only included drivers for keyboard, HID mouse, usb-storage and some usb-serial drivers, but the rest would be easy.

You can plug/unplug USB devices any number of times, but once the power source is disconnected the USB controller will stop working before another cold start.

I think this behavior is consistent with some other device I read somewhere before, and I don't know if there is any workaround. Since I don't have much more spare time lately I'll have to live with it for now. Hope this helps.

Thanks for your tests btw :)
[Optimus One, P500 Android Development] 4silvertooth:
But we have common slot for microUSB and charging. ONLY ONE SLOT.
[Optimus One, P500 Android Development] haoto:
@4silvertooth: You can get a PC instead. They also have bigger screens to help you read more easily.
[Optimus One, P500 Android Development] d3vil:
I think that's why the Y-cable is for, no?

Just ordered a OTG cable, would be great to have some more feedback meanwhile.
[Optimus One, P500 Android Development] 4silvertooth:
Thanx man I have 3.
[Optimus One, P500 Android Development] spaic:
You will have to use a Y usb cable. There are some pictures of my cables, and a general schematic.

What he meant by "the microUSB-A cable and power source connected" was actually "provide USB power to the bus from an external source, because the phone does not provide power to the USB bus"

What I have is:

otg cable from a nokia, with micro usb A male (modified to fit a B plug) and a USB A female.

a Y cable with two USB A male plugs and one USB A female plug, as pictured in my post above (also a schematic)

What you do is connect the micro usb to the phone, the USB A male that has the data pins wired to the OTG adapter (in the USB A female cable) and the other USB A male either to a computer or to a charger that has a USB A female plug (the one that came with my phone is perfect).

When you do this you will:

provide power to the usb bus for the connected devices

charge your phone
[Optimus One, P500 Android Development] d3vil:
Any updates? Does it work with a card reader?
[Optimus One, P500 Android Development] spaic:
still no luck for me...

I get

<6>[ 4.043033] msm_otg_suspend: usb in low power mode

whatever I do. (I don't know if this means that USB is changing mode)

I attached 3 dmesg output files:

first pluged in the micro usb port, pressed power after the battery chaging image appered.

same as above, but screen timeout set to 10 minutes, so it does not enter "screen off" mode

first pressed the power and then pluged in the micro usb plug, before (I hope) the system started to boot, same 10 minutes delay.

each time there was no usb device attached, and then I attached a USB stick.

Could it be because of the version of android I'm running?

I still use the stock romanian kernel, only with changed kernel and the patches for performance (hwacc and quadrant patch). And lately I've been using the franco kernel, except when testing this one.

my android version is 2.2 (not 2.2.1, not 2.2.2), build number FRF91, Software version LG-P500-V10b

Sorry I can't do more testing, but I am also kinda busy...

Although anyone could try and see if it works (mind the red warnings, though, but it's not that complicated nor very dangerous, if you know what you are doing. My phone did not fry), the more feedback the better.
[Optimus One, P500 Android Development] d3vil:
I got my adaptor today. Any guide to flash the files so I can test it?
[Optimus One, P500 Android Development] aaronbutton:
I too would like to have this functionality but i would like to keep with the franco kernel do to the improvements. Can the modules just be copied over with root explorer, ect? If more needs to be done to the kernel such as recompiled could some more information be given? such as the code that needs to be added.

I assume that as the moment the boot.img is just flashed using flash_img via terminal?

Very good work thank you
[Optimus One, P500 Android Development] flaviopac:
What about this?

http://developer.android.com/guide/topics/usb/index.html

It seems like host usb has been introduced since android 2.3.4 (provided that android device fisically supports power supply to the usb devide)
[Optimus One, P500 Android Development] d3vil:
I believe it's supported from 3.1 onwards, 2.3.4 only supports accessory mode
[Optimus One, P500 Android Development] flaviopac:
maybe it should support standard usb devices too (self-powered)

I don't think it would be too hard to get it work ;)

Here some notes from the LG P500 service manual:
[Optimus One, P500 Android Development] aaronbutton:
As it was said in the early posts other phones (nook color, nexus, htc hero) have this pre-gingerbread (through hacking) and that the for usb host is included in the kernel source just not compiled with official builds. I believe the P500 could do better than the nook as the sense pin is connected so hopefully could switch automatically. The source for the nook and the thread can be found from here http://xdaforums.com/showthread.php?t=1105497. If we had the sources from the OP perhaps we could port his changes into the franco source and maybe learn something from the nook colors sources. :cool:
[Optimus One, P500 Android Development] flaviopac:
sources for Nook Color are avaible here:

https://github.com/dalingrin/nook_kernel/tree/usbhost

maybe someone is capable to port it on CM7 for Lg P500 :rolleyes:
[Optimus One, P500 Android Development] nikoperugia:
Hi all, first post here. I'll build the cable in the next few days. In the meantime, has anyone tried building franco's kernel with the EHCI_MSM option enabled? It looks like the source is there, just like LG's kernels:

config USB_EHCI_MSM

bool "Support for Qualcomm on-chip EHCI USB controller"

depends on USB_EHCI_HCD && USB_MSM_OTG_72K && ARCH_MSM

---help---

Enables support for the USB controller present on the

Qualcomm chipsets.
[Optimus One, P500 Android Development] nikoperugia:
On the other hand, I'm afraid that the Nook Color uses a completely different chipset, so the source won't be really useful.
[Optimus One, P500 Android Development] flaviopac:
Yes, the chipsets are different..

But anyway our Qualcomm MSM7227 supports host usb feature (at least from the service manual..)

I'm waiting for my microusb->usb OTG cable.. hoping in a solution about this| :)
[Optimus One, P500 Android Development] nikoperugia:
A cheap and easy way to build a cable would be to take a USB front panel (they usually come with two ports) from an old case and use short cables to connect the pins from the two ports together.

It has the added benefit of being able to fiddle with pins (sense, etc..) easily.

update: i'm building franco's kernel with usb host enabled right now.
[Optimus One, P500 Android Development] d3vil:
Nice! Please post it and your results
[Optimus One, P500 Android Development] flaviopac:
Well, I ordered a microusb->usb cable and I own a usb Y cable (in the case we need external power supply for devices).

Some devices work using the internal android-based device battery, others need externar source...

let us know if it works! :eek:
[Optimus One, P500 Android Development] nikoperugia:
Now on for the updates. After an afternoon of fiddling, I've managed to build my very own kernel and boot.img. I'm working with mik's CM Sources.

Altough I can compile everything, including usb host support, i see no logs when connecting devices.
[Optimus One, P500 Android Development] flaviopac:
Andy said we need .35 lg kernel source (android 2.3.3) which is coming soon

It seems that lg included such drivers from this kernel

In tha meantime you could tru gingerbread leaked version (the one i'm running right now) whoch is compiled by lg with the official .35 kernel

Let us know!
[Optimus One, P500 Android Development] aaronbutton:
I know that the sources are available for the nook but the guy that made the kernel for the p500 in this thread hasn't posted his.

I think the kernel needs editing so that it will boot or switch over into accessory mode, It isn't a feature built into the kernel so it wont change over its self. In the previous hack the kernel stayed in that mode, however as we dont have the sources I dont know what was changed :confused:. The nook uses a app to do this.
[Optimus One, P500 Android Development] nikoperugia:
I don't think that LG enables USB host out of the box, even if it's included in the new kernel they're using. I'd think we would need the sources to enable it in the config. Has andy specifically said so?
[Optimus One, P500 Android Development] nikoperugia:
Hi, some updates with the things I'm trying (with no success apparently..)

I'm using these patches http://sven.killig.de/android/Blade/usb_host/ on mik's kernel. I can get everything to compile (cross-checking with the patches from the same site that are for a .32 kernel). I've also set is_host to 1, as read in this thread, until someone can get pin monitoring to work.

USB Gadget doesn't work anymore with this changes, so something is definitely going on here, but neither does USB host.

update: I've decided that one afternoon of fiddling is enough for now. Recap of the things I've tried:

-building mik's kernel with the zte blade patches (they're for 29 but compile on .32)

-enabling msm host drivers in mik's kernel (running with CM7) with patched is_host() to always return 1. that seems to get the same results haoto got in his first posts. The USB root is recognized, but anything else. I don't how how he got it working, as he writes that it started working magically with the same kernel.. That seems the way to go, anyways

-trying to boot haoto's boot.img with CM7. Very promising indeed, if I attach a usb thumb drive to my externally powered bus, it flashes for a while and seems to be recognized. unfortunately i can't see anything on the screen (probably froyo/gb incompatibility)

-trying to boot haoto's boot.img with a random froyo rom. if i follow his instructions and connect the phone to the powered bus before turning it on, it just enters a reboot loop. if i connect it later, nothing works.

if someone wants to pick up from here, just let me know, I've put together a fair amount of noob knowledge on compiling android kernels.
[Optimus One, P500 Android Development] aaronbutton:
I assume you read this bit? “The good news is that the LG v10r kernel source seems to have the USB host driver for msm7x27; it is just not compiled into the official kernels. I compiled a kernel with usbcore, ehci-hcd, usb-storage and usbhid built in.” The kernel sources can be found with a quick Google.

“Oh, and note that usb client mode is nonexistent with the attached kernel because host and client drivers don't play nice with each other. Because of this you'll probably see some error message that some setting application crashed, but it's not a big deal.”

Looks like you have been doing some good work, Thank you. I would like to have a go at this myself but I have far to much college work. I also guess that the modules will work from different phones and can just be copied over from the htc link you gave.