Installing adb on ubuntu 16.04 and accessing android device using adb

1) compile kernel with adb + mass storage gadget support

2) flash and connect USB cable to Host

dmesg looks like..

[11621.761441] usb 2-1: new high speed USB device using ehci_hcd and address 27
[11621.912445] usb 2-1: configuration #1 chosen from 1 choice
[11621.959123] Initializing USB Mass Storage driver…
[11621.959341] scsi6 : SCSI emulation for USB Mass Storage devices
[11621.959551] usbcore: registered new interface driver usb-storage
[11621.959555] USB Mass Storage support registered.
[11621.964209] usb-storage: device found at 27
[11621.964212] usb-storage: waiting for device to settle before scanning
[11626.961587] usb-storage: device scan complete
[11626.962259] scsi 6:0:0:0: Direct-Access     <NULL>   <NULL>           0000 PQ: 0 ANSI: 2
[11626.963870] sd 6:0:0:0: Attached scsi generic sg1 type 0
[11626.966200] sd 6:0:0:0: [sdb] Attached SCSI removable disk

# lsusb
Bus 002 Device 027: ID 18d1:0002

# lsusb -v -d

Bus 002 Device 027: ID 18d1:0002

Device Descriptor:
bLength                18
bDescriptorType         1
bcdUSB               2.00
bDeviceClass            0 (Defined at Interface level)
bDeviceSubClass         0
bDeviceProtocol         0
bMaxPacketSize0        64
idVendor           0x18d1
idProduct          0x0002
bcdDevice            2.16
iManufacturer           1
iProduct                2
iSerial                 3
bNumConfigurations      1

Configuration Descriptor:
bLength                 9
bDescriptorType         2
wTotalLength           55
bNumInterfaces          2
bConfigurationValue     1
iConfiguration          0
bmAttributes         0xe0 ( Self Powered, Remote Wakeup)
MaxPower                2mA

Interface Descriptor:
bLength                 9
bDescriptorType         4
bInterfaceNumber        0
bAlternateSetting       0
bNumEndpoints           2
bInterfaceClass         8 Mass Storage
bInterfaceSubClass      6 SCSI
bInterfaceProtocol     80 Bulk (Zip)
iInterface              0

Endpoint Descriptor:
bLength                 7
bDescriptorType         5
bEndpointAddress     0x81  EP 1 IN
bmAttributes            2
Transfer Type            Bulk
Synch Type               None
Usage Type               Data
wMaxPacketSize     0x0200  1x 512 bytes
bInterval               0

Endpoint Descriptor:
bLength                 7
bDescriptorType         5
bEndpointAddress     0x01  EP 1 OUT
bmAttributes            2
Transfer Type            Bulk
Synch Type               None
Usage Type               Data
wMaxPacketSize     0x0200  1x 512 bytes
bInterval               1

Interface Descriptor:
bLength                 9
bDescriptorType         4
bInterfaceNumber        1
bAlternateSetting       0
bNumEndpoints           2
bInterfaceClass       255 Vendor Specific Class
bInterfaceSubClass     66
bInterfaceProtocol      1
iInterface              0

READ  USB - Physical

Endpoint Descriptor:
bLength                 7
bDescriptorType         5
bEndpointAddress     0x82  EP 2 IN
bmAttributes            2
Transfer Type            Bulk
Synch Type               None
Usage Type               Data
wMaxPacketSize     0x0200  1x 512 bytes
bInterval               0

Endpoint Descriptor:
bLength                 7
bDescriptorType         5
bEndpointAddress     0x02  EP 2 OUT
bmAttributes            2
Transfer Type            Bulk
Synch Type               None
Usage Type               Data
wMaxPacketSize     0x0200  1x 512 bytes
bInterval               0

3) add a udev rule of your Host with following information
# vim /etc/udev/rules.d/51-android.rules

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

4) chmod 777 /etc/udev/rules.d/51-android.rules

5) Now disconnect and reconnect USB cable and run “adb devices”

# ./adb kill-server (may be need to kill adb server if was already running)

# ./adb devices
List of devices attached
0123456789ABCDEF    device

# ./adb shell

On device
=========

# ls -l /dev/android*
crw-rw—- adb      adb       10,  60 2010-07-01 07:20 android_adb
crw-rw—- adb      adb       10,  61 2010-07-01 07:20 android_adb_enable

adbd process running

# root      883   1     3364   156   ffffffff 0000f444 S /sbin/adbd

** Modifications for conencting with adb if using another USB Vendor ID.
========================================================================
1) Modify system/core/adb/usb_vendors.c as following.
+++ b/adb/usb_vendors.c
@@ -69,6 +69,7 @@
#define VENDOR_ID_PANTECH       0x10A9
// Qualcomm’s USB Vendor ID
#define VENDOR_ID_QUALCOMM      0x05c6
+#define VENDOR_ID_CORPORATION      0xabcd

/** built-in vendor list */
@@ -90,6 +91,7 @@ int builtInVendorIds[] = {
VENDOR_ID_KYOCERA,
VENDOR_ID_PANTECH,
VENDOR_ID_QUALCOMM,
+    VENDOR_ID_CORPORATION,
};

2) change udev rule(/etc/udev/rules.d/51-android.rules) as following,
SUBSYSTEM==”usb”, SYSFS{idVendor}==”abcd”, MODE=”0666″

then recompile android, and used recompiled “out/host/linux-x86/bin/adb” binary for getting adb shell.

# ./out/host/linux-x86/bin/adb devices

List of devices attached
0123456789ABCDEF    offline

Here, “0123456789ABCDEF” is the sring from usb descriptor “Serial Number” String descriptor as a part of “usb device descriptor”

Installing adb on ubuntu 16.04
——————————

 $ sudo apt-get install adb 

Above command will also install android-libadb android-libbase android-libcutils android-liblog

Leave a Reply

Your email address will not be published. Required fields are marked *