当前位置:网站首页>[openharmony] USB gadget configuration HDC function cfg file interpretation
[openharmony] USB gadget configuration HDC function cfg file interpretation
2022-06-23 15:59:00 【Fried lentil】
List of articles
cfg File path
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- First of all, will configfs The file system is mounted on the system
mount configfs none /config
One 、 Create device
- Create the directory corresponding to the device :
mkdir /config/usb_gadget/g1 0770 shell shell - Each device has its own product id and vendor id
write /config/usb_gadget/g1/idVendor 0x2207write /config/usb_gadget/g1/idProduct 0x0018 - Every device There must also be his Serial number 、 manufacturer 、 Product string , Create a string The directory is used to store this information .
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\"
Two 、 Create a configuration
- Each device consists of many configurations , The directories corresponding to these configurations also need to be created
mkdir /config/usb_gadget/g1/configs/b.1 0770 shell shell - Each configuration also needs its own string , So you need to create a corresponding for each language string Catalog
mkdir /config/usb_gadget/g1/configs/b.1/strings/0x409 0770 shell shell - Then the configuration string can be written in
write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration hdc - Other properties of this configuration can also be set
write /config/usb_gadget/g1/configs/b.1/MaxPower 500
3、 ... and 、 Create features
- The device will provide some functions , For each function, the corresponding directory must also be created
mkdir /config/usb_gadget/g1/functions/ffs.hdc
Four 、 Associate functions with corresponding configurations
- Now a lot of devices have been created , Each device has some configurations and some functions . Next, we need to identify which functions are effective in which configuration . A function can be included in multiple configurations . The above actions are completed through symbolic links .
symlink /config/usb_gadget/g1/functions/ffs.hdc /config/usb_gadget/g1/configs/b.1/f1
mount functionfs file system
- functionfs Think of it as a composite with unique behavior function. The main function is to mount functionfs File system directory ep0 Catalog , Used to write descriptors and strings to complete negotiation .
mount functionfs hdc /dev/usb-ffs/hdc uid=2000,gid=2000
5、 ... and 、 Enable the device
- To enable this device, we must bind it to some udc The above to
write /config/usb_gadget/g1/UDC ${sys.usb.controller}
UDC The name should be directory/sys/class/udc/*One of the following .
6、 ... and 、 To enable the device
write /config/usb_gadget/g1/UDC none
7、 ... and 、 eliminate
- Remove function from configuration
rm /config/usb_gadget/g1/configs/b.1/f1 - Remove the string directory in the configuration ( Did not find )
rmdir configs/<config name>.<number>/strings/<lang> - Remove configuration ( Did not find )
rmdir configs/<config name>.<number> - Remove features ( Did not find )
rmdir functions/<name>.<instance name> - Remove the device string Directory ( Did not find )
rmdir strings/<lang> - Finally remove the device
rmdir <gadget name>
Implementation design
- One gadget There is it config Group , This group has some properties (idVendor, idProduct etc) And default subgroups (configs, functions, strings).
- Write these properties , This will cause these attributes to be stored in the corresponding location . stay configs, functions, strings In the subgroup , Users can create their subgroups , Represents the corresponding configuration , Functions and strings .
- Users can create some configurations and functions , And use symbolic links to link them . On the device UDC After the attribute is written , This information will be used . This writing means that the device and the corresponding UDC It's connected .
drivers/usb/gadget/configfs.cThe code inside will facilitate all configurations , It will facilitate all functions in each configuration , And bind them .
Reference material
Linux USB gadget configured through configfs
How FunctionFS works
边栏推荐
- This year's cultural entertainers have turned their sidelines into their main business
- Android kotlin collaboration Async
- Big factory Architect: how to draw a grand business map?
- Quartz
- CA认证和颁发吊销证书
- Do you understand Mipi c-phy protocol? One of the high-speed interfaces for mobile phones
- AsyncContext简介
- freemark 使用ftl文件 生成word
- Variable declaration of go language
- 30. concatenate substrings of all words
猜你喜欢

Three simple tips for accelerating yarn install

If no code is moved, the project access speed drops significantly the next day. Case analysis
![生成二叉搜索平衡树[利用树递归特性]](/img/b3/f8edf45bdfdced7c3698088dbf7d84.png)
生成二叉搜索平衡树[利用树递归特性]

SQL窗口函数怎么使用

Important knowledge of golang: detailed explanation of context

This year's cultural entertainers have turned their sidelines into their main business

XML

The "shoulder" of sales and service in the heavy truck industry, Linyi Guangshun deep ploughing product life cycle service

Slice() and slice() of JS

Stone from another mountain - Intelligent Question and answer technology in wechat search
随机推荐
139. 单词拆分
5 minutes to quickly launch web applications and APIs (vercel)
一文看懂经典BUCK-BOOST负电压电路
MySQL日志管理怎么配置
现在我要买股票,怎么开户?手机开户安全么?
Memory Consistency and Cache Coherence —— 内存一致性
C. Add One--Divide by Zero 2021 and Codeforces Round #714 (Div. 2)
Apple iPhone, Samsung mobile phone and other electronic products began to enter Russia through parallel import channels
Quartz
xcbdfbs xcvb
TCP protocol notes
2022年个人理财利率是多少?个人如何选择理财产品?
get_edges
自监督学习(SSL)Self-Supervised Learning
B. AND 0, Sum Big-Codeforces Round #716 (Div. 2)
进阶开发阶段-势若悬丝的加粗开始. 现在的一小步,明年的一大步
The meaning of FPGA abbreviations and words in engineering field
PageHelper在面对复杂service数据处理下的分页问题
TCP协议笔记
Which platform is a good place to open a futures account? Is it safe to open an online futures account?