Skip to content

Serial port on Android

by drphrozen on May 30th, 2011

At work we had a problem connecting an embedded device to a smartphone, but solved it rather nicely using an Android phone (Nexus One). This guide will show you how i solved the problem using an idea stolen from sven.killig.de.

The recipe is as follows:

Install (using binaries)

Prerequisites:

Optional:

Walkthrough:

  1. Install CyanogenMod (IMPORTANT: do not boot into android after this)
  2. Mount /system from recovery
  3. Extract content of the modified kernel package
    $ adb push bcm4329.ko /system/lib/modules
  4. Boot into fastboot (hold trackball when rebooting/powering)
    $ fastboot flash zimage zImage
  5. Test connection using Android SerialPort API.

Compile (from source)

Kernel Modifications

Verify that the following options are set:

  • # CONFIG_MSM_SERIAL_DEBUGGER is not set
  • CONFIG_CMDLINE="mem=64M console=null"

Change a line in drivers/serial/msm_serial.c:

static struct console msm_console = {
...
  .flags = CON_ENABLED, // was CON_PRINTBUFFER
...
};

Fastboot

Fastboot is available at htc.com, to start Nexus One in fastboot mode, hold trackball while powering up.

  • fastboot oem unlock (used to unlock the phone)
  • fastboot boot /path/to/zImage (used to test a new kernel)

Reference blog: Enabling the Serial Port on a Nexus One

android-serialport-api

I had to recompile this project without O_DIRECT at:

fd = open(path_utf, O_RDWR | O_DIRECT | O_SYNC);

Hardware

Usb connection

The hardware is described on http://sven.killig.de/android/N1/serial/.

pin 1, VBus must be left open (red)
pin 2, D-: TX (white)
pin 3, D+: RX (green)
pin 5: GND (black)

From → Uncategorized

No comments yet

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS