Andrew de Quincey's livejournal

Previous Entry Share Next Entry
HTC Hero (MSM7201) USB host mode
For the last few days I've been busy figuring out how to support USB host mode on the HTC hero. This may also apply to many other android devices (e.g. the G1, and possibly the Nexus One as I think it may use the same USB host silicon internally). I've only tested it on the Hero so far though.

Android supports USB device mode out of the box. However my aim is to use the phone as a mobile USB host. I want to control my Nikon SLR over PTP/USB in order to do fancier shoots, for example timelapses. You can also obviously do loads of other cool things: USB-serial devices, keyboards, webcams, DVB receivers, etc etc.. I knew I'd be able to implement it if I had the docs; sort of a similar situation to this XKCD :)

However, (a) there isn't a USB host mode driver for the phone, and (b) the documentation for the Qualcomm MSM7201A System on a Chip the phone uses is not available, so I was stuck for a while. A month or so ago however, my friend Mark sent me this link. That is a patch to the u-boot project implementing USB for a freescale processor. Interestingly, the register define:
#define FSL_SOC_USB_USBMODE    0x1a8
Matches that in the android USB device mode driver exactly. As do all the other fields. And there are full docs available for the freescale chips such as the MPC5121 available here. They obviously licensed the same USB controller hardware designs. I'm not quite sure whose design it was originally, as Transdimension, Oxford Semiconductor, ARC and finally Synopsys all seem to have something to do with it, and have acquired each other over the last few years.

I also needed to know what USB transceiver hardware it used. From the USB device code, I could see it communicated using the ULPI protocol. And ULPI devices implement VENDORID/DEVICEID fields in their register set. After I dumped those I could see it was an SMSC device. Its actually a USB3316, but again, register level docs are not available (there is a "data brief", but that is not detailed enough). They are for the closely related USB3320 though!

After a few days of fiddling, I have just this evening got it all working. You can see my original thread on the android kernel list here. My post with the working patch is here. You'd obviously have to get the HTC Hero kernel source (I grabbed it from, patch it, and compile a custom kernel enabling EHCI/MSM7201 USB host support and disabling both USB  Function and USB Gadget support.

The next problem is that as far as I know the hero cannot supply power on the USB bus, and I'm not daring to try enabling the USB bus power hardware registers until I know more about how the charging circuitry is implemented. Therefore, I modified a portable USB hub to have two cables attached: one data with GND/D+/D- for connecting to the phone and one with GND/VBUS for supplying power to the hub itself. I'm powering everything off some rather nifty slimline rechargeable batteries acquired from Maplin.

There is information on other USB/host adapter cables at the openmoko project.

Plugging in my USB keyboard surprisingly works seamlessly - android just "works" with it. USB mice work as well in a sort of confusing manner; I think it treats them as a trackball. I've not tried anything else yet, but the idea of attaching 1TB hard disk to it sounds.... amusing :)

Here are some pictures. My workspace where I'm resoldering the cables to the USB hub:

The modified hub itself (Its some Saitek "UFO" hub:

And finally, here is it all wired together and running:

My next step will probably be to see how it can coexist with the default gadget driver; implementing USB OTG may be possible, or else I could implement some sort of software switch. Or I might just go ahead and implement some of the PTP camera control software. I've already implemented a fairly comprehensive python library, pyptp that I use from my laptop.

can you wear that hub as a necklace..?

Probably yeah! Originally it had a glowing LED in the middle that changed colour as you used it too :)

Nice Work!

I've also been working on this project as well. Nice job getting this to work. What cable did you end up using?
Do you think this would work?
( from the openmoko page )


Hi - yeah, that'd probably work fine; it just needs something to allow normal USB cables to be plugged into the USB B socket after all; you can program the hardware to switch the data lines over in software if they're the wrong way round in the cable :)

I *would* check its not doing something daft like mixing GND and the +5V supply up though!

The phone can't supply power to use peripherals as far as I know so you'll need something to inject power into the system; I've not investigated enough yet though. Perhaps it could be connected to a powered hub?

I basically just hacked an old unpowered USB hub apart and added the correct USB connector for the phone and a seperate power supply for my cable.

Great work --- Droid and USB stick attached?

