Fedora配置usb驅動支持adb

If you're developing on Ubuntu Linux, you need to add a udev rules file that contains a USB configuration for each type of deviceyou want to use for development. In the rules file, each device manufactureris identified by a unique vendor ID, as specified by theATTR{idVendor} property. For a list of vendor IDs, see USB Vendor IDs, below. To set up device detection onUbuntu Linux:

  1. Log in as root and create this file: /etc/udev/rules.d/51-android.rules.

    Use this format to add each vendor to the file:
    SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666", GROUP="plugdev"

    In this example, the vendor ID is for HTC. The MODEassignment specifies read/write permissions, and GROUP defineswhich Unix group owns the device node.

    Note: The rule syntaxmay vary slightly depending on your environment. Consult the udevdocumentation for your system as needed. For an overview of rule syntax, seethis guide to writing udevrules.

  2. Now execute:
    chmod a+r /etc/udev/rules.d/51-android.rules
  3. 如何查看device id,root帳號運行lsusb

[root@zlf rules.d]# lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 003: ID 413c:2107 Dell Computer Corp.
Bus 001 Device 004: ID 192f:0416 Avago Technologies, Pte.

Bus 002 Device 005: ID 22b8:41da Motorola PCS        

其中紅色一行是我們要的目標設備信息,按照步驟a的格式添加到android.rules的配置文件中即可

         d.  重起adb,adb需要配置對應的PATH環境變量,把sdk中對應的platform-tools目錄加到PATH環境變量即可



下面是網上別人在ubantu的一篇博文

sdk文檔上有推薦方法是:

1. 新建 /etc/udev/rules.d/51-android.rules,該文件內容可模仿下面的內容:

# adb protocol on passion (Nexus One)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e12", MODE="0600",OWNER=="username"

這個是讓系統識別Nexus One android機器的內容,如果要加你自己的機器,只要知道你目標機的 VendorId, ProductId即可。

2. 如何得到VendorId, ProducId?將目標機用usb與電腦相連,在命令行窗口輸入lsusb,即可顯示與本機相連的所有usb設備。如:

michelle@michelle-ThinkPad-Edge:~$ lsusb

Bus 002 Device 007: ID 0489:c001 Foxconn / Hon Hai

Bus 002 Device 003: ID 17ef:4815 Lenovo Integrated Webcam [R5U877]

其中 Bus 002 Device 007: ID 0489:c001 Foxconn / Hon Hai
是我的android設備. 它的VendorId是0489,ProductId是c001。

3.在 /etc/udev/rules.d/51-android.rules文件中加入剛纔lsusb中查到的內容既可。如:

# adb protocol on FM6 (Foxconn FM6)
SUBSYSTEM=="usb", ATTR{idVendor}=="0489", ATTR{idProduct}=="c001", MODE="0666", OWNER="michelle"

這裏的OWNER就是你登錄ubuntu的用戶。

4. 在命令行執行

sudo chmod a+rx 51-android.rules
sudo service udev restart

這樣就重啓了udev service,讓剛纔新加的51-android.rules生效

5.執行

adb kill-server

adb devices

即可看到找到對應的設備,adb可用。

6. 如果這樣做後還是不能連上adb, 則要在 ~/.android 目錄下的adb_usb.ini文件中添加你所查到的設備的vendor id. 如本例中 vendorID = 0489, 則在該文件下添加一行:

0x0489

7.然後重新執行步驟5即可


發佈了40 篇原創文章 · 獲贊 0 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章