背景


在 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 



然后进入 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://my.oschina.net/jingxia/blog/697460

更多相关文章

  1. Android中TabHost中实现标签的滚动
  2. Android(安卓)NDK: jni/Android.mk: Cannot find module with ta
  3. Android学习--界面设计
  4. android中联系人搜索框
  5. Android(安卓)Settings中的默认设置
  6. android app 不会被low memory killer回收
  7. 在Android(安卓)Studio上测试运行,Unity发布成Android包的环境搭
  8. android崩溃日志保存sdcard打开并发送到email
  9. Android的语言设置(二)

随机推荐

  1. 跟大家分享下Android布局文件layout.xml
  2. Android(安卓)对象序列化之你不知道的 Se
  3. Android:控件属性
  4. Android图标的制作
  5. Android(安卓)代码实现应用强制装到手机
  6. android 4.2修改设置菜单的背景颜色
  7. android studio查看模拟器文件夹
  8. 由Android想到的事情
  9. android 获取路径目录方法
  10. [Android随笔]Android参考书籍