Android 4.4 Kitkat 使能 USB adb 功能

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!



版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/118670.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号