Android Phone Serial Interface

From GT RoboJackets

Jump to: navigation, search

Contents

Introduction

Most Android phones have a USB interface, but they are USB slave by default -- they can't talk to other USB slaves (ex. a microcontroller). Many Android phones actually have USB OTG chipsets, but there aren't any drivers (that we know of) built into Android, yet.

G1 Serial Interface

The G1 has a special ExtUSB connector, which in addition to the normal USB pins, also has pins for audio in and out in. Some of those extra pins can actually be used as a 2.8V serial port. By default on the G1 dev phone, that port sends debugging information, but that can be disabled in the kernel compile settings (see #Serial_Enabled_Kernel). Also the permissions to access the serial port must be set properly (see #Setting Serial Port Permissions) -- unfortunately this must be done every time the phone is restarted (at least for now).

G1 Pinout

AndroidSerialPort.png
3: Rx
4: Tx
5: GND

Sources

[1] [2]

Serial Enabled Kernel

To use the serial port on the G1 you have to enable it in your kernel. To do this, you will have to build the kernel from source. If you use a kernel version compatible with your currently install Android, you want have to rebuild any of the Android source (which will take much longer).

Setup Build Environment
Download the Kernel Source
Modify the Kernel
Build the Kernel
Flash the Kernel to the Phone

Setting Serial Port Permissions

TODO: maybe we can fix this

Right now, this has to be done every time the phone is restarted:
(Note: adb needs to be run as root in Ubunutu -- run adb kill-server if it wasn't started using sudo)
adb shell
su
chmod 666 /dev/ttyMSM2
exit
exit

Logic Level Shifter

To interface the 2.8V (really more like 2.6V) phone serial port to a 5V Arduino we used a logic level shifter. We made our own but you can also buy them many places.
File:FlyingAndroidLogicLevelShifter.png

Personal tools