FORUMS
Remove All Ads from XDA
H10 Turbo

[Guide]USB Host Enabled Kernel for the G1/Dream

25 posts
Thanks Meter: 1
 
By kodovoimeji, Junior Member on 29th September 2010, 10:08 AM
Post Reply Email Thread
HOWTO: Compile USB Host Enabled Kernel for the G1/Dream

Hi everyone,
I've got my new HTC Dream and I love it. It's my first Android based device. Now I'm running CyanogenMod 6 Rom.

So this is what I have:
Model number: HTC Dream
Andreoid ver: 2.2
Kermel ver: 2.6.34.5-cynogenmod
Mod version: CyanodenMod-6.0.0-DS
Build number: FRF91

I followed these guides to compile usb host enabled kernel. Please thank Andrew de Quincey, Sven Killig , Michael Mitchell and Frank Sposaro for their awesome work.

Preparing Android Build Environment

mkdir ~/cm-kernel-usbhost/
cd ~/cm-kernel-usbhost/
git clone git://github.com/CyanogenMod/cm-kernel.git
cd cm-kernel
git branch -r
git checkout --track -b cm-2.6.34 origin/android-msm-2.6.34

Patch the kernel source tree

wget http://sven.killig.de/android/N1/2.2...usb-host.patch
patch -p1 < android-kernel_msm-bca5320_Nexus-One_usb-host.patch

open ~/cm-kernel-usbhost/ cm-kernel /drivers/usb/host/ehci-msm7201.c and delete line 313

Export a variable for the ARM cross compiler

export CCOMPILER=~/android-ndk-r4b/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/arm-eabi-

Download kernel .config here and move to .config
Edit!: Use attached config file!

mv g1-cm-kern-2.6.34-usbhost.config .config

Then start the build:

make ARCH=arm CROSS_COMPILE=$CCOMPILER

At this point you should have a kernel stored in ~/cm-kernel-usbhost/cm-kernel/arch/arm/boot/zImage
Now, get the kernel on the phone:

I use fastboot to boot from RAM (not persistent)

~/android-sdk-linux_86/tools/fastboot boot arch/arm/boot/zImage


Look above at the output from the kernel build. The last thing completed is the module building (total = modpost). Notice the hierarchal structure of the compiled modules within the filesystem. Ex: /system/drivers/usb/core/usbcore.ko

Copy modules to sdcard

Now we need to load the modules into the running kernel.

Open a terminal emulator on the phone (connectbot also works, connect to local)

get root:
su

then load the usb core and ehci modules:

insmod /sdcard/usbcore.ko
insmod /sdcard/ehci-hcd.ko

You can download compiled kernel and modules here.
Hope that this guide will be helpful to newbies like me.
Regards,
Andy

NB!
This kernel currently disables USB mount and adb over USB.
usb-storage.ko module is loaded fine but when a usb flash drive is pluged-in the phone reboots itself.
You need a powered hub or Y-cable and USB A Female / A Female Adaptor to connect your usb devices.
Now wifi is working!

UPDATE: 11.12.2010
How to make an OTA package and switch between usb host and otg.

wget ww2.cs.fsu.edu/~mitchell/android/ZipBuilder.tar
tar -xvf ZipBuilder.tar
cd ZipBuilder
./builder.sh
rename update_signed.zip usbhost_signed.zip and copy it to sd card.

make a Nandorid backup and split boot.img using split_bootimg.pl
rename boot.img-kernel to zImage and copy it to ~/cm-kernel-usbhost/cm-kernel/arch/arm/boot/
than run ./builder.sh again
rename update_signed.zip to otg_signed.zip and copy it to sd card.

Now you can flash these zip from recovery.
Attached Files
File Type: txt G1-Usb-Host.config.txt - [Click for QR Code] (50.3 KB, 492 views)
File Type: txt G1-usb-host-modules-copy.sh.txt - [Click for QR Code] (477 Bytes, 293 views)
File Type: zip otg_signed.zip - [Click for QR Code] (2.44 MB, 502 views)
File Type: zip usbhost_signed.zip - [Click for QR Code] (2.46 MB, 558 views)
 
 
firefly123
2nd October 2010, 06:34 AM |#2  
Guest
Thanks Meter: 0
 
More
Any luck with Sven's img?
3rd October 2010, 06:40 PM |#3  
OP Junior Member
Thanks Meter: 1
 
More
Yes, I tried to boot Sven's zImage but without success.
So now I'm trying to compile android-msm-2.6.34 kernel pathced with Sven's patch file.
The patch was successfully applied but when I started compilling this error occured:

In file included from drivers/usb/host/ehci-hcd.c:1153:
drivers/usb/host/ehci-msm7201.c: In function 'usb_hcd_msm7201_probe':
drivers/usb/host/ehci-msm7201.c:313: error: 'struct msm_hsusb_platform_data' has no member named 'phy_shutdown'

I don't know how and where to add this member.
I'd appreciate some help.
Regards Andy
Attached Files
File Type: txt g1_cm-kern-2.6.34-usbhost.config.txt - [Click for QR Code] (55.0 KB, 139 views)
File Type: txt ehci-msm7201.c.txt - [Click for QR Code] (10.2 KB, 98 views)
File Type: txt ehci-msm7201.h.txt - [Click for QR Code] (1.5 KB, 78 views)
The Following User Says Thank You to kodovoimeji For This Useful Post: [ View ] Gift kodovoimeji Ad-Free
3rd October 2010, 06:58 PM |#4  
sonic74's Avatar
Senior Member
Flag Schwabach
Thanks Meter: 18
 
Donate to Me
More
Quote:
Originally Posted by kodovoimeji

