全志F1C上测试一下ADB功能
配置buildroot
- Target packages > System tools 勾选android-tools adb adbd
这个程序需要openssl,所以会自动下载编译openssl
启动脚本
- #!/bin/sh
modprobe g_ffs idVendor=0x18d1 idProduct=0x4e42 iSerialNumber=”f1c_adb”
mkdir -p /dev/usb-ffs/adb
mount -t functionfs adb /dev/usb-ffs/adb -o uid=2000,gid=2000
adbd&
- 下边是输出信息
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32[ 1015.671170] usb_phy_generic usb_phy_generic.0.auto: usb_phy_generic.0.auto supply vcc not found, using dummy regulator
[ 1015.683059] musb-hdrc musb-hdrc.1.auto: MUSB HDRC host driver
[ 1015.688989] musb-hdrc musb-hdrc.1.auto: new USB bus registered, assigned bus number 1
[ 1015.704830] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.04
[ 1015.713091] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 1015.720406] usb usb1: Product: MUSB HDRC host driver
[ 1015.725414] usb usb1: Manufacturer: Linux 5.4.99 musb-hcd
[ 1015.730799] usb usb1: SerialNumber: musb-hdrc.1.auto
[ 1015.738779] hub 1-0:1.0: USB hub found
[ 1015.742642] hub 1-0:1.0: 1 port detected
[ 1015.768938] using random self ethernet address
[ 1015.773397] using random host ethernet address
[ 1015.778010] using random self ethernet address
[ 1015.782453] using random host ethernet address
[ 1015.787926] usb0: HOST MAC 8a:c5:4f:1e:6f:18
[ 1015.792298] usb0: MAC d2:d0:89:99:11:ec
[ 1015.796436] g_ffs gadget: g_ffs ready
# [ 1017.200076] g_ffs gadget: high-speed config #2: FunctionFS + ECM
# adbd&
# install_listener[ 1056.721906] read descriptors
('tcp:5037','*sm[ 1056.725214] read strings
artsocket*')
[ 1056.729168] using random self ethernet address
[ 1056.734713] using random host ethernet address
[ 1056.739196] using random self ethernet address
[ 1056.743630] using random host ethernet address
[ 1056.749049] usb0: HOST MAC b6:d2:0d:05:55:96
[ 1056.753421] usb0: MAC fa:a3:f6:8f:4d:72
[ 1056.757540] g_ffs gadget: g_ffs ready
[ 1057.234908] g_ffs gadget: high-speed config #2: FunctionFS + ECM
ubuntu中安装adb工具
sudo apt install adb
adb devices 列出adb设备
$ adb devices
List of devices attached
f1c_adb device用lsusb可以看到是一个google Nexus 7 的android设备
- ubuntu上查看usb设备
1
2
3
4
5$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 8087:0a2b Intel Corp.
Bus 001 Device 033: ID 18d1:4e42 Google Inc. Nexus 7 (debug)
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub - 在板子上查看usb设备会出现一个usb网卡
1
2
3
4
5
6
7
8
9# lsusb
Bus 001 Device 001: ID 1d6b:0002
# ifconfig -a
usb0 Link encap:Ethernet HWaddr 9A:A2:75:F3:AD:7F
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
- ubuntu上查看usb设备
连接adb设备
$ adb connect f1c_adb:5037
unable to connect to f1c_adb:5555: Name or service not known
[ cannot open /dev/ptmx - No such file or directory ]
这是因为我把虚拟终端都给去掉了 只需要把下边一项勾上即可
[*] Unix98 PTY support查看一下/dev下的文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14# ls /dev
audio mtd0 pts ttyS2
bus mtd0ro random ttyS3
console mtd1 rfkill ttyS4
cpu_dma_latency mtd1ro rtc0 ttyS5
dsp mtd2 shm ttyS6
fd mtd2ro snd ttyS7
full mtd3 spidev1.0 urandom
gpiochip0 mtd3ro stderr usb-ffs
i2c-0 mtdblock0 stdin watchdog
kmsg mtdblock1 stdout watchdog0
log mtdblock2 tty zero
mem mtdblock3 ttyS0
mixer null ttyS1
使用adb上传下载文件
- #adb shell 即可像普通终端那样操作了
- adb push ./test /opt 上传文件到板子上/opt文件夹
- adb pull /opt/test ~ 下载文件到本地用户主目录
评论