FORUMS
Remove All Ads from XDA
Honor View 10

USB OTG or HOST on the incredible.

12 posts
Thanks Meter: 4
 
By gowthamj, Junior Member on 11th August 2010, 05:26 PM
Post Reply Email Thread
Now that the 2.6.32 kernel is out. Can we patch the kernel with Sven's patch to enable ush host on the incredible?
 
 
14th August 2010, 07:59 PM |#2  
Junior Member
Thanks Meter: 10
 
More
Patch Applies...
The patch applies cleanly to the source for the latest HTC 2.6.32 kernel we have on our phones. I have the equipment to test this, but the weather is too nice today to stay inside to configure and compile a kernel. I'll start building later.

This will be my first time modifying a kernel on an Android device. Fastboot sounds like it would be helpful here, but last I checked the Incredible doesn't have fastboot.

Any Incredible kernel hackers out there have links or advice for how to go about testing an updated kernel?

Cheers,
-Slick
15th August 2010, 11:41 PM |#3  
Junior Member
Thanks Meter: 10
 
More
Still working on it...
Unfortunately, getting the kernel to compile with EHCI (host controller) instead of USB gadget support is not as easy. HTC's patches to the kernel assume USB gadget support and all the callbacks that it provides (e.g. usb_register_notifier, usb_get_connect_type).

(If these callbacks were required for charging to occur (e.g. in htc_battery.c) when USB is plugged, that would kind of stink.)
17th August 2010, 08:11 AM |#4  
Junior Member
Thanks Meter: 10
 
More
Progress
Even after I got the kernel compiling, the new EHCI driver wouldn't load (probe() wasn't being called). Then I realized -- after several hours -- that the USB device was no longer being registered (thanks to more HTC-kernel awesomeness). So, I had to carefully go in and set CONFIG_USB_ANDROID to be Y without enabling any other USB gadget drivers. This allows the USB controller device to be registered with the Linux kernel, but without a driver claiming it yet. That's the EHCI driver's job. And then you see:

Code:
<6>[  247.267852] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
<7>[  247.268096] ehci_hcd: block sizes: qh 60 qtd 96 itd 160 sitd 96
<7>[  247.268615] msm_hsusb msm_hsusb: initializing MSM7201/QSD8X50 USB Controller
<6>[  247.287658] msm_hsusb msm_hsusb: Qualcomm MSM7201/QSD8X50 On-Chip EHCI Host Controller
<7>[  247.287994] drivers/usb/core/inode.c: creating file 'devices'
<7>[  247.288391] drivers/usb/core/inode.c: creating file '001'
<6>[  247.288604] msm_hsusb msm_hsusb: new USB bus registered, assigned bus number 1
<7>[  247.288970] msm_hsusb msm_hsusb: reset command 080002 (park)=0 ithresh=8 period=1024 Reset HALT
<7>[  247.289733] msm_hsusb msm_hsusb: park 0
<7>[  247.289947] msm_hsusb msm_hsusb: reset command 080b02 park=3 ithresh=8 period=1024 Reset HALT
<6>[  247.290313] msm_hsusb_phy_reset
<7>[  247.347717] msm_hsusb msm_hsusb: ...powerdown ports...
<6>[  247.377807] msm_hsusb msm_hsusb: irq 58, io mem 0xa0800000
<7>[  247.397918] usb usb1: default language 0x0409
<7>[  247.398406] usb usb1: udev 1, busnum 1, minor = 0
<6>[  247.399108] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
<6>[  247.399505] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
<6>[  247.400207] usb usb1: Product: Qualcomm MSM7201/QSD8X50 On-Chip EHCI Host Controller
<6>[  247.400939] usb usb1: Manufacturer: Linux 2.6.32.15-hg000000000000 ehci_hcd
<6>[  247.401306] usb usb1: SerialNumber: msm_hsusb
<7>[  247.402893] usb usb1: uevent
<7>[  247.409057] usb usb1: usb_probe_device
<6>[  247.409484] usb usb1: configuration #1 chosen from 1 choice
<7>[  247.410278] usb usb1: adding 1-0:1.0 (config #1, interface 0)
<7>[  247.410980] usb 1-0:1.0: uevent
<7>[  247.417358] hub 1-0:1.0: usb_probe_interface
<7>[  247.417938] hub 1-0:1.0: usb_probe_interface - got id
<6>[  247.418304] hub 1-0:1.0: USB hub found
<6>[  247.419189] hub 1-0:1.0: 1 port detected
<7>[  247.419586] hub 1-0:1.0: standalone hub
<7>[  247.419982] hub 1-0:1.0: individual port power switching
<7>[  247.420684] hub 1-0:1.0: individual port over-current protection
<7>[  247.421051] hub 1-0:1.0: Single TT
<7>[  247.421752] hub 1-0:1.0: TT requires at most 8 FS bit times (666 ns)
<7>[  247.422149] hub 1-0:1.0: power on to power good time: 20ms
<7>[  247.422882] hub 1-0:1.0: local power source is good
<7>[  247.423278] hub 1-0:1.0: enabling power on all ports
<7>[  247.428955] drivers/usb/core/inode.c: creating file '001'
<4>[  247.429718] ------------[ cut here ]------------
<4>[  247.430175] WARNING: at kernel/irq/manage.c:274 enable_irq+0x4c/0xa0()
<4>[  247.430877] Unbalanced enable for IRQ 58
<4>[  247.431274] Modules linked in: ehci_hcd(+) usbcore bcm4329
<4>[  247.433502] [<c002d7f8>] (unwind_backtrace+0x0/0xd8) from [<c0063e34>] (warn_slowpath_common+0x48/0x60)
<4>[  247.434265] [<c0063e34>] (warn_slowpath_common+0x48/0x60) from [<c0063e84>] (warn_slowpath_fmt+0x24/0x30)
<4>[  247.434997] [<c0063e84>] (warn_slowpath_fmt+0x24/0x30) from [<c00979f0>] (enable_irq+0x4c/0xa0)
<4>[  247.435516] [<c00979f0>] (enable_irq+0x4c/0xa0) from [<bf064988>] (usb_hcd_msm7201_probe+0x23c/0x2fc [ehci_hcd])
<4>[  247.436279] [<bf064988>] (usb_hcd_msm7201_probe+0x23c/0x2fc [ehci_hcd]) from [<c01b2dc4>] (platform_drv_probe+0x18/0x1c)
<4>[  247.437042] [<c01b2dc4>] (platform_drv_probe+0x18/0x1c) from [<c01b1f84>] (driver_probe_device+0xa0/0x14c)
<4>[  247.437805] [<c01b1f84>] (driver_probe_device+0xa0/0x14c) from [<c01b2090>] (__driver_attach+0x60/0x84)
<4>[  247.438568] [<c01b2090>] (__driver_attach+0x60/0x84) from [<c01b17f8>] (bus_for_each_dev+0x48/0x84)
<4>[  247.439331] [<c01b17f8>] (bus_for_each_dev+0x48/0x84) from [<c01b114c>] (bus_add_driver+0x9c/0x218)
<4>[  247.440093] [<c01b114c>] (bus_add_driver+0x9c/0x218) from [<c01b235c>] (driver_register+0xa8/0x134)
<4>[  247.440551] [<c01b235c>] (driver_register+0xa8/0x134) from [<bf0700ac>] (ehci_hcd_init+0xac/0x12c [ehci_hcd])
<4>[  247.441314] [<bf0700ac>] (ehci_hcd_init+0xac/0x12c [ehci_hcd]) from [<c002836c>] (do_one_initcall+0x5c/0x1b4)
<4>[  247.442077] [<c002836c>] (do_one_initcall+0x5c/0x1b4) from [<c008d368>] (sys_init_module+0xb0/0x1dc)
<4>[  247.442840] [<c008d368>] (sys_init_module+0xb0/0x1dc) from [<c0028f00>] (ret_fast_syscall+0x0/0x2c)
<4>[  247.443542] ---[ end trace 1b75b31a2719ed1f ]---
<7>[  247.518524] hub 1-0:1.0: state 7 ports 1 chg 0000 evt 0000
A comment in the code seems to indicate that the WARNING from the kernel is normal (?).

So the USB controller is up, but it's not detecting any devices plugged into it. Rather, when I plug a hub in, the Incredible detects it as a start-charging-the-battery event.

(Note: When I removed the callbacks, plugging in the phone to upstream power doesn't necessarily cause it to start charging. But when an attached hub is disconnected and reconnected, it sometimes starts charging. But then I see things like:

Code:
<6>[ 2183.727874] batt: M2A_RPC: set_charging: 1 at 2180262071950 (2010-08-17 06:08:47.707000720 UTC)
<6>[ 2183.742767] batt: M2A_RPC: cable_update: USB at 2180276934011 (2010-08-17 06:08:47.721923817 UTC)
<6>[ 2183.743865] batt: htc_cable_status_update: 1 -> 1
<6>[ 2183.744323] batt: batt:(htc_cable_status_update)power_supply_changed: OverVoltage at 2180278520925 (2010-08-17 06:08:47.723510731 UTC)
<6>[ 2183.749298] batt: SMEM_BATT: get_batt_info: batt_id=2, batt_vol=3966, batt_temp=324, batt_current=417, eval_current=92, level=75, charging_source=1, charging_enabled=1, full_bat=1300000, over_vchg=0 at 2180283892020 (2010-08-17 06:08:47.728454579 UTC)
<6>[ 2183.751159] batt: SMEM_BATT: get_batt_info: batt_id=2, batt_vol=3966, batt_temp=324, batt_current=417, eval_current=92, level=75, charging_source=1, charging_enabled=1, full_bat=1300000, over_vchg=0 at 2180285723074 (2010-08-17 06:08:47.730316152 UTC)
<6>[ 2183.752838] batt: SMEM_BATT: get_batt_info: batt_id=2, batt_vol=3966, batt_temp=324, batt_current=417, eval_current=92, level=75, charging_source=1, charging_enabled=1, full_bat=1300000, over_vchg=0 at 2180287401541 (2010-08-17 06:08:47.731994618 UTC)
OverVoltage? That doesn't sound good -- I hope I'm not killing the poor USB port!
17th August 2010, 05:32 PM |#5  
OP Junior Member
Thanks Meter: 4
 
More
Thanks, for the update. I have another friend of mine, who is taking as shot at this. Can you post the changes you made. Maybe its helpful for other ppl trying to get this to work.

Sent from my ADR6300 using XDA App
17th August 2010, 06:55 PM |#6  
Junior Member
Thanks Meter: 0
 
More
I would like to help.
Let me know the steps to get the lastest kernal and what setup you are using.

I got a USB OTG cable, Y cable, Kenington USB HUB. Looking to get Keyboard, Mouse (Could we use the port of the mouse pointer from x86 port in CM6 ROM), USB Drive and I hope USB VGA out.
18th August 2010, 03:56 AM |#7  
Junior Member
Thanks Meter: 10
 
More
Sure, here's the "link":

linuxbeast.net/incredible_host

You'll need:
- the "stock" 2.6.32 Incredible kernel from HTC's website (unpack it)
- sonic74's patch (apply it with 'patch -p1' in the kernel directory)
- the config file from the above link as '.config'

Then apply one of the two patches from the above link, again with 'patch -p1'. One of the patches modifies the EHCI driver files to give you more debug output (#define DEBUG -- so you get the same output I did above), while the other does not.

As you can see, it didn't take too many changes to get the kernel to compile. The harder part was figuring out that I still needed to select CONFIG_USB_ANDROID to get the msm_hsusb platform device (i.e. the USB controller hardware interface) defined... and then avoid selecting/compiling the USB gadget driver (msm72k_udc), which would have then claimed that resource (as in stock).

Thanks so much for your interest. I won't have time to work on this for at least several days, so... good luck!

-Slick

P.S. I also included two kernel updater .ZIPs for the impatient. One lets you try the current state of things, and the other reverts back to stock. Use at your own risk!
18th August 2010, 05:28 AM |#8  
OP Junior Member
Thanks Meter: 4
 
More
Will try to load the new kernel and try to debug. If you need help in testing the changes, i am more that happy to risk my incredible. I got an extra one to play with.
18th August 2010, 02:06 PM |#9  
Junior Member
Thanks Meter: 10
 
More
It would be nice to at least see confirmation of the behavior I'm seeing; it's painfully close to working. Once you insmod the usbcore and echi-hcd modules, the USB controller appears to initialize and recognize the internal USB (host) port. But it doesn't seem to recognize the presence of any USB devices I plug in (besides, say, beginning to charge once I plug in a hub).
18th August 2010, 05:25 PM |#10  
OP Junior Member
Thanks Meter: 4
 
More
I recompiled the kernel by applying you patch. Here is the dmesg output.

Code:
<6>[  241.454376] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
<7>[  241.454650] ehci_hcd: block sizes: qh 60 qtd 96 itd 160 sitd 96
<7>[  241.455200] initializing MSM7201/QSD8X50 USB Controller
<6>[  241.471252] msm_hsusb msm_hsusb: Qualcomm MSM7201/QSD8X50 On-Chip EHCI Host Controller
<7>[  241.472045] drivers/usb/core/inode.c: creating file 'devices'
<7>[  241.472412] drivers/usb/core/inode.c: creating file '001'
<6>[  241.473083] msm_hsusb msm_hsusb: new USB bus registered, assigned bus number 1
<7>[  241.473785] msm_hsusb msm_hsusb: reset command 080002 (park)=0 ithresh=8 period=1024 Reset HALT
<7>[  241.474548] msm_hsusb msm_hsusb: park 0
<7>[  241.475189] msm_hsusb msm_hsusb: reset command 080b02 park=3 ithresh=8 period=1024 Reset HALT
<6>[  241.475555] msm_hsusb_phy_reset
<7>[  241.531097] msm_hsusb msm_hsusb: ...powerdown ports...
<6>[  241.561157] msm_hsusb msm_hsusb: irq 58, io mem 0xa0800000
<7>[  241.581268] usb usb1: default language 0x0409
<7>[  241.581390] usb usb1: udev 1, busnum 1, minor = 0
<6>[  241.581512] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
<6>[  241.581695] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
<6>[  241.581909] usb usb1: Product: Qualcomm MSM7201/QSD8X50 On-Chip EHCI Host Controller
<6>[  241.582000] usb usb1: Manufacturer: Linux 2.6.32.15-g7507bb0 ehci_hcd
<6>[  241.582214] usb usb1: SerialNumber: msm_hsusb
<7>[  241.582550] usb usb1: uevent
<7>[  241.584045] usb usb1: usb_probe_device
<6>[  241.584167] usb usb1: configuration #1 chosen from 1 choice
<7>[  241.584289] usb usb1: adding 1-0:1.0 (config #1, interface 0)
<7>[  241.584564] usb 1-0:1.0: uevent
<7>[  241.585845] hub 1-0:1.0: usb_probe_interface
<7>[  241.586059] hub 1-0:1.0: usb_probe_interface - got id
<6>[  241.586181] hub 1-0:1.0: USB hub found
<6>[  241.586364] hub 1-0:1.0: 1 port detected
<7>[  241.586547] hub 1-0:1.0: standalone hub
<7>[  241.586639] hub 1-0:1.0: individual port power switching
<7>[  241.586761] hub 1-0:1.0: individual port over-current protection
<7>[  241.586944] hub 1-0:1.0: Single TT
<7>[  241.587066] hub 1-0:1.0: TT requires at most 8 FS bit times (666 ns)
<7>[  241.587249] hub 1-0:1.0: power on to power good time: 20ms
<7>[  241.587371] hub 1-0:1.0: local power source is good
<7>[  241.587585] hub 1-0:1.0: enabling power on all ports
<7>[  241.588592] drivers/usb/core/inode.c: creating file '001'
<4>[  241.588897] ------------[ cut here ]------------
<4>[  241.589019] WARNING: at kernel/irq/manage.c:274 enable_irq+0x4c/0xa0()
<4>[  241.589202] Unbalanced enable for IRQ 58
<4>[  241.589324] Modules linked in: ehci_hcd(+) usbcore
<4>[  241.589782] [<c002d7f8>] (unwind_backtrace+0x0/0xd8) from [<c0063e34>] (warn_slowpath_common+0x48/0x60)
<4>[  241.589996] [<c0063e34>] (warn_slowpath_common+0x48/0x60) from [<c0063e84>] (warn_slowpath_fmt+0x24/0x30)
<4>[  241.590209] [<c0063e84>] (warn_slowpath_fmt+0x24/0x30) from [<c00979f0>] (enable_irq+0x4c/0xa0)
<4>[  241.590423] [<c00979f0>] (enable_irq+0x4c/0xa0) from [<bf021978>] (usb_hcd_msm7201_probe+0x22c/0x2cc [ehci_hcd])
<4>[  241.590637] [<bf021978>] (usb_hcd_msm7201_probe+0x22c/0x2cc [ehci_hcd]) from [<c01b2dc4>] (platform_drv_probe+0x18/0x1c)
<4>[  241.590850] [<c01b2dc4>] (platform_drv_probe+0x18/0x1c) from [<c01b1f84>] (driver_probe_device+0xa0/0x14c)
<4>[  241.591064] [<c01b1f84>] (driver_probe_device+0xa0/0x14c) from [<c01b2090>] (__driver_attach+0x60/0x84)
<4>[  241.591186] [<c01b2090>] (__driver_attach+0x60/0x84) from [<c01b17f8>] (bus_for_each_dev+0x48/0x84)
<4>[  241.591400] [<c01b17f8>] (bus_for_each_dev+0x48/0x84) from [<c01b114c>] (bus_add_driver+0x9c/0x218)
<4>[  241.591613] [<c01b114c>] (bus_add_driver+0x9c/0x218) from [<c01b235c>] (driver_register+0xa8/0x134)
<4>[  241.591827] [<c01b235c>] (driver_register+0xa8/0x134) from [<bf02d0ac>] (ehci_hcd_init+0xac/0x108 [ehci_hcd])
<4>[  241.592041] [<bf02d0ac>] (ehci_hcd_init+0xac/0x108 [ehci_hcd]) from [<c002836c>] (do_one_initcall+0x5c/0x1b4)
<4>[  241.592254] [<c002836c>] (do_one_initcall+0x5c/0x1b4) from [<c008d368>] (sys_init_module+0xb0/0x1dc)
<4>[  241.592376] [<c008d368>] (sys_init_module+0xb0/0x1dc) from [<c0028f00>] (ret_fast_syscall+0x0/0x2c)
<4>[  241.592590] ---[ end trace 1b75b31a2719ed1f ]---
<7>[  241.681396] hub 1-0:1.0: state 7 ports 1 chg 0000 evt 0000
The Following User Says Thank You to gowthamj For This Useful Post: [ View ] Gift gowthamj Ad-Free
19th August 2010, 02:13 AM |#11  
Junior Member
Thanks Meter: 10
 
More
OK good, so you're seeing the same behavior I was.

Do you have the right cables to test plugging anything in? If so, what (if anything) happens when you plug in, say, a hub?
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes