Android G1 Serial to USB Cable

148K3658

Intro: Android G1 Serial to USB Cable

Learn how to make an Android G1 2.8v serial to USB Serial device adapter (using a 3.3v ttl to usb serial adapter). This can be used for kernel debugging/etc with your computer. This project shouldn't cost you more than 40 bucks if you already have basic electronic tools such as a soldering iron.

Notice: The ability to use 3.3v ttl level serial is based off of google group discussions and a picture of a serial cable used by an alleged android dev. 2.8v level serial was determined via someone using a voltmeter. Build/use at your own risk and check the comments of this instructable too before beginning!

Information may be applied to build a 2.8v serial to RS232 converter to interact with RS232 devices, or a 2.8v serial to serial 5v level converter to interact with microcontroller such as an Arduino. I may post instructables on how to make these once I play around with the G1 kernel some more. :)

This tutorial assumes basic knowledge of soldering. If you don't have this skill you should find an instructable regarding it and practice a bit. The soldering required for this project isn't difficult, but needs to be done in a small amount of space which could be difficult for beginners.

This cable was created based off of information received from the Android-Platform Google Group.

... Specifically these two threads:
http://groups.google.com/group/android-platform/browse_thread/thread/f03730e25cc3fe55?fwc=1
http://groups.google.com/group/android-platform/browse_thread/thread/439d3f3af7a88a09/10a80eb835e8dbcc?lnk=gst&q=serial#10a80eb835e8dbcc

...This picture of a "mystical" g1 serial cable helped (and confused!) too:
https://www.noisebridge.net/wiki/Image:G1-two-usb-to-serial-cable.jpg

Please leave constructive criticism/comments if you find any steps wrong, confusing... or poorly written!

STEP 1: Items Needed

To build this converter you will need the following:

STEP 2: Soldering the HTC ExtUSB Breakout Board Data Wires

= 1. Using the wire cutters, cut three lengths of wire that are each about 5 inches long. If you bought more than one color of wire, make one black wire and two of your custom color.
= 2. With the wire strippers, remove about 5mm of insulation from each end of the three cables.

Now, before continuing, go grab your HTC ExtUSB breakout board and take a close look at it. One side will have tiny numbers on it that reflect the following:

6 9 11 5
O O O O
78 10 4
OO O O
1 2 3
O O O

The bold holes are what we are interested in. Those three holes represent GND (Hole 7), TXO (Hole 8), and RXI (Hole 9), all of which are necessary for the G1's serial communications. In case you were wondering what the other pins were tied to, this is what PodGizmo.com currently has listed:

1: USB VCC +5v
2: USB Data -
3: USB Data +
4: N / C
5: USB GND
6: Left Audio +
7: Labeled "AG" (Serial 2.8v Level GROUND)
8: Audio - (GND) Labeled "CK" (Serial 2.8v Level TX0)
9: Switch (Talk) Labeled "OT" (Serial 2.8v Level RX'I)
10: Right Audio +
11: Mic +
12: Chassis Ground (GND)

= 3. Plug in your soldering iron and let it warm up.
= 4. Grab a wire you cut earlier (the black one if you have multiple colors) and solder it through hole 7 (GND).
= 5. Grab another wire you cut earlier and solder it through hole 8 (TXO).
= 6. Grab the last wire you cut earlier and solder it through hole 9 (RXI).

After that it should look something like the picture below.

STEP 3: Soldering the USB to TTL-Level Serial Adapter Data Wires

Now that the ExtUSB board is soldered, the next step is to solder those wires into the respective holes in the USB to 2.8v serial board. Before continuing, it would be a good idea to grab this board and look carefully to find the GND, RX, and TX holes.

= 1. Solder the GND wire (The one Soldered in Hole 7 of the HTC ExtUSB board) in the hole labeled GND on your USB to 2.8v Serial adapter.
= 2. Solder the TXO wire (The one Soldered in Hole 8 of the HTC ExtUSB board) in the hole labeled RX on your USB to 2.8v Serial adapter.
= 3. Solder the RXI wire (The one Soldered in Hole 9 of the HTC ExtUSB board) in the hole labeled TX on your USB to 2.8v Serial adapter.

STEP 4: Verify the Data Wire Connections

= 1. If needed, install any drivers necessary for the USB to 2.8v serial adapter you used.
= 2. Download a serial console app for your computer. For OS X/Linux users, the command line minicom or screen are good choices. I will be using minicom under Ubuntu.
= 3. Plug in the converter you made into a USB port on your computer. Do NOT plug it into the phone yet.
= 4. Open up your serial console app and see if the device is detected. For me it shows up under /dev/ttyUSB0 and minicom picked it up automatically. You may need to configure your software.
= 5. With the serial port now recognized, now you need to change the baud rate/stop bits, and flow control. To change these in minicom, type Ctrl-a then type Shift-O (O as in Obama). A configurations dialogue will pop up. You should choose "serial port setup", hit enter then change the values to be the following:
  • Bps/Par/Bits: 115200 8N1
  • Hardware Flow Control: No
  • Software Flow Control: No

= 6. Close settings and wait for a connection now. You can exit settings in minicom by hitting the escape button.
= 7. Go grab your G1 Phone and make sure it has a good charge. Once it does, you should go to Settings->Sounds and Display->Screen Timeout and increase it to 10 Minutes or Never Timeout. From preliminary tests, It seems serial doesn't work with the display off.. but this has not been verified.
= 8. Plug the HTC ExtUSB connector into the phone.. if you smell anything funny or see sparks, quickly disconnect the connector from the phone then the USB cable and review the prior steps to see what you missed.

= 9. If all looks and smells ok, take a look at the serial console output, it should say "debug>" immediately. This reflects that you at least soldered the GND and RX wires correctly, woo!**
= 10. Try typing "ps" and hit enter, if you see ps appear and lots of text scrolls by when you hit enter, that means you cable works fine. Neat!**

**If you do not see the expected "debug>" text or you don't see what you type, hit enter a few times. Sometimes the communications can get garbled since no software/hardware flow control is used. If that doesn't work, you can try restarting your console app, verifying serial communication settings, unplug/plug in the phone, and finally double checking what you soldered.

= 11. Trim the excess wires off both boards.

STEP 5: Soldering the USB to TTL-Level Serial Adapter Power Wire (optional)

Now that you know your cable works you can either use it as is, make it provide power to the G1, or make it work as a dual standard USB and USB serial device. The following explains how to supply power to the G1 provided your adapter has a 5v hole to solder to.

= 1. Take a look at your 2.8v level serial to USB adapter and look for a something labeled 5V. It may also be labeled VCC but if this is the case, check your adapters data sheet to verify it actually does supply 5V directly from the USB bus. It also probably wouldn't hurt to double check this using a voltmeter.

If you do not have this connection, you will not be able to complete the next few steps. If you run into this situation you might want to consider just soldering a USB cable to the proper HTC ExtUSB pins as this should allow you to both power the G1 and also have standard USB access to the G1

= 2. Using the wire cutters, cut a wire that is about 5 inches long. If you bought more than one color of wire, use the red wire.
= 3. With the wire strippers, remove about 5mm of insulation from each end of the cable.
= 4. Solder the wire through the 5V (or VCC) hole on your adapter.

STEP 6: Soldering the HTC ExtUSB Breakout Board Power Wire (optional)

Take a look at the HTC ExtUSB breakout board again. We are interested in the USB VCC +5v hole which is bolded below.

6 9 11 5
O O O O
7 8 10 4
O O O O
1 2 3
O O O

1: USB VCC +5v
2: USB Data -
3: USB Data +
4: N / C
5: USB GND
6: Left Audio +
7: Labeled "AG" (Serial 2.8v Level GROUND)
8: Audio - (GND) Labeled "CK" (Serial 2.8v Level TX)
9: Switch (Talk) Labeled "OT" (Serial 2.8v Level RX)
10: Right Audio +
11: Mic +
12: Chassis Ground (GND)

= 1. Solder the other end of the (red) wire you just soldered in hole 1 (USB VCC +5v).

STEP 7: Verify the Power Wire Connection

= 1. Plug in the adapter into your computer. If it starts to smell funny or spark, quickly remove it and check what you soldered.
= 2. Grab your phone, power it on if it is off, then plug the adapter into it. After about a second or two, the amber charging light should turn and stay on.. if it doesn't, quickly disconnect it and double check your connections.

That's it, go hog wild!

STEP 8: Now What?

So now that you know how to interact with the serial port on the G1, you probably have a bunch of ideas floating around your head for how to take advantage of it, right?

Wouldn't it be nice to use this to:
-Control a robot
-Use the G1 as a serial console to connect to servers in a beowulf cluster like System-X
-Communicate with sensors/activators over a 3g network for remote monitoring/control
-Use the serial port to attach a blood glucose reader or other medical device (psst, any big medical companies hiring?) and combine two devices into one for many people?

Here's a project that explains how to compile the G1 phone's kernel so you can use the serial port from the userland. It also features an api so you can use the serial port directly from Android Gui apps!

http://code.google.com/p/android-serialport-api/


Don't forget to post your projects here when you're done!

58 Comments

I have a Droid Bionic - anyone want to build one of these for? (with instructions on how to install driver, etc)
Thanks for great instructable.
I tried that I connected G1 with Cisco console.

Android (T-Mobile G1) -> Serisl Port API -> TTL -> RS232C -> Cisco console

(my scene)
http://youtu.be/t4EuB8qhTvA
Hi all,

I've connected mine G1 to the PC via FTDI Basic Breakout (http://www.dfrobot.com/index.php?route=product/product&path=45&product_id=147) and managed to get full output from 'ps. However, it seem that G1 could not received my input from the keyboard most of the times.

I need to repeatly hit the keyboard to get the terminal emulator to echo it back!

Did anyone experienced it? Any tips will be helpful. Thanks
Thanks very much for the tutorial! I would like to know whether I can use this from a program on my g1, say, if i were to develop a program that could say to a picchip "SEND ME" then it could write back the values of its inputs etc. then the program could do something with them. would I have to use NDK? or does the SDK have some kind of serial control command?
  Yep, this allows 2-way communication via the serial protocol with a pic/avr/arduino, etc. That's actually my main reason for making this cable.

To do this you need to configure and rebuild the kernel to disable the serial debugger and htc handset detection drivers. Consequently after doing this, you probably won't be able to use your headset. This requires you to have a rooted phone too, preferably with the dev spi.

There's no android application level serial communication sdk stuff yet.. (Porting rxtx to android is on a todo list of mine) so you will need to compile a c app (search google for agcc.pl to learn how to compile c apps for android) in order to either use as a middle man between android apps and your uC.. or just to configure the serial port initially to whatever baud rate, stop bits, etc you need then interface with /dev/ttyMSM2 directly
Hey not sure you still interested but I just ported the RXTX library ( gnu.io.rxtx) to the android. More details here http://v-lad.org/projects/gnu.io.android/
Hmm, Cepr could you send me/post the code your using so that I can have a stab at it, and macpoddotnet are your steps nessery because I have a routed device so shouldn't I just be able to talk to /dev/ttyMSM2 using just command line (I will try this soon) because at the moment I'm testing using my actual phone I use on a day to day basis but I will buy a dedicated one I can break things like headsets and it doesn't matter.
Hi jamescorbett,<br /><br />I just created a Google Code project to host the code:<br />http://code.google.com/p/android-serialport-api/<br /><br />I will complete the wiki with compilation instructions soon.<br />
My application is now stable, I uploaded an apk in the download section.
SerialPort_0.7.apk features:
- detect all the serial ports of the phone (most are internal, do not use)
- select baudrate (4800, 9600, 115200)
- detect missing file permissions, and try to change it with "su" (does not work on all phones)
- terminal screen to receive and send text through the serial port
- "loopback test": the phone sends infinite 0x55555..., and display the count of received and sent bytes. If you connect RX and TX, you should have the same value.


Great work! When I get home I'll check it out then throw a link up in this instructable.

Hmm, the NDK has me really excited now.. it has made some other things I have wanted to do way easier now.
 If you are satisfied with the default baud rate you set in your kernel config before building it, you don't need to route applications through a c serial program.. or even make one to set the baud rate.

All you have to do is get the right permissions and talk to /dev/ttyMSM2 just like you would with any other linux serial port.

The NDK stuff wasn't around when I played with this, but this might even offer a better solution provided you have privileges. If you can include serial libs, you could control the baud rate directly from an app which would be awesome. This would be really useful for porting the rx/tx java libs too... hmm


The config entries that should be disabled have changed since I first did this, but currently these should be it:
CONFIG_HTC_HEADSET
CONFIG_MSM_SERIAL_DEBUGGER
CONFIG_MSM_SERIAL_DEBUGGER_CONSOLE


... possibly this too:
CONFIG_MSM_FIQ_SUPPORT
Thank you!
I have now ttyMSM2 :D
(it works also with CONFIG_MSM_FIQ_SUPPORT=y)
I made an Android program to read/write to a Linux serial port.
It uses the SDK and a little the NDK.
Anyway, you need a rooted device because the /dev/tty* do not have the read/write permissions for Android applications.

For the newer generations of android electronics (phones and tablets) They come with USB host already built in> Could i use the same programing cable for my arduino to connect to an android tablet? If i did, what app would i need to accomplish a serial port to the arduino?

Chow.
Thanks heaps for this instructable. After heaps of mucking around I managed to get the HTC Magic working with it using the stock headset (I cut it up).

Few pointers for those interested:
Headset cable already has the USB GND pin connected to what becomes the TX pin... obviously this won't work so I just hacked out all the normal usb pins (which solved the issue).

I've recompiled the 2.6.29-donut kernel and confirmed this works.

One issue though... when I use a custom kernel I cannot use it in normal USB mode :-(. Is this normal? Should you be able to use normal USB and this special serial mode at the same time?
I have now confirmed that Pin 4 is the data high pin and I have achieved 2 way communication.

http://garr.me/?p=315

Instructable coming soon.
Hey great work although I have noticed one thing that could be wrong.

Pin 4 is actually 2.8v or Data High which is required for some 2 way logic level converters.

Be warned, I haven't checked if it changes during data transmission. I will post my results when I get up to that stage.
The best way for me to see the phone sending commands to the PC was to type the following:

$ su
# echo 'hello' > /dev/ttyMSM2

It is also helpful to type 'ash' in so that you can recall commands:

$ su
# ash
/ # echo 'hello' > /dev/ttyMSM2

Then you can use ALT+trackball-up to recall previous commands.
More Comments