HTC Desire

HTC Desire Patches

My work on the USB Hostmode for the HTC Desire is based on the patch provided by Sven Killig for the Nexus one:

http://sven.killig.de/android/N1/2.2/usb_host/

Basically Sven’s patch also works for the HTC Desire. However since there has been a small change in the Kernel API for Kernel 3.6.37, I had to amend one line of the patch in order to make it work on the new kernel version.

Downloads:

Patches Available:

Kernels Available:
The discussion about this is going on at xda-developers.com:

 

Even though I did not have any problems with these patches and kernels so far, I cannot guarantee for any damage to your devices. Applying the provided kernel or any of the patches to your device and following any guide I provide happens on your own risk.

 

Using the Host mode

 

In my version of the Kernel, USB host mode is only available as a kernel module. I also had a version of the Kernel, where it was compiled right in the kernel but that resulted in having to connect at least a USB hub before booting the device. The advantage of using modules is that it is only required to connect the USB device before inserting the module into the kernel.

To load Hostmode, enter the following lines in a shell on your Desire:

insmod /system/lib/modules/$(uname -r)/kernel/drivers/usb/core/usbcore.ko
insmod /system/lib/modules/$(uname -r)/kernel/drivers/usb/host/ehci-hcd.ko

Connecting a USB mass storage device

After installing the above kernel you can connect USB mass storage to your HTC-Desire.

Connect your USB mass storage device to your HTC-Desire

Open a shell and enter:

insmod /system/lib/modules/$(uname -r)/kernel/drivers/usb/core/usbcore.ko
insmod /system/lib/modules/$(uname -r)/kernel/drivers/usb/host/ehci-hcd.ko
insmod /system/lib/modules/$(uname -r)/kernel/drivers/scsi/scsi_wait_scan.ko
insmod /system/lib/modules/$(uname -r)/kernel/drivers/scsi/scsi_mod.ko
insmod /system/lib/modules/$(uname -r)/kernel/drivers/scsi/sd_mod.ko
insmod /system/lib/modules/$(uname -r)/kernel/drivers/usb/storage/usb-storage.ko

Navigate to /dev/block and check if you have a sda1 in there. This is of course only for the first mass storage device. The second one is called sdb1 and so on. The following assumes that we take the first device. For all other devices, you will have to adjust the guide a little bit.

Load the filesystems:

insmod /system/lib/modules/$(uname -r)/kernel/fs/ntfs.ko
insmod /system/lib/modules/$(uname -r)/kernel/fs/msdos.ko

So far, I only included FAT and NTFS as modules. Ext4 is built in. If you need any other file systems, please ask below in the comments area and I can compile them for you.

To mount your disk, you first need a folder you want to mount into. I chose to create a folder “mnt” on my sdcard. Then issue one of the following commands:

mount -t vfat /dev/block/sda1 /mnt/sdcard/mnt/
mount -t ntfs /dev/block/sda1 /mnt/sdcard/mnt/

depending on weather you have a NTFS of FAT Filesystem.

Now you should be able to access the files on your USB mass storage device.

WLAN sleep off

In my scenario, I need the WLAN to be running all the time without switching to sleep. This is only necessary if you are connecting to an ad-hoc network. In a managed network the base station will make sure you still receive the packets, even if the WLAN goes to sleep.

I wrote a small patch, that simply disables the sleeping function of the WLAN driver. It can be found above.

 

Changelog

  • Du kannst diese HTML tags verwenden: <a> <abbr> <acronym> <b> <blockquote> <cite> <code> <del> <em> <i> <q> <strike> <strong>

  • #95 geschrieben von Tim  vor 4 Monaten

    The built in ifconfig is somewhat broken. It does work but only limited. That’s why I installed a busy box on my own which includes a correctly working ifconfig.
    I uploaded it here: http://tim.mactory.com/HTC_Desire/busybox.zip

    Unzip, push it to your phone and execute e.g. to /data:
    adb push busy box /data/busybox
    Then run it with:
    /data/busybox ifconfig

    See what it tells you. You might also have to reconfigure the routes, but let’s start with seeing weather the network is found at all.

  • #96 geschrieben von renderit  vor 4 Monaten

    Another trouble,sorry, about usbnet.After load mii.ko usbnet.ko and asix.ko, disable wifi, I think I would have a ether net ( I type “netcfg” in terminal console) ,but none.
    Any tips? Wish my endless question not put you too much trouble. IMO, after load the mdules, plug in a usb to RJ45,config IP, then I can use network.

  • #97 geschrieben von renderit  vor 4 Monaten

    Yes,Now simply specify iocharset=utf8 work fine for me.I test with a 1000GB WEST Digital elements SE USB HD,fat32, All work fine.

  • #98 geschrieben von Tim  vor 4 Monaten

    Hey,
    you were right, there was just one codepage and charset compiled into the kernel. Now I enabled all of them and recompiled the kernel. You can download it above: http://tim.mactory.com/HTC_Desire/2.6.37_host_mod.zip
    It also contains the mii.ko and the other two files needed for the usb networking.
    If you figured out if the codepages now work, I would be glad if you reported back here :)
    Thanks

  • #99 geschrieben von renderit  vor 4 Monaten

    Hi,Tim,I googled, I guess when you complied the filesystem kernel,you forgot have the
    Native Language Support —>
    iocharset and codepage checked.SoWhen I mount , I can not specify the -o iocharset=utf8,codepage=936,it return “Invalid Argument”.

  • #100 geschrieben von Tim  vor 4 Monaten

    I don’t have your device and no experience weather it is possible to use it as USB-Host. If it has the same chipset as the Desire, the patches might work.
    Maybe this Forum can help:
    http://forum.xda-developers.com/showthread.php?t=1212437

  • #101 geschrieben von st11lgar  vor 4 Monaten

    USB Host doesn’t work on my G2/Desire-Z running ICS :(

    Would I be able to apply these or similar modules for my device?

    I have a OTG cable and an external usb sensor that needs power form the G2…

    I’m willing to test anything that might bring me this feature on the device…

    Thanks
    Stilgar

  • #102 geschrieben von renderit  vor 4 Monaten

    yes,mill.ko solve the problem.Great,I will test usb network ,I wish it faster than wifi.

  • #103 geschrieben von Tim  vor 4 Monaten

    I think the mii.ko module was the problem. After loading this first, i was able to load usbnet.ko.
    I have sent it to you via E-Mail. Please check weather it is working for you.

  • #104 geschrieben von renderit  vor 4 Monaten

    Never mind.I prefer change the file name to match the filesystem.I just google that, one way is using “convmv “in a linux system to convert the coding of all the file name. Another way is making a ftp , upload my files to Desire,then the file name should be right. I think your kernel and the modules(except the usbnet.ko and asix.ko) work great,stable enough.Thanks very much.

  • #105 geschrieben von Tim  vor 4 Monaten

    Now there is something I have no Idea of. You will probably need to google that.

    When compiling, I can specify a default iocharset and codepage for FAT, but no such options for NTFS. You might be able to change the charsets when loading the module or when mounting a disk, but like I said… you will need to google that.

  • #106 geschrieben von renderit  vor 4 Monaten

    The filesystem mudules has the -o specified build in,but this make things confused.Some file name coded with GBK(or GB2312),but other with UTF8,or Gig5.Only one of them can been displaced correctly.Could all those code page been supported,or can I specify the “-0 iocharset” and the codepage parameter when I mount the mass storage? Now, there are a lot of ? in my file name.

  • #107 geschrieben von Tim  vor 4 Monaten

    Nice. I will probably integrate those Modules later today into my Kernel packages and the webpage.
    Thank you for your help.

  • #108 geschrieben von renderit  vor 4 Monaten

    80 G fat disk work too. I will test stablility(transfer huge mount of files through samba or ftp) tomorrow.
    I cant load the usbnet.ko or asix.ko,it say:No such file or directory,ps I need load another modules first,but which one?

  • #109 geschrieben von renderit  vor 4 Monaten

    10G NTFS work too.A 10 G hard disk and a flash work at the same time too.
    I found some file explorer can not seen any files in the NTFS disk,ie ,File Expert,IO About,But Root explorer work better.
    40 G NTFS can mount ,but can not list all files( root exploere),as my test,only one file can been listed on my 40 G disk.

  • #110 geschrieben von Tim  vor 4 Monaten

    Great :) I only tested it with FAT32 since I have a Mac and cannot format as NTFS. Did you use NTFS?

  • #111 geschrieben von renderit  vor 4 Monaten

    O,Now it work for a 10G fat hard disk.Good.

  • #112 geschrieben von renderit  vor 4 Monaten

    I tested.I flash a new cyanogenmod 7.10,step by step ,carefully,the sda1 (and a sda too)apear in the /dev/block,but when I mount,nothing apear in target folder.

  • #113 geschrieben von Tim  vor 4 Monaten

    I sent an E-Mail to you with a Kernel to test, that also contains your usbnet and asia modules.
    It would be great if you could test it on your phone.

  • #114 geschrieben von renderit  vor 4 Monaten

    Lack of filesystem kernel modules? O,will support NTFS? expect it.

  • #115 geschrieben von Tim  vor 4 Monaten

    The problem could be, that I did not include any filesystem kernel modules with the kernel. I should do that ;)
    I will then also compile the two modules you wanted for you.

  • #116 geschrieben von renderit  vor 4 Monaten

    Would you compile usbnet.ko and asix.ko for cm 7 (2.6.37 kernel) for me? Thx.

  • #117 geschrieben von renderit  vor 4 Monaten

    Look at here,http://forum.xda-developers.com/archive/index.php/t-993152.html

    torsrex wrote: wohoo! Now I got around 200gB on my phone! (yes you saw right, 200gB!). on Desire HD,

    Make usb mass storage working on Desire is so Attractive for me , I am a newbie .
    If usb mass storage work, then I can use my Desire as a file server for my Ipad.

  • #118 geschrieben von renderit  vor 4 Monaten

    When I plugin a usb device , a new number appear in dev/bus/usb/001,like 001,002,003,etc.I think Desire recorgnize them as a device,but can not mount a a a usb disc,so how to manul mount it.

  • #119 geschrieben von Tim  vor 4 Monaten

    Like I said, I have no experience with USB Storage on the Desire.
    I am glad to compile a special kernel for you, if you tell me what kernel options you need activated, I will compile them into the kernel for you.

    Does your USB Mass storage show up in /proc/bus/usb (I think that is the location) ?

  • #120 geschrieben von renderit  vor 4 Monaten

    Sorry for bother you so much!

  • #121 geschrieben von renderit  vor 4 Monaten

    Now, I get a new hub,mouse work fine.but usb storage still not work.

    I check the dmesg:

    [ 476.845520] Initializing USB Mass Storage driver…
    [ 476.846435] scsi0 : usb-storage 1-1.2:1.0
    [ 476.851287] usbcore: registered new interface driver usb-storage
    [ 476.851776] USB Mass Storage support registered.
    [ 477.854522] scsi 0:0:0:0: Direct-Access IBM-DJSA -210 ABBA
    PQ: 0 ANSI: 2 CCS
    [ 870.375854] usb 1-1.4: new high speed USB device using msm_hsusb and addre
    ss 4
    [ 870.696441] scsi1 : usb-storage 1-1.4:1.0
    [ 871.710205] scsi 1:0:0:0: Direct-Access aigo MiniKing 8.07
    PQ: 0 ANSI: 2
    _________________________________
    _________________________________
    There is no sda1 sda2 etc in the /dev , I think the kernel or the modules still lack something to support usb storage?

  • #122 geschrieben von Tim  vor 4 Monaten

    I have not yet used USB Storage, so I cannot help you with that.

  • #123 geschrieben von renderit  vor 4 Monaten

    also ,there is no sda1 etc in the /dev/block,only platform vold loop0 loop1 …..mmcblk1 mmcblkp1 mtdblock1 ……..,so I can’t us “mount -t vfat /dev/block/sda1 /mnt/sdcard/usb-storage” ,no lucky.

  • #124 geschrieben von renderit  vor 4 Monaten

    the usbcore.ko ehci-hcd.ko scsi_mod.ko
    and usb-storage.ko seems loaded(without feed back,no error message), but where is my usbstorage?it should mount as a folder in the mnt?

  • #125 geschrieben von renderit  vor 4 Monaten

    yes,I resign your zip using a java tool(Auto-sign.zip),then flash successfully.Now my kernel version i 2.6.37-cyanogenmod+tim@VirtualBox #1.My phone can not used as a client now.Perhaps, I am near the end.
    but I can not make my usb keyboard or usb storage work.
    perhaps because of the chip of my hub(with a power) is not Compatible. I will try when I get a new hub tomorrow.

  • #126 geschrieben von Tim  vor 4 Monaten

    Yes, you should be able to do that.

    I Googled your problem and found this:
    http://forum.xda-developers.com/showthread.php?p=10309975

    Seems like you need to disable signature verification in your recovery.

  • #127 geschrieben von renderit  vor 4 Monaten

    Can I only download the kernel from here,and push the kernel to my phone?,ignore the patch ?I think this should be ok. But I put the zip file to SDCARD, flash .zip file in recovery mode,it always saying:
    system/xbin/12ping missing…….I test cyanogenMod 7.0/7.10/6.02…..No lucky.

  • #128 geschrieben von Tim  vor 4 Monaten

    You can’t patch your kernel on the phone. You will have to download the Kernel Source, patch that and afterwards push the kernel to your phone.

  • #129 geschrieben von renderit  vor 4 Monaten

    Any one can help me with how to patch it?
    I do like this ,but fall :
    first ,in a adb shell ,I input patch -p1 /sdcard/HTC_Desire_Hostmode_kernel_2-6-37.patch
    but, it dont work.

  • #130 geschrieben von Grzesiek  vor 5 Monaten

    I tried to patch it myself, but file names and contents are different in current cyanogen kernel.
    Have you found out anything?

    • #131 geschrieben von Tim  vor 5 Monaten

      I just did a really quick try. The patch contains some USB HostMode code that is not designed for the Desire. I would have to filter that out first and I didn’t find time for this yet…
      So no progress from my side so far.

  • #132 geschrieben von Grzesiek  vor 5 Monaten

    It would be nice if you informed me of the progress : )

  • #133 geschrieben von Tim  vor 5 Monaten

    I know that usb device mode is lost. I have tried to patch the kernel myself to allow for the device mode to be loaded as kernel module but was unsuccessful.
    Thank you for the link! I will look into it!

  • #134 geschrieben von Grzesiek  vor 5 Monaten

    I also have Cyanogenmod 7.1.0 with kernel 2.6.37.6.
    After using your patch usb device mode is completely lost.
    Have you seen Andrew de Quincey’s patch (http://adq.livejournal.com/101420.html)? Maybe it would be possible to put it all together and apply to Cyanogen’s kernel?
    I can try to help in some way, however I’m quite new to android development.

  • #135 geschrieben von Tim  vor 5 Monaten

    Of course I can :)
    I didn’t get any answers yet, but I’ll send the same stuff to you, as I did to him.

  • #136 geschrieben von sashimi  vor 5 Monaten

    Hi Tim,
    I am also running Cyanogenmod 7.1.0 (or last stable version in the future). Would you mind including me in your email discussions between Greg and you so I can follow and test stuff live on my side too ?

    Many thx in advance

  • #137 geschrieben von Tim  vor 5 Monaten

    Yes you can do that, but it will just unload the usb host mode. Since the host mode kernel does not include any android gadget usb support, you can’t switch between host and normal mode this way.
    If you use rmmod you will just have a phone without any usb functionality.
    I haven’t investigated wether it is possible to have android gadget mode as loadable module

  • #138 geschrieben von Colin  vor 5 Monaten

    Can I use rmmod to “un host” ???

  • #139 geschrieben von Greg Hanford  vor 6 Monaten

    Hi Tim ,

    Great work in this area I think you may be interested in what I have to say and possibly may want to help. I am doing a project involving a midi device ( midi music keyboard ) and want to connect it to my HTC Desire Bravo. I am having real big trouble as I have followed your instruction on the latest cyanogen V 7.1 and loaded the 2 modules for usb host so i can test it with a mouse to start with the usb host cable i got off amazon. It doesn’t work with the kernal loaded at recovery mode and was hoping you might be able to help me. Nobody seems to have a “out of the box” type of solution like you have and hope you can help me.

    Regards,
    Greg.

    • #140 geschrieben von Tim  vor 6 Monaten

      Hi Greg,

      I’ll write you an eMail, it’s probably easier to discuss your problem there.

      Tim

  • #141 geschrieben von Kelvin Nicholson  vor 7 Monaten


    phentex:

    Hi, thx for theses patches & patched kernels. I use oxygen rom v2.3 (android 2.3.7 with kernel 2.6.35.14). Is there any chance the kernel patch could work ?
    many thx in advance

    Have you compiled the 2.6.35.14 kernel for Oxygen yet? I might do it if you haven’t.

  • #142 geschrieben von chross  vor 7 Monaten

    Hey,
    I saw that kernel but assumed that it must be some kind of special one as you denominated the cyanogenmod kernel separately.

    Well, I will try this one then and report back, when I’m done.

    Cheers

    • #143 geschrieben von Tim  vor 7 Monaten

      Thanks for the hint. I changed the descriptions of the kernels to indicate that they are ALL cyanogen kernels.

  • #144 geschrieben von chross  vor 7 Monaten

    do you mind creating a patch for the cyanogenmod kernel 2.6.37.6

    I’d love to have USB hsot mode but I won’t install the no sleep kernel because it will drain too much battery.

    Please upload a version of cyanogenmod’s kernel without wlan no sleep patch.

    • #145 geschrieben von Tim  vor 7 Monaten

      Hey,

      I would guess, that the 2.6.37 Patch also works for the 2.6.37.6 kernel. Have you tried that yet? I don’t know where to get the 2.6.37.6 Kernel. If you tell me where to get it, I could try compiling it.

      You did not look properly above. There is a 2.6.37 Kernel without the WLAN no sleep patch: http://tim.mactory.com/HTC_Desire/2.6.37_host_mod.zip

  • #146 geschrieben von Tim  vor 7 Monaten

    Mmh.. I’ve never used the kernel with any other rom than cyanogen.
    I don’t know if there is a difference between the kernels, but I don’t see why there would be.
    There could be a problem with the 2.6.35 you are using, since I know that the 2.6.37 I use, does not work on the older cyanogen rom that uses 2.6.35 as standard kernel, since something changed with the wpa supplicant…

    I would say just try it. Beforehand make sure, that you have a working kernel image (or the image of your rom) on your SD card, so you can flash that again, if my kernel does not work. If you reflash your rom, I’m not sure however if it overwrites any of your data, so be sure to make a backup first.

    I’ve added my older patch for the Kernel 2.6.35.9 to the page above. I’m not quite sure if it applies to the 2.6.35.9 Kernel correctly, because it was just something I quickly tried out. You could try compiling your own kernel for your rom.

  • #147 geschrieben von phentex  vor 7 Monaten

    Hi, thx for theses patches & patched kernels. I use oxygen rom v2.3 (android 2.3.7 with kernel 2.6.35.14). Is there any chance the kernel patch could work ?
    many thx in advance

  • #148 geschrieben von Best Elliptical Machine  vor 7 Monaten

    Much appreciated for the information and share!
    Nancy

  • Kommentar-Feed für diesen Beitrag
nach oben