天天看點

Android 4.4 Kitkat 使能 USB adb 功能背景

大家好,又見面了,我是全棧君,祝每個程式員都可以多學幾門語言。

背景

在 Linux-3.8 以後,Android 的核心分支,便去掉了 f_adb,改使用 USB function FS,在使用者空間實作 USB adb 功能。這篇文章依據原作者的 Google+ 文章,在 Atmel sama5 開發闆上做了測試,将步驟記錄例如以下,供須要使用的讀者參考,你也能夠檢視作者原文:

https://plus.google.com/111524780435806926688/posts/AaEccFjKNHE 

在 Linux-3.10 上使能 USB ADB

編譯核心時使能 USB FunctionFS

When building your kernel, make sure to configure in FunctionFS:
 
     Device Drivers -> USB Support -> USB Gadget Support
 
         -> USB Gadget Driver -> Function Filesystem             

複制

設定正确的 USB vendor ID 和 Product ID

這個設定能夠放在 bootcmd 或者載入核心子產品的時候通過參數傳遞:

Modify your boot parameters to set the vendor and product ids so adb on your host recognizes the device.
 
     g_ffs.idVendor=0x18d1 g_ffs.idProduct=0x4e26
 
 
    Alternatively this can also be done if you built the gadget driver as a module at load time:
            

複制

insmod g_ffs.ko idVendor=0x18d1 idProduct=0x4e26           

複制

啟動 Android 并挂載 functionFS, 使能 USB adb

Now here I’m assuming you’ve got a serial port working. Boot your target device with your new kernel (and insmod the g_ffs driver if necessary), and setup the functionfs directory:           

複制

# mkdir /dev/usb-ffs
    # mkdir /dev/usb-ffs/adb
    # mount -o uid=2000,gid=2000 -t functionfs adb /dev/usb-ffs/adb           

複制

重新啟動 adbd 守護程序

If everything is working, you can kill adbd and when it restarts it should find the functionfs mount and make use of it.
            

複制

# ps adbd
    # kill <pid for adbd>           

複制

然後進入 cmd 或者 Linux Host 就能夠成功連接配接 usb adb 獲得 Android shell 了

On your host system, connect to the target using the adb program:           

複制

$ ./adb shell
    root@android:/#           

複制

    Hooray there’s your shell!           

複制

釋出者:全棧程式員棧長,轉載請注明出處:https://javaforall.cn/118670.html原文連結:https://javaforall.cn