Great work! My apologies in advance for not being on the same programming level, but i've got a few questions as I've been trying to figure out a way to do this for my Motorola Droid in order to view video files or just general files off an SD card(through a USB reader) or a USB stick

What is the main reason you had to recompile the kernel on your phone??-->."and compile a custom kernel enabling EHCI/MSM7201 USB host support and disabling both USB Function and USB Gadget support."? Was this to get the phone switched from peripheral to host mode switching the USB functionality? I know the other way to switch the Droid to host mode is through a custom soldiered USB dongle...posted here: is the kernel to forgo having to do this on the HTC? If that is the reason would there be a way to do this for the droid or easily create an app to switch the USB to host mode?

It sounds like from other posts the Droid will power devices connected to it once in host mode; therefore will your Y connector work to power both the phone(charge it) and the hub or device connected to the phone?...feel free to email me if it would be easier

Re: Great work --- Droid and USB stick attached?

Hi, you basically need two cooperating drivers: one for USB device mode, and one for USB host mode.

The droid is based on the TI OMAP chipset which AFAIK already has USB device+host drivers in linux. Motorola seem to have been kind enough to leave it on in their shipping software (I guess their engineers thought it was a cool feature :) The Droid cable basically tells it to switch between device and host mode.

The other android phones - G1/Hero etc - are based on the Qualcomm MSM7201 chipset, which has different USB hardware. Google/HTC have (irritatingly) only developed a USB device driver.. so if you wanted to use it as a host you were out of luck - the hardware supports it, but the software is missing.

I basically just added in the missing host driver code. Right now its still very much a prototype (I only started investigating this a week ago!). It is missing the auto-cable-switching the droid supports (which is the "USB OTG" standard); I fully intend to support this if the hardware allows it though!

As of right now, I haven't tried telling the phone hardware to /supply/ power to the USB bus; it depends how the hardware is wired physically. It might work, but it also might fry something!

The Y cable basically replaces the missing USB power supply for the USB peripherals with a battery. And you're right: the phone can still function as a USB host, and since the power line config is unchanged, it is also charged by the battery at the same time.

Edited at 2010-02-11 06:33 pm (UTC)

Sprint Hero Too?

That's hardcore! Good to see someone taking the time to hack around the deficient documentation. Do you know offhand if it'll work with the chinless Sprint Hero phones? Or would they use different hardware?

Re: Sprint Hero Too?

Ta! :)

According to the sprint uses the MSM7600, which I hear is the CDMA version of the MSM720x series.

I've just downloaded the sprint kernel source from; it looks like its using an identical msm_hsusb USB-device-mode driver, so its /extremely/ likely the host mode will be identical to the GSM Heros as well. I can't confirm till someone's actually tried it though obviously.

Re: Sprint Hero Too? (Anonymous) Expand



Don't see why not, linux has drivers for a "SIS" USB VGA dongle.. the main problem would be how to make the android stack use it sensibly I guess.

I *do* like the idea of controlling a project from it though.. something along the lines of the SixthSense demo? (

I wonder if you can get USB heads-up-display glasses... be rather interesting to /really/ overlay things like the Layar android app on reality :)

instead of creating that patched cable do you think that a battery hub like this one that can change the gender of the USD , can be use instead ?

PS: it has also battery based charging capabilities

Fantastic! A battery powered USB hub would be ideal!

The only reason I'm not using one is because I didn't find one after a quick search and wouldn't have wanted to wait till it arrived.

On the other blog they propose this cables ? Which one do you think will be more suited ?

PS : I would like to buy one of this cables :)

PS2: I see that e-bay link that this is already working on various linux powered mobile devices.

I'll try and have a look at those properly tomorrow; I don't want to give bad advice.

I too am interested (Anonymous) Expand

Marvelous idea

That's just a simply marvelous idea! Having USB host support in the kernel almost doubles the usefulness of this device - it basically turns the Hero into a mini-computer.

I can think of a lot of very good reasons why to have host support:
- More (and more flexible) storage solutions
- Keyboards, mice and other input devices (thinking Playstation joysticks anyone?).
- External screens
- Using the Hero as a controller for other equipment (Digital photography, printers etc)
- Wired networking cards

Really looking forward to seeing this kind of stuff in the custom ROMs.

Re: Marvelous idea


Also, imagine when these things start getting "old" and hitting the second hand market - that's a lot of rather nifty embedded development systems.

BTW - in case you've not seen the more recent progress - its not just the Hero now; the magic works, the g1 should too, and I have hopes for the Nexus One.

Re: Marvelous idea (Anonymous) Expand

Camera remote control

Excellent work - beyond my technical prowess but I know enough to appreciate what you've done. I've just spent a few hours scouring the web for ways to make just this happen - control my camera for timed exposures, automated aperture sequences and so on. Pretty much come to the conclusion that system-level will be required to open it up for host (or PTP) mode. I figure part of the reason could be reluctance to open up the phone-as-modem can of worms but it sure would be useful.

Another idea is to talk to a small self-contained device which has the USB host capability but uses a different mode of communication: bluetooth or wifi maybe. A cursory search reveals little but it is hard to remove the hits that deal with the opposite thing: getting bluetooth via a usb dongle... Anyway, if such a beast existed it is conceivable that the USB host could be realized in a non-rooted phone perhaps? It would even be nice to not to have to physically attach the phone to the camera for the purpose of shooting (or whatever your app would be).

Enough ranting, I really just wanted to congratulate you on solving this problem :-)

Stefan Engstrom

Re: Camera remote control


Yeah, I'd looked for a bluetooth-to-usb-host widget as well, but never had any luck finding one.

I'm hoping I'll be finished with fixing the device-mode stuff soon; its not exactly the most interesting thing to do. I'd ideally like to write an android app for the camera control.

Since the hero and G1 use the same port, and pretty similar software, do you think it would be possible? Also, if I sent you the parts, and some cash, could you make one of those for me? I don't have a soldering iron, so that would be greatly appreciated!

Re: possible on the G1?

as far as I know, yes, the G1 should work, but no one has confirmed it yet as far as I remember. The magic has been.

Not really up to making bespoke cables, but I know its possible to do it with a HDD-style USB Y-cable connector and a converter and no soldering.. I'm hoping to put a guide up once I've got the thing actually working.

Just what I was after to start my project

Brilliant!. I am currently using the Teknologist 1.9 Kernel on the Modaco rom image 3.0. I will have to see if its been enabled in the tree. Of course come mid April, we can hope the new 2.1 kernel's are better compiled from HTC.

My current project that I want to develop on my Hero (and for Android phones in general) is based around a TIRA device ( I just ordered it today, and expect it this week. Since this device is LIRC compliant, it would be idea for this!. Most likely I would have to use batteries like you for my testing, but in long run would like to get power for Tira board from the HTC Hero.

I will post my results some where once I have some success (or not).

Please let me know what you think in this thread.


Re: Just what I was after to start my project

Ah cool! That sounds interesting, keep me informed how it goes. I'll hopefully get some time tomorrow to debug my latest patch.


Hi, I think your work is awesome.

I'm thinking about connect a game pad (NES like) to the Hero and searching for info I ended in your post.

Do you think is possible to connect a game pad to the USB port on the Hero?

I’ll appreciate so much if you can guide me or give me some clues.

Thanks and regards.

Hi, it should support pretty much any USB device, as long as the appropriate device driver module is compiled and present on the phone.

I spotted this:

nexus one

I have been dreaming of being able to connect a portable screen like this one to my nexus one accompanied by a Bluetooth keyboard. It would be like having a netbook in your pocket. Imagine RDP to your powerful home PC with that set up. I have been searching this topic and came across your work. Keep it up this is awesome stuff.

HTC Incredible

Hey I love your project and want to help. I have the HTC Incredible and created a Micro USB A and B cable from - Chris Paget's Blog , I got USB- Keyboard and mouse working on the Moto Droid but not on Incredible. What do I need to do to get it to work on my machine? Do I need to wait for it to be rooted or can I install your patch?

Re: HTC Incredible

If its an HTC phone, it'll be based on the Qualcomm chipset, so it would most likely need my patch ported to it (only the TI OMAP chipsets will just "work" with the cable mod).

As I don't have the hardware, I can't really help as its the sort of fiddly thing you need to test on a live device.

Acer liquid host mode

May be or not? What are you think.


Log in

No account? Create an account