nVidia SHIELD TV setup for development on Linux

February 06, 2016 »know-how

This was harder than I thought it would be. Also, it’s a bit too long for a simple inline, so I made this a post instead.

The goal of this article is to get the nVidia SHIELD TV to accept ADB connections via USB and then via network. The steps outlined here directly apply to Ubuntu 14.04 LTS (and elementary OS 0.3.2, which is based on that Ubuntu version). They should also be apply-able to any other modern Linux system, though the actual commands might vary.

I will skip over the SDK and IDE setup. Everything you need to know is here.

To make the following steps easier, you should add <sdk-location>/tools/ and <sdk-location>/platform-tools/ to your PATH-variable.

ADB over USB

As a first step, we need to get ADB running over USB. Connect the nVidia SHIELD TV to your computer using a USB Micro cable. Make sure you have activated USB debugging on the device! Now run adb devices. This is what I got:

$ adb devices
List of devices attached
042421500478000000d1	no permissions

Well, that’s a good start… A quick search told me that this is a problem with the permissions on my system. The official documentation tells you:

If you’re developing on Ubuntu Linux, you need to add a udev rules file that contains a USB configuration for each type of device you want to use for development. In the rules file, each device manufacturer is identified by a unique vendor ID […]

Log in as root and create this file: /etc/udev/rules.d/51-android.rules Use this format to add each vendor to the file:

SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666", GROUP="plugdev" 

Now execute:

chmod a+r /etc/udev/rules.d/51-android.rules

On the list of vendor-ids, the listed ID for nVidia is 0955. So I added the following line to the udev rule:

SUBSYSTEM=="usb", ATTR{idVendor}=="0955", MODE="0666", GROUP="plugdev"

A bit of info on that line: ATTR{idVendor} is the vendor-id of the device we want to add a rule for, MODE sets the Unix permission bits for the device (here: read/write for owner, user and group) and the parameter GROUP specifies the name of the group to own the device. You can use the groups command to check if your current user is in the specified group.

What the documentation doesn’t tell you is, that you’ll have to reload the udev rules in order for them to take effect (or reboot the computer). So execute the following commands:

# Reload the rules:
$ sudo udevadm control --reload-rules
# Restart udev (probably optional)
$ sudo service udev restart
# Kill the adb-server:
$ adb kill-server

Afterwards, run adb devices again. If that works for you: lucky you! If not:

The vendor ID

For me, the above wasn’t enough. The device showed up as before and still said “no permissions”. So I headed over to the Arch Linux Wiki (Side-note: The Arch Linux Wiki has a lot of very well written and extensive articles on Linux topics and is my go-to resource for problems like this. They are however very technical).

The relevant part can be found further down the page:

Each Android device has a USB vendor/product ID. An example for HTC Evo is:

vendor id: 0bb4
product id: 0c8d

Plug in your device and execute:

$ lsusb

It should come up something like this:

Bus 002 Device 006: ID 0bb4:0c8d High Tech Computer Corp.

So, executing lsusb on my system gave me (amongst others) the following line:

Bus 001 Device 012: ID 18d1:4ee7 Google Inc.

So the vendor-id is 18d1 and the product-id is 4ee7. With this information I added the following three lines to the /etc/udev/rules.d/51-android.rules-file:

SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee7", SYMLINK+="android_adb"
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee7", SYMLINK+="android_fastboot"

Now reload udev with the commands shown above and run adb devices again:

$ adb devices
List of devices attached
042421500478000000d1	device

Wuuuh! At the same time, the SHIELD TV displayed the familiar prompt and asked, if I want to allow USB Debugging from the computer. “Always allow”, “OK”, done.

ADB over Network

Deploying Apps and debugging them now works. Thats all nice and good, but my SHIELD is not in USB-cable range of my PC. Luckily, Android supports debugging over network.

Back on the device go to: Settings -> Developer Settings -> Debugging -> Network Debugging -> On. Now the device should accept adb connections via network. The next steps are outlined in this StackOverflow post:

  1. Connect the device via USB and make sure debugging is working.
  2. adb tcpip 5555
  3. adb connect <DEVICE_IP_ADDRESS>:5555
  4. Disconnect USB and proceed with wireless debugging.

adb -s <DEVICE_IP_ADDRESS>:5555 usb to switch back when done.

Running adb devices after executing the four steps should display something like this:

$ adb devices
List of devices attached
<DEVICE_IP_ADDRESS>:5555    device

Congrats, you’re done.

Conclusion

  1. Create udev rules with the correct vendor and device-id
  2. Get USB debugging working first
  3. Switch adb over to network and connect to the device
  4. Profit

Posted by Lukas Knuth

Comments

comments powered by Disqus