Introducing XDA:DevCon – A Conference For Developers By Developers
XDA Developers Android and Mobile Development Forum
Forgot your password?
 
Post Reply+
Tip us?
 
kodovoimeji
Old
(Last edited by kodovoimeji; 11th December 2010 at 07:02 PM.) Reason: Update
#1  
Junior Member - OP
Thanks Meter 0
Posts: 25
Join Date: Aug 2006
Default [Guide]USB Host Enabled Kernel for the G1/Dream

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, 328 views)
File Type: txt G1-usb-host-modules-copy.sh.txt - [Click for QR Code] (477 Bytes, 162 views)
File Type: zip otg_signed.zip - [Click for QR Code] (2.44 MB, 278 views)
File Type: zip usbhost_signed.zip - [Click for QR Code] (2.46 MB, 325 views)
firefly123 Old
#2  
Guest
Thanks Meter
Posts: n/a
Any luck with Sven's img?
 
kodovoimeji
Old
#3  
Junior Member - OP
Thanks Meter 0
Posts: 25
Join Date: Aug 2006
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, 74 views)
File Type: txt ehci-msm7201.c.txt - [Click for QR Code] (10.2 KB, 38 views)
File Type: txt ehci-msm7201.h.txt - [Click for QR Code] (1.5 KB, 25 views)
 
sonic74
Old
(Last edited by sonic74; 3rd October 2010 at 07:17 PM.)
#4  
sonic74's Avatar
Senior Member
Thanks Meter 17
Posts: 161
Join Date: Jan 2010
Location: Schwabach

 
DONATE TO ME
Quote:
Originally Posted by kodovoimeji View Post
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.
 
kodovoimeji
Old
#5  
Junior Member - OP
Thanks Meter 0
Posts: 25
Join Date: Aug 2006
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!
 
fox0001
Old
(Last edited by fox0001; 7th October 2010 at 09:22 AM.)
#6  
Junior Member
Thanks Meter 0
Posts: 9
Join Date: May 2010
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
 
kodovoimeji
Old
#7  
Junior Member - OP
Thanks Meter 0
Posts: 25
Join Date: Aug 2006
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.
 
sonic74
Old
#8  
sonic74's Avatar
Senior Member
Thanks Meter 17
Posts: 161
Join Date: Jan 2010
Location: Schwabach

 
DONATE TO ME
Quote:
Originally Posted by kodovoimeji View Post
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?
 
kodovoimeji
Old
#9  
Junior Member - OP
Thanks Meter 0
Posts: 25
Join Date: Aug 2006
Quote:
Originally Posted by sonic74 View Post
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
 
sonic74
Old
#10  
sonic74's Avatar
Senior Member
Thanks Meter 17
Posts: 161
Join Date: Jan 2010
Location: Schwabach

 
DONATE TO ME
Quote:
Originally Posted by kodovoimeji View Post
Usb-storage.ko depends on usb-libusual.ko
Strange, I haven't seen this module yet.

Quote:
Originally Posted by kodovoimeji View Post
But I can't see it when I run lsusb.
You have to do

Code:
mount -t usbfs none /proc/bus/usb

 
Post Reply+
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Go to top of page...

XDA PORTAL POSTS

Preventing App Piracy: Join the Discussion

The topic of piracy is always a touchy subject, but I feel that the grass roots style of Android … more

Jolla Sailfish OS Flagship Device Makes First Appearance

Given the amount of coverage that Android receives around here, you could almost be … more

XDA University: Porting ClockworkMod Recovery to New Devices

Having a good recovery makes the process of modifying, tweaking, maintaining, … more

One Stop Guide Shop for the Newbie and Dev

It’s been well established that XDA-Developers isthedestination for resources relating to … more