ADB

From linux-sunxi.org
Jump to navigation Jump to search

ADB is Android Debug Bridge, a protocol over USB (OTG) to provide many necessary system access services.

A full explanation on how to use ADB is provided at the android developer website.

Common pitfalls

No devices found

If you run adb devices, and it shows no devices:

List of devices attached 

Then verify that your device is present on the usb bus, by running lsusb:

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 032: ID abcd:1234

You then need to make sure that adb knows about this new vendor id:

mkdir ~/.android/
echo "0xabcd" > ~/.android/adb_usb.ini

You need to restart adb for this to take effect:

adb kill-server

Only root has access

You need to alter the permissions of your usb device through udev.

Add a file 51-android.rules in /etc/udev/rules.d/ with the following content (with the ID matching what lsusb says).

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

When you now update udev, you should be able to access the device as a user:

udevadm trigger

root access

While most Allwinner devices ship with root access enabled via ADB, some don't. There are different ways of gaining root access on the device, but many of them are not straightforward or involve using proprietary software. Android can be tricked to quickly provide root access on ADB shell, using the lax permissions set on /data/local/tmp files at boot.

adb shell
$ rm -rf /data/local/tmp
$ ln -s /data /data/local/tmp

Reboot the device.

adb shell
$ echo "ro.kernel.qemu=1" > /data/local/tmp/local.prop

Reboot the device: ADB shell should now be running as root!