If you are developing/porting a new Linux kernel for some android platform, the first thing we need is a debug support. When we are porting very basic kernel, we might have UART for debugging purpose, but those have dependencies over limited UART cables and since we normally have more USB cables as those are required to charging mobiles, its always better to have some kind of debugging over USB cable. Android allows us to connect to device shell using its own Android Debug Bridge (ADB) protocol.

Execution & Command Syntax

Terminalbash
adb command facilitates a variety of device actions, such as installing and debugging apps, and it provides access to a Unix shell that you can use to run a variety of commands on a device
Terminalbash
make sure, we have USB ADB gadget support enabled in Linux kernel
Terminalbash
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

Technical Implementation Details

Android Debug Bridge (adb) is a versatile command-line tool that lets you communicate with a device. The adb command facilitates a variety of device actions, such as installing and debugging apps, and it provides access to a Unix shell that you can use to run a variety of commands on a device. Reference Android Studio The first step we need to do is to make sure, we have USB ADB gadget support enabled in Linux kernel. Before KERNEL version 3.10, the Android had a separate ADB driver at drivers/usb/gadget/f_adb.c and can be enable from menuconfig. After 3.10, Android has deprecated f_adb.c and has replaced with Accessory driver at drivers/usb/gadget/function/f_accessory.c For compiling kernel, Follow steps from “Compile custom Linux kernel for Android / AOSP on Ubuntu” 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.

Gotchas and Common Issues

  • Permission Verification - confirm execution permissions and path variables before invoking system binaries.

  • Version Compatibility - check software version release notes for deprecated flags or syntax changes.

  • Log Monitoring - inspect system logs (journalctl or /var/log) to troubleshoot execution failures.

Following these steps ensures clean configuration, proper security boundaries, and reliable execution for enabling adb support with linux kernel for new platform.