当前位置:网站首页>【OpenHarmony】usb gadget 配置hdc功能cfg文件解读
【OpenHarmony】usb gadget 配置hdc功能cfg文件解读
2022-06-23 15:27:00 【炒扁豆】
cfg文件所在路径
https://gitee.com/openharmony/device_board_hihope/blob/master/rk3568/cfg/init.rk3568.usb.cfghttps://gitee.com/openharmony/startup_init_lite/blob/master/services/etc/init.usb.configfs.cfg- 首先将configfs文件系统挂载到系统上
mount configfs none /config
一、创建设备
- 创建设备对应的目录:
mkdir /config/usb_gadget/g1 0770 shell shell - 每个设备有它自己的product id和vendor id
write /config/usb_gadget/g1/idVendor 0x2207write /config/usb_gadget/g1/idProduct 0x0018 - 每个设备 也必须有他的 序列号、厂商、产品字符串,创建一个string目录用来存放这些信息。
mkdir /config/usb_gadget/g1/strings/0x409 0770copy /sys/block/mmcblk0/device/cid /config/usb_gadget/g1/strings/0x409/serialnumberwrite /config/usb_gadget/g1/strings/0x409/manufacturer Rockchipwrite /config/usb_gadget/g1/strings/0x409/product \"HDC Device\"
二、创建配置
- 每个设备由许多配置组成,这些配置对应的目录也需要被创建
mkdir /config/usb_gadget/g1/configs/b.1 0770 shell shell - 每个配置也需要有自己的字符串,所以对于每种语言需要创建一个对应的string目录
mkdir /config/usb_gadget/g1/configs/b.1/strings/0x409 0770 shell shell - 然后这个配置的字符串就可以被写进去了
write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration hdc - 这个配置的其它一些属性也可以被设置进去
write /config/usb_gadget/g1/configs/b.1/MaxPower 500
三、创建功能
- 设备将会提供一些功能,对于每一个功能其对应的目录也必须被创建
mkdir /config/usb_gadget/g1/functions/ffs.hdc
四、将功能和对应的配置关联起来
- 现在创建了很多设备,每个设备有一些配置和一些功能。那么接下来就需要我们标识出来哪些功能在哪个配置里面是有效。一个功能可以被包含在多个配置当中。上述动作通过符号链接来完成。
symlink /config/usb_gadget/g1/functions/ffs.hdc /config/usb_gadget/g1/configs/b.1/f1
挂载functionfs文件系统
- functionfs可以把它当做一个具有独特行为的复合function。主要作用是在挂载的functionfs文件系统目录下生成ep0目录,用来写入描述符和字符串完成协商。
mount functionfs hdc /dev/usb-ffs/hdc uid=2000,gid=2000
五、使能该设备
- 为了使能这个设备我们必须要将它绑定到某个udc上面去
write /config/usb_gadget/g1/UDC ${sys.usb.controller}
UDC名称应该是目录/sys/class/udc/*下面的某一个。
六、去使能该设备
write /config/usb_gadget/g1/UDC none
七、清除
- 从配置里面移除功能
rm /config/usb_gadget/g1/configs/b.1/f1 - 移除配置里面的字符串目录(没找到)
rmdir configs/<config name>.<number>/strings/<lang> - 移除配置(没找到)
rmdir configs/<config name>.<number> - 移除功能(没找到)
rmdir functions/<name>.<instance name> - 移除设备字符串目录(没找到)
rmdir strings/<lang> - 最后移除设备
rmdir <gadget name>
实现设计
- 一个gadget有它的config组,这个组有一些属性(idVendor, idProduct etc)和默认的子组(configs, functions, strings)。
- 写这些属性,将会导致这些属性存储在对应的位置。在configs, functions, strings子组里面,用户可以创建他们的子组,代表相应的配置,功能和字符串。
- 用户可以创建一些配置和功能,并使用符号链接将他们关联起来。在设备的UDC属性被写之后,这些信息将会被使用。这个写意味着将该设备和对应的UDC关联起来了。
drivers/usb/gadget/configfs.c里面的代码将会便利所有的配置,在每个配置里面将会便利所有的功能,并绑定他们。
参考资料
Linux USB gadget configured through configfs
How FunctionFS works
边栏推荐
- Wechat applet guides users to add applet animation page
- B. AND 0, Sum Big-Codeforces Round #716 (Div. 2)
- Pop() element in JS
- Explain in detail the principle and implementation of redis distributed lock
- 怎样快速的应对变动的生产管理需求?
- 一文看懂经典BUCK-BOOST负电压电路
- MySQL transactions and locks
- MES在流程和离散制造企业的15个差别(上)
- 创建好后的模型,对Con2d, ConvTranspose2d ,以及归一化BatchNorm2d函数中的变量进行初始化
- 30. concatenate substrings of all words
猜你喜欢

A transformer can only convert alternating current. How can I convert direct current?

XML

SQL窗口函数怎么使用

这五年的6个编程感悟!

Slice() and slice() of JS
The idea and method of MySQL master-slave only synchronizing some libraries or tables

513. Find Bottom Left Tree Value

stylegan1: a style-based henerator architecture for gemerative adversarial networks

Half wave loss equal thickness and equal inclination interference

30. 串联所有单词的子串
随机推荐
stylegan1: a style-based henerator architecture for gemerative adversarial networks
MES在流程和离散制造企业的15个差别(上)
Gartner's latest report: development of low code application development platform in China
How can I get the discount for opening a securities account? Is online account opening safe?
Matlab| sparse auxiliary signal denoising and pattern recognition in time series data
Embedded software architecture design - program layering
要买的理财产品年限长,划算吗?
B. AND 0, Sum Big-Codeforces Round #716 (Div. 2)
30. concatenate substrings of all words
云上探“店”,云商店全新升级!
MySQL series: storage engine
Important knowledge of golang: mutex
30. 串联所有单词的子串
进阶开发- 泛型入门基础类测试
SQL窗口函数怎么使用
Stone from another mountain - Intelligent Question and answer technology in wechat search
golang 重要知识:mutex
中大人脸素描FERET数据库(CUFSF)
图片读取:Image.open(ImgPath)
力扣每日一题-第25天-495.提莫攻击