USB Store/debugging on Nexus One – checked !!

I was about to title this post something like “I got a nexus one and now what?” but I have been doing a lot of things with my new smart phone even without trying to hack it that it would not make any sense so instead I am going to record today’s experience trying to figure out how to connect my Nexus One to my Ubuntu box and it possibilities.

Basic ingredients:

  • Need a nexus one smart phone (Any Android OS based phone will do but recipes may be slightly different)
  • USB cable/connector. (The one that came inside your phone box)
  • A PC with your favorite OS; Ubuntu Linux 64 Bits is good enough for me.

Note that ingredients described in list above would work just fine for any of the following recipies.

Plug in your phone and get access to your SD memory card information.

What?? this is what any electronic device that is capable for storing data into any type of removable non-volatile memory should allow you to do, is not it? So with the nexus one is a breeze.

Step 1: Get your Ubuntu Linux box in happy state. Well that is the regular state, so far I have not seen any blue screen or the annoying “sand clock” like the OS I used to work with long time ago. This time using a green background to be in line with my environmentalist friends.
Step 2: Plug in your Nexus One to USB port and click over “Turn on USB storage”  button after USB connected message is shown.
Step 3: Note that your nexus one has set itself as USB storage device.
Step 4: Your Ubuntu is also happy and anxious to figure out how do you wan to open your storage device.
Step 5: That is it, start transferring files back and for.
Step 6: Wait, You do really prefer the shell are not you?.

Well, I was really thinking on setting my Nexus one on Hardware debug mode …

Yeah, this is the real deal about having your Nexus One connected to your trusty development box via USB, after all what you really want is to start hacking this little one and with hacking, debugging your stuff on real hardware is what you will be looking for. The first thing you gain by turning on “USB Debugging” on your Nexus One is the ability to capture screen shoots directly from your phone just like we have shown in the steps of the first recipe on this article but basically USB Debugging is what enable you as software developer to download, execute, debug and fine tune your Android applications using a real device HW (Android emulator is good but is not good enough to test before publishing your artifacts to the Android Market).

Advance Ingredients for this recipe:

  • On top of the basic ingredients shown at the top of this article you will also need Android SDK fully operational. In case of lacking of this material you are very welcomed to read “Step 0.0: Get Android SDK Installed“.
  • Just be aware that very basic Linux shell (bash in this case) skills are needed so please do not get overwhelmed.
Step 0: Always check the Android’s most trusted source. Android Developers Site. Following steps will show how I did it on my Ubuntu Linux 9.10 development box.
Step 1: make sure your device is enumerated in your Linux box UDEV rules. This is the most recent way to handle Linux kernel devices kind of plug and play way. In my case I added 51-android.rules file into /etc/udev/riles.ddirectory with the following content:

SUBSYSTEM==”usb”,SYSFS{idVendor}==”18d1″, MODE=”0666″

Where “18d1 is nexus One vendor ID, note that any other generic “HTC” device may need to use “0bb4” instead, you can always add two entries one of each to be sure.

Do not forget to use “sudo” while creating this file and also changing its mode to “a+r”.

Step 2:Restart UDEV and adb servers to set yout new device info up. You can always reboot your linux box but that is old fashion unless you are still going on Windows mode.Try restarting UDEV service with the following command:

$ sudo /etc/init.d/udev restart

Now restart “adb” server. This way adb (Android Debug Bridge) will pick up the newly added “UDEV” device settings.

$ adb kill-server

$ adb start-server

Step 3: Setup your Nexus One on “USB Debugging” mode. This is the crucial step. On the device, go to the home screen, press MENU, select Applications > Development, then enable USB debugging.Now connect the USB cable from your Nexus One into your Linux box USB port.
Step 4: Check for your phone to be included in the “adb” devices list. If device name shows like “????????” something went wrong and you must check your “UDEV” settings. You may need to set correct “idVendor”
Step 5: Check for your device using eclipse IDE . If you do not have set “Device” view then select from eclipse menu -> Window ->Show View -> Other.. -> Android -> Devices.

Future work …

I think for this article it is good enough for now so in another article I will describe how to get advantage of “USB Debugging” to capture your Nexus One screen shoots from your Linux box. Another one would be actually debugging your app directly on your Nexus One device. Stay tuned.

sudo /etc/init.d/udev restart

Comments are closed.