Nexus One USB host driver

robross0606

Senior Member
Feb 22, 2011
181
9
0
Further investigation shows that the issue appears to be in the boot.img builder of dsixda's Android ROM Kitchen. On FRG83G I was able to use the kitchen to expand the boot.img, replace zimage file and compress back to boot.img. However, with GRI40, looks like even if I just expand the stock boot.img and immediately build it again, the resulting file causes the Nexus One to hang on boot as described above. I'm assuming this is some sort of script bug in the ROM kitchen. Need to dredge up some instructions for manually creating a boot.img file...
 
Last edited:

robross0606

Senior Member
Feb 22, 2011
181
9
0
Gingerbread with USB_HOST

Okay, I was wrong again. Turns out the kitchen is able to expand and rebuild a working stock boot.img. Therefore, the problem must be in the custom compiled zimage and not a problem with the kitchen itself. Not sure how to debug the problem without mucking with the kernel some more to enable serial output. I also don't have a serial over USB cable.

I have attached my compiled zimage in case someone wants to test it out.
 

Attachments

Last edited:

Aerohix

New member
Apr 2, 2011
3
0
0
Florianópolis, SC
External Touchscreen Monitor + Ubuntu (?)

Hi All!
I study electronics and know almost nothing about android programming, I just want to know if is it possible, using this USB host drivers I can connect it to an battery powered external touch screen monitor.
To transform my nexus one into a tablet when I'm home or at work so I can do the basic things using ubuntu because I feel irritated with the small screen (3.7") a 12" screen I have would fit it better and Ubuntu already have the drivers for my touch screen digitizer (from an HP Tx2 1020us laptop).
I also could try some programming to implement that driver into android hahaha but that's for another day.
Thank you!
 
Last edited:

robross0606

Senior Member
Feb 22, 2011
181
9
0
In the absence of serial port access to kernel boot messages, is there a way to output kernel boot messages to a log file on the system? Or perhaps directly to the screen and disable the boot images? Any help would be greatly appreciated as I'm completely stuck right now.

I see some work has been done by Sven, but on a Nexus S.

http://sven.killig.de/android/console.html
 
Last edited:

Alt.F4

Member
Apr 6, 2011
9
0
0
Hey,

I'm trying to get USB host working on my N1, but am running into some trouble:

First, I can't seem to find the android ndk 4b on Linux that Sven indicates in his instructions. The latest appears to be 5b. Not sure if this causes any problems.

I replaced the CROSS_COMPILE variable with: /android-ndk-r5b/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin/arm-eabi-

...and it builds, and flashes. But when I try to load the kernel modules, I get a "failed (Exec format error)."

Someone earlier posted about having the same issue (link) , but then he just kind of says he fixed it without saying exactly how.


Using the binaries provided by Sven seems to be giving me a little more luck. I can flash it to my N1, but upon enabling the host driver (/sdcard/drivers/usb/host/ehci-hcd.ko) something crashes and gives me a stack trace:

Code:
<6>[  384.419677] batt:  56%, 3825 mV, -175 mA (-191 avg), 30.3 C, 761 mAh
<6>[  434.481048] batt:  56%, 3830 mV, -254 mA (-200 avg), 30.2 C, 760 mAh
<6>[  486.809295] batt:  55%, 3825 mV, -175 mA (-179 avg), 30.1 C, 756 mAh
<4>[  519.236114] mmc1: Starting deferred resume
<4>[  519.435058] mmc1: Deferred resume completed
<6>[  519.501800] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
<7>[  519.502471] ehci_hcd: block sizes: qh 60 qtd 96 itd 160 sitd 96
<7>[  519.503021] initializing MSM7201/QSD8X50 USB Controller
<6>[  519.523223] msm_hsusb msm_hsusb: Qualcomm MSM7201/QSD8X50 On-Chip EHCI Host Controller
<7>[  519.523773] drivers/usb/core/inode.c: creating file 'devices'
<7>[  519.524444] drivers/usb/core/inode.c: creating file '001'
<6>[  519.524841] msm_hsusb msm_hsusb: new USB bus registered, assigned bus number 1
<7>[  519.525573] msm_hsusb msm_hsusb: reset command 080003 (park)=0 ithresh=8 period=1024 Reset RUN
<7>[  519.526611] msm_hsusb msm_hsusb: park 0
<7>[  519.527008] msm_hsusb msm_hsusb: reset command 080b02 park=3 ithresh=8 period=1024 Reset HALT
<7>[  519.543212] msm_hsusb msm_hsusb: ...powerdown ports...
<6>[  519.573242] msm_hsusb msm_hsusb: irq 58, io mem 0xa0800000
<7>[  519.593261] usb usb1: default language 0x0409
<7>[  519.593688] usb usb1: udev 1, busnum 1, minor = 0
<6>[  519.594055] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
<6>[  519.594726] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
<6>[  519.595397] usb usb1: Product: Qualcomm MSM7201/QSD8X50 On-Chip EHCI Host Controller
<6>[  519.595794] usb usb1: Manufacturer: Linux 2.6.32.9-27240-gbca5320-dirty ehci_hcd
<6>[  519.596466] usb usb1: SerialNumber: msm_hsusb
<7>[  519.597503] usb usb1: uevent
<7>[  519.600311] usb usb1: usb_probe_device
<6>[  519.600708] usb usb1: configuration #1 chosen from 1 choice
<7>[  519.601409] usb usb1: adding 1-0:1.0 (config #1, interface 0)
<7>[  519.602050] usb 1-0:1.0: uevent
<7>[  519.606536] hub 1-0:1.0: usb_probe_interface
<7>[  519.607208] hub 1-0:1.0: usb_probe_interface - got id
<6>[  519.607574] hub 1-0:1.0: USB hub found
<6>[  519.608062] hub 1-0:1.0: 1 port detected
<7>[  519.608673] hub 1-0:1.0: standalone hub
<7>[  519.609039] hub 1-0:1.0: individual port power switching
<7>[  519.609680] hub 1-0:1.0: individual port over-current protection
<7>[  519.610046] hub 1-0:1.0: Single TT
<7>[  519.610412] hub 1-0:1.0: TT requires at most 8 FS bit times (666 ns)
<7>[  519.611083] hub 1-0:1.0: power on to power good time: 20ms
<7>[  519.611480] hub 1-0:1.0: local power source is good
<7>[  519.612152] hub 1-0:1.0: enabling power on all ports
<7>[  519.614685] drivers/usb/core/inode.c: creating file '001'
<4>[  519.615661] ------------[ cut here ]------------
<4>[  519.616058] WARNING: at kernel/irq/manage.c:274 enable_irq+0x5c/0xb4()
<4>[  519.616699] Unbalanced enable for IRQ 58
<4>[  519.617065] Modules linked in: ehci_hcd(+) usbcore
<4>[  519.618713] [<c002bb00>] (unwind_backtrace+0x0/0xd8) from [<c0057158>] (warn_slowpath_common+0x48/0x60)
<4>[  519.619171] [<c0057158>] (warn_slowpath_common+0x48/0x60) from [<c00571a8>] (warn_slowpath_fmt+0x24/0x30)
<4>[  519.619873] [<c00571a8>] (warn_slowpath_fmt+0x24/0x30) from [<c008bd14>] (enable_irq+0x5c/0xb4)
<4>[  519.620635] [<c008bd14>] (enable_irq+0x5c/0xb4) from [<bf0218ac>] (usb_hcd_msm7201_probe+0x22c/0x2cc [ehci_hcd])
<4>[  519.621398] [<bf0218ac>] (usb_hcd_msm7201_probe+0x22c/0x2cc [ehci_hcd]) from [<c01b7f30>] (platform_drv_probe+0x18/0x1c)
<4>[  519.622131] [<c01b7f30>] (platform_drv_probe+0x18/0x1c) from [<c01b70ec>] (driver_probe_device+0xa0/0x14c)
<4>[  519.622863] [<c01b70ec>] (driver_probe_device+0xa0/0x14c) from [<c01b71f8>] (__driver_attach+0x60/0x84)
<4>[  519.623565] [<c01b71f8>] (__driver_attach+0x60/0x84) from [<c01b6954>] (bus_for_each_dev+0x48/0x84)
<4>[  519.623992] [<c01b6954>] (bus_for_each_dev+0x48/0x84) from [<c01b62a8>] (bus_add_driver+0x9c/0x218)
<4>[  519.624725] [<c01b62a8>] (bus_add_driver+0x9c/0x218) from [<c01b74c4>] (driver_register+0xa8/0x138)
<4>[  519.625457] [<c01b74c4>] (driver_register+0xa8/0x138) from [<bf02d0ac>] (ehci_hcd_init+0xac/0x108 [ehci_hcd])
<4>[  519.626220] [<bf02d0ac>] (ehci_hcd_init+0xac/0x108 [ehci_hcd]) from [<c002637c>] (do_one_initcall+0x5c/0x1b4)
<4>[  519.626922] [<c002637c>] (do_one_initcall+0x5c/0x1b4) from [<c00812f4>] (sys_init_module+0xb0/0x1dc)
<4>[  519.627655] [<c00812f4>] (sys_init_module+0xb0/0x1dc) from [<c0026f40>] (ret_fast_syscall+0x0/0x2c)
<4>[  519.628051] ---[ end trace 048932ae2a6b9568 ]---
<7>[  519.703338] hub 1-0:1.0: state 7 ports 1 chg 0000 evt 0000
<6>[  536.891387] batt:  55%, 3815 mV, -187 mA (-201 avg), 30.1 C, 753 mAh
<6>[  586.949249] batt:  55%, 3815 mV, -190 mA (-195 avg), 30.0 C, 752 mAh
Peering through the log, it appears to recognize the local USB hardware, and then also recognize the powered USB hub I'm using too. But the crash is troubling. I tried looking through some of the functions that the stack trace pointed to, but it wasn't immediately clear what the problem was.

Edit: Ultimately, I'm trying to make both USB host and usbnet work. So I can have the N1 sending IP packets over the usb port as host to a device that's a usb slave. Thanks!

Edit2: Actually, I see Sven says to ignore the above stack trace. So never mind about that. Hmm, the N1 still fails to recognize any devices I insert. No activity in dmesg when I insert a USB mouse or keyboard after enabling usbhid.ko, nothing from m usb flash stick after I enable usb mass storage, etc...
 
Last edited:

Alt.F4

Member
Apr 6, 2011
9
0
0
Okay, so I managed to get Sven's binaries to work. I'm actually not sure what I was doing wrong. :( Wish I could report what the issue was. It just seems to work now when I flash them over. Perhaps I was using the wrong image, or rebooting after a ramboot or something? Dunno.

My hardware setup is essentially the same as what others have been posting:
N1 Plugged into a Powered USB Hub. Dual USB cord to provide upstream power to the N1.


I still cannot seem to get a build to work from source, however. I can build (using the r5b version of the NDK as stated above) and flash it to the phone.

If I try to insmod the the usbcore.ko provided by Sven, I get a "Failed (Exec format error)". dmesg says: "usb version magic '2.6.32.9-27240-gbca5320-dirty preempt mod_unload ARMv7 ' should be '2.6.32.9-27242-g4c0d547-dirty preempt mod_unload ARMv7 ' But that's probably to be expected.

When I try to insmod the usbcore.ko built from source, I get "failed (No such file or directory)" with dmesg saying "usbcore: Unknown symbol _GLOBAL_OFFSET_TABLE_"
 

n8loller

New member
Apr 25, 2011
2
1
0
...
First, I can't seem to find the android ndk 4b on Linux that Sven indicates in his instructions. The latest appears to be 5b. Not sure if this causes any problems.

I replaced the CROSS_COMPILE variable with: /android-ndk-r5b/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin/arm-eabi-
...
Google is being tricksy with it. Though they don't provide a link to it anymore, they still host version r4b to download at... ok so they wont let me post links yet, and I haven't found a way around their parsing... so go to the download site for android ndk version r5b, then replace the file name in the download link with "android-ndk-r4b-linux-x86.zip"...

I ran into the problem too, and it took me a while to find somewhere to download r4b... just to find Google still hosting it. However, I wasn't able to find this alternative directory in r5b as you did.
 
  • Like
Reactions: Alt.F4

n8loller

New member
Apr 25, 2011
2
1
0
I've been running into problems left and right trying to get this working on my motorola droid (original). I am running:

Android: 2.2.1
Baseband: C_01.43.01P
Kernel: 2.6.32.9-cm-stk [email protected]#1
Mod: CyanogenMod-6.1.2-Droid
Build: FRG83D

It took me a while just to get the sdk, source, and ndk on my machine and able to be compiled... then once it worked, I tried to load it onto my phone and that didn't work either.

I am pretty sure from reading random web sites that my phone doesn't support fastboot, so I tried using flash_image instead. That gave me more errors, so I decided to load the boot.img using nandroid (I had to spoof the md5 checksum for that to work).

Once that got on, my phone would just boot to the moto logo and do nothing indefinitely (5 minutes at least).

I tried with your pre-compiled image and with one I build myself with the same results. Is there anything that I said that immediately raises a red flag?

edit:

Well for one thing, I assume the "msm" in "kernel_msm" means this is intended for the Qualcomm chips (I'm guessing if I checked what the hardware was for your phone, I'd see a Snapdragon or similar), where my phone has the ARM Cortex A8. I can see that being a problem... Is there anywhere that you have noted what files you changed from the msm kernel base to get USB working so I could try to mirror that in the generic kernel (or whichever is intended for my phone)?
 
Last edited:

Alt.F4

Member
Apr 6, 2011
9
0
0
Google is being tricksy with it. Though they don't provide a link to it anymore, they still host version r4b to download at... ok so they wont let me post links yet, and I haven't found a way around their parsing... so go to the download site for android ndk version r5b, then replace the file name in the download link with "android-ndk-r4b-linux-x86.zip"...

I ran into the problem too, and it took me a while to find somewhere to download r4b... just to find Google still hosting it. However, I wasn't able to find this alternative directory in r5b as you did.
That did the trick. I downloaded the r4b NDK and it just worked. I just went ahead with the build like normal from Sven's website and it built, flashed and installed. USB HID (keyboard / mouse) and USB storage working.
 

hedpe

Senior Member
Jan 24, 2008
249
12
0
has anyone figured out if it's possible to make udev rules for USB devices?

on my Droid, there is no /etc/udev

So I created /etc/udev/udev.conf and /etc/udev/rules.d with rules in there. For example, to mount a USB drive to a specific place when it's connected.

However, it seems as though Android is completely ignoring my set of udev rules.

Maybe they are located somewhere else? I have searched all over the place, and can't find anything related.
 

hnk1234

New member
May 21, 2011
1
0
0
thanks for the great work, it works fine with my nexus one.
now i want to communicate/receive data from a SunSPOT (9600 baud, 8 data bits, 1 stop bit, no parity). any suggestions how to use the serial port for this?
 

Pwl10

New member
Nov 5, 2010
3
0
0
I'm trying to enable USB host feature on Samsung I5500. It has MSM7227 SoC - the same has ZTE Blade where Sven has already enabled it. So, I'm full of inspiration.

Just a few questions to heroes, who already have some experience.
1. Is it necessary to build and flash new kernel? Is it not enough to build required modules (at least usbcore.ko and ehci-hcd.ko) and load it with original kernel manually?
2. It's clear that in .config file we need to enable USB hosting. But do we need to disable something, e.g. USB gadgets?
3. Just to confirm. We need to "insmod" modules when the device (e.g. flash drive) is already connected to the phone. Is it right?
4. How can I confirm that the USB host driver is loaded properly?
Are there any signs in the system if there is not enough power on the USB port to detect the connected device? I'm using Y-cable with 5V-1A DC - not sure if this is enough to charge the phone and power the flash drive.

If someone could paste the dmesg log of this procedure it would be really helpful.

Wow, a bit more than a few but I really appreciate any help :)

Cheers,
Pavel