如何让Openharmony设备HDC接口(OTG接口)作为一个复合设备,实现HDC(HDC:鸿蒙设备连接器) + CDC ACM(USB 虚拟串口),而设备本身支持HDC。所以需要增加CDC ACM(USB 虚拟串口)。
本文主要讲解OpenHarmony中,板卡上的OTG接口如何支持复合设备,环境说明如下:
描述项 | 说明 |
---|---|
OpenHarmony版本 | release-4.0 |
内核版本 | 5.10 |
板卡 | 风火轮youyeetoo R1开发板(RK3588S) |
Linux内核5.10,是采用configfs来配置USB的功能,即配置USB gadget。实现USB复合设备之前,需要了解一些概念。
"mount configfs none /config"
"mkdir /config/usb_gadget/g1 0770 shell shell"
"write /config/usb_gadget/g1/idVendor 0x2207",
"write /config/usb_gadget/g1/idProduct 0x0018",
"write /config/usb_gadget/g1/os_desc/use 1",
"write /config/usb_gadget/g1/bcdDevice 0x0223",
"write /config/usb_gadget/g1/bcdUSB 0x0200",
"mkdir /config/usb_gadget/g1/strings/0x409 0770",
"copy /sys/block/mmcblk0/device/cid /config/usb_gadget/g1/strings/0x409/serialnumber",
"chmod 0640 /config/usb_gadget/g1/strings/0x409/serialnumber",
"write /config/usb_gadget/g1/strings/0x409/manufacturer Rockchip",
"write /config/usb_gadget/g1/strings/0x409/product \"HDC Device\"",
"mkdir /config/usb_gadget/g1/configs/b.1 0770 shell shell",
"mkdir /config/usb_gadget/g1/configs/b.1/strings/0x409 0770 shell shell",
"write /config/usb_gadget/g1/os_desc/b_vendor_code 0x1",
"write /config/usb_gadget/g1/os_desc/qw_sign MSFT100",
"write /config/usb_gadget/g1/configs/b.1/MaxPower 500",
mkdir /config/usb_gadget/g1/functions/<name>.<instance name>
mkdir /config/usb_gadget/g1/functions/ffs.hdc
"ln -s /config/usb_gadget/g1/functions/<name>.<instance name> /config/usb_gadget/g1/configs/c.1"
"symlink /config/usb_gadget/g1/configs/b.1 /config/usb_gadget/g1/os_desc/b.1",
"setparam sys.usb.configfs 1",
"setparam sys.usb.controller fc000000.usb"
CONFIG_USB_CONFIGFS_ACM=y
"mkdir /config/usb_gadget/g1/functions/acm.usb",
"symlink /config/usb_gadget/g1/functions/acm.usb /config/usb_gadget/g1/configs/b.1/f2",
本文分享自 Rice 嵌入式开发技术分享 微信公众号,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
本文参与 腾讯云自媒体同步曝光计划 ,欢迎热爱写作的你一起参与!