USB, Android and Ubuntu

Recently the USB connection to my Android tablets stopped working with Ubuntu. I found about a year ago that it never worked reliably in MTP mode, so I started using the Android SDK "adb" command to manage the device. This includes:

  • file transfers to/from the device (and SD card, if attached)
  • live debugging of apps on the device from Eclipse on the desktop
  • Both of these features recently became unreliable. Some USB related devices I plugged in worked only intermittently. Others, like printers and card readers, were reliable. It was a real mystery why. I googled the problem for weeks, learned a lot and found various false trails that didn't solve my problem.

    Symptom 1: Connect an Android tablet and use "adb" to access it. This includes pushing & pulling files, or doing a debug session from Eclipse. It works perfectly for about 30 seconds. Then it suddenly stops responding and hangs.

    Symptom 2: Plug in a known good USB flash drive. Copy files back and forth. It works for about 30 seconds. Then it hangs entirely or gets VERY slow (like 1 kB / second transfers).

    Observations:

  • On this machine, some USB devices were intermittent and unreliable
  • On this machine, other USB devices worked fine
  • The "bad" devices worked fine from the same machine booted to Windows XP
  • The "bad" devices worked fine from other machines running Win XP, Ubuntu 11 and 12
  • Thus, it was not the cable or the device. Logically, I assumed it was something about the way Ubuntu 12 was configured on this machine. Things I tried:

  • Several different USB storage devices (flash drives, Android tablets connected via USB)
  • Removing mtpfs related files
  • Adding mtpfs related files back
  • Editing /etc/udev/rules.d file for the "bad" device entries
  • Removing /etc/udev/rules.d file for the "bad" device entries
  • Re-adding /etc/udev/rules.d file for the "bad" device entries
  • Using the tablet in mtpfs mode instead of dev/debug mode
  • None of the above worked.

    As a last resort, I opened the computer and checked all cable connections to USB devices. I also scrolled through the system BIOS settings page by page, looking for anything unusual. This is where I found and fixed the problem.

    This computer's 2 SATA drives were connected as devices 0 and 2. SATA device 1 was unused and turned off in the BIOS. This confused Ubuntu linux. I plugged the SATA drive that was in SATA slot 2, into SATA slot 1. And I updated the system BIOS to enable SATA slot 1 and disable SATA slot 2. Problem resolved!

    Very simple, but who would ever think that would make a difference? I hope this is helpful to someone else.

    NOTE: during the above troubleshooting I accidentally deleted the /boot directory. This is fatal to Linux, makes the box un-bootable. I restored it by booting to the Ubuntu Boot Repair CD, mounting my root directory partition, and copying /boot files from another Ubuntu 12 box, using a USB flash drive. That too might be useful for others to know.