Android 4.4 Kitkat 使能 USB adb 功能

來源:互聯網
上載者:User

標籤:android   usb   kernel   shell   

背景
在 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 adbNow 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    [email protected]:/#


    Hooray there‘s your shell!


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.