1.打开内核配置,进行如下配置
forlinx@ubuntu:~/OK113i-linux-sdk$ ./build.sh menuconfig
CONFIG_USB_ACM=y CONFIG_USB_CONFIGFS_ACM=y
- 配置完成后,将开机自启adb服务进行关闭
forlinx@ubuntu:~/OK113i-linux-sdk/platform/framework/auto/rootfs/etc/init.d/$ mv S03adb K03adb
//切到out路径将adb开机自启关闭
forlinx@ubuntu:~/OK113i-linux-sdk/out/t113_i/ok113i/longan/buildroot/target/etc/init.d$ mv S03adb K03adb
- 关闭adb服务完成后进行全编译并打包镜像
forlinx@ubuntu:~/OK113i-linux-sdk$ ./build.sh
forlinx@ubuntu:~/OK113i-linux-sdk$ ./build.sh pack
- 烧写镜像后进入串口终端执行以下指令
root@ok113i:/# ls /sys/kernel/config/ //未出现信息为正常
接着将下方的命令输入串口终端
mount -t configfs none /sys/kernel/config
mkdir /sys/kernel/config/usb_gadget/g1
echo "0x1f3a" > /sys/kernel/config/usb_gadget/g1/idVendor
echo "0x0007" > /sys/kernel/config/usb_gadget/g1/idProduct
mkdir /sys/kernel/config/usb_gadget/g1/strings/0x409
mkdir /sys/kernel/config/usb_gadget/g1/functions/acm.usb0
mkdir /sys/kernel/config/usb_gadget/g1/configs/c.1
echo 0xc0 > /sys/kernel/config/usb_gadget/g1/configs/c.1/bmAttributes
echo 500 > /sys/kernel/config/usb_gadget/g1/configs/c.1/MaxPower
mkdir /sys/kernel/config/usb_gadget/g1/configs/c.1/strings/0x409
ln -s /sys/kernel/config/usb_gadget/g1/functions/acm.usb0/ /sys/kernel/config/usb_gadget/g1/configs/c.1/acm.usb0
ls /sys/class/udc/ | xargs echo > /sys/kernel/config/usb_gadget/g1/UDC
- 测试,这里通过找另一块开发板作为usb host,接入配置好USB ACM功能的113中,打开做usb host的开发板的串口终端,查看现象:
root@ok113i:/# lsusb
Bus 001 Device 001: ID 1d6b:0002
Bus 001 Device 002: ID 1a40:0101
Bus 002 Device 001: ID 1d6b:0001
Bus 001 Device 003: ID 0bda:d723
Bus 001 Device 004: ID 1f3a:0007
root@ok113i:/# ls /dev/ttyA*
/dev/ttyACM0 /dev/ttyAS0 /dev/ttyAS1 /dev/ttyAS3 /dev/ttyAS4
通过现象可以发现我们可以看到新生成的/dev/ttyACM0节点以及我们之前在做USB ACM功能的113中设置的USB的uid,vid ”1f3a:0007“,验证完成,已成功配置好USB ACM功能。 |