In file included from drivers/usb/host/ehci-hcd.c:1153:
drivers/usb/host/ehci-msm7201.c: In function 'usb_hcd_msm7201_probe':
drivers/usb/host/ehci-msm7201.c:313: error: 'struct msm_hsusb_platform_data' has no member named 'phy_shutdown'

This seems to be defined only in the Hero Kernel. Delete line 313.
4th October 2010, 01:05 PM |#5  
OP Junior Member
Thanks Meter: 1
 
More
Thank you very much for quick reply!!!
Now everything is OK!
I used fastboot to boot from RAM and then load the usb core and ehci modules.
And...yeeeeeeee now my G1 is usb host device!
I'm using Y-cable from my external HDD.
I must compile some modules like usb-storage and start testing.
My usb mouse works great with usbhid.ko.
Thank you again!

P.S. I'll update the first post soon!
7th October 2010, 09:18 AM |#6  
Junior Member
Thanks Meter: 0
 
More
Smile
That's Great~! I've found this for several months! Could you post your detailed tutorial for us? I think most G1 owner should want it. Maybe, you could make a special patch for the roms of CM 6, and everyone could update kernel more effortlessly.

Cheers!

Fox
11th October 2010, 01:01 PM |#7  
OP Junior Member
Thanks Meter: 1
 
More
I updated the first post and now you can download compiled kernel-2.6.34 and modules.
I tried usb-storage.ko but when I pluged my usb flash drive the phone reboot itself.
11th October 2010, 02:58 PM |#8  
sonic74's Avatar
Senior Member
Flag Schwabach
Thanks Meter: 18
 
Donate to Me
More
Question
Quote:
Originally Posted by kodovoimeji

I tried usb-storage.ko but when I pluged my usb flash drive the phone reboot itself.

Is there something in /data/dontpanic directly after the reboot?
12th October 2010, 08:14 PM |#9  
OP Junior Member
Thanks Meter: 1
 
More
Quote:
Originally Posted by sonic74

Is there something in /data/dontpanic directly after the reboot?

No, it's empty.
I load these modules: usbcore.ko, ehci-hcd.ko, usb-libusual.ko, usb-storage.ko.
Usb-storage.ko depends on usb-libusual.ko

I'm curious if it's possible to run my ACR122 contactless smartcard reader.
I installed Debian Leny and ACR drivers on sdcard as I do on my PC.
This is the output when I run dmesg:
Quote:

[ 196.719024] msm_hsusb msm_hsusb: GetStatus port 1 status 80001803 POWER sig=j CSC CONNECT
[ 196.719573] hub 1-0:1.0: port 1: status 0101 change 0001
[ 196.819427] hub 1-0:1.0: state 7 ports 1 chg 0002 evt 0000
[ 196.820007] hub 1-0:1.0: port 1, status 0101, change 0000, 12 Mb/s
[ 196.939056] usb 1-1: new full speed USB device using msm_hsusb and address 2
[ 197.089111] usb 1-1: ep0 maxpacket = 8
[ 197.093750] usb 1-1: skipped 1 descriptor after interface
[ 197.095733] usb 1-1: default language 0x0409
[ 197.098724] usb 1-1: udev 2, busnum 1, minor = 1
[ 197.099426] usb 1-1: New USB device found, idVendor=072f, idProduct=90cc
[ 197.100280] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 197.100769] usb 1-1: Product: CCID USB Reader
[ 197.101593] usb 1-1: Manufacturer:
[ 197.106353] usb 1-1: usb_probe_device
[ 197.106872] usb 1-1: configuration #1 chosen from 1 choice
[ 197.108795] usb 1-1: adding 1-1:1.0 (config #1, interface 0)
[ 197.116180] drivers/usb/core/inode.c: creating file '002'
[ 197.117492] hub 1-0:1.0: state 7 ports 1 chg 0000 evt 0002

But I can't see it when I run lsusb.
This is the output of pcscdaemon:
Quote:

00000000 pcscdaemon.c:280:main() pcscd set to foreground with debug send to stderr
00000336 debuglog.c:239: DebugLogSetLevel() debug level=debug
00018596 pcscdaemon.c:498:main() pcsc-lite 1.4.102 deamon ready
01416524 hotplug_libhal.c:460:HPRegisterForHotplugEvents() error: dbus_bus_get: org.freedesktop.DBus.Error.NoServer: Failed to connect to socket /var/run/dbus/system_bus_socket: Connection refused
00000244 pcscdaemon.c:517:main() SVCServiceRunLoop returned
00000091 pcscdaemon.c523:at_exit() cleaning /var/run/pcscd

13th October 2010, 12:03 AM |#10  
sonic74's Avatar
Senior Member
Flag Schwabach
Thanks Meter: 18
 
Donate to Me
More
Quote:
Originally Posted by kodovoimeji

Usb-storage.ko depends on usb-libusual.ko

Strange, I haven't seen this module yet.

Quote:
Originally Posted by kodovoimeji

But I can't see it when I run lsusb.

You have to do

Code:
mount -t usbfs none /proc/bus/usb
13th October 2010, 11:45 PM |#11  
OP Junior Member
Thanks Meter: 1
 
More
Hi again,
thanks for your help. It seems that usb-storage.ko depends on usb-libusual.ko only when this modul is selected. I compiled kernel with build-in usb-storage but no matter i do my phone reboots after I pluged-in a usb flash storage. /data/dontpanic is empty.

Code:
mount -t usbfs none /proc/bus/usb
Now I can use lsusb.
I looked at .config but didn't find something about smartcard reader so if I manage to sort out drivers in Debian will it start working?

Kind regards
Andy
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