[技术讨论] 一些RTOS系统的usb命令使用方法

[复制链接]
563|0
 楼主| 神棍地海棠 发表于 2023-10-16 13:50 | 显示全部楼层 |阅读模式
本帖最后由 神棍地海棠 于 2023-10-16 13:52 编辑

以下命令在所有RTOS平台(MELIS/FREERTOS)都可以使用
通过menuconfig打开usb模块功能
RTOS通过usb命令集成了测试用例。通过如下命令即可显示支持的功能:
  1. <span class="hljs-comment" style="box-sizing: border-box; color: rgb(188, 148, 88); font-style: italic;">//输入如下命令</span>
  2. msh />usb

  3. Usage:
  4.         usb hci {-i|-r} [<port>]
  5.         usb udc {-i|-r} [<port>]
  6.         usb phy_range {-s|-g} {<port>} [<phyrange>]
  7.         usb ed_test {<port>} {<type>}
  8.         usb debug {<status>}
  9.         usb uvc_test

  10.         - - - - - - - - - - - - - - - - - - - - -
  11. Meaning:
  12.         -i:insmod, -r:rmmod, -s:<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(194, 98, 48);">set</span>, -g:<span class="hljs-keyword" style="box-sizing: border-box; color: rgb(194, 98, 48);">get</span>

  13.         port     : [<span class="hljs-number" style="box-sizing: border-box; color: rgb(165, 194, 97);">0</span><span class="hljs-number" style="box-sizing: border-box; color: rgb(165, 194, 97);">-0</span>],port number
  14.         phyrange : [<span class="hljs-number" style="box-sizing: border-box; color: rgb(165, 194, 97);">0x0</span><span class="hljs-number" style="box-sizing: border-box; color: rgb(165, 194, 97);">-0x1f</span>],phy range
  15.         status   : [<span class="hljs-number" style="box-sizing: border-box; color: rgb(165, 194, 97);">0</span>-disable,<span class="hljs-number" style="box-sizing: border-box; color: rgb(165, 194, 97);">1</span>-enable],hci debug status
  16.         type     : [test_j_state/test_k_state/test_se0_nak/test_pack]--hci & otg
  17.                    [<span class="hljs-meta" style="box-sizing: border-box; color: rgb(155, 133, 157);">test_not_operating/test_force_enable/test_mask</span>]--hci only

  18.         ==>> More information refer to spec <<==

HCI功能测试
命令形式:usb hci {-i|-r} [<port>]
  • 加载hci驱动(以USB1为例)
  1. <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(205, 168, 105);">usb</span> hci -i <span class="hljs-number" style="box-sizing: border-box; color: rgb(165, 194, 97);">1</span>
  • 卸载hci驱动(以USB1为例)
  1. <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(205, 168, 105);">usb</span> hci -r <span class="hljs-number" style="box-sizing: border-box; color: rgb(165, 194, 97);">1</span>
UDC功能测试
命令形式:usb udc {-i|-r} [<port>]
  • 加载udc驱动(以USB0为例)
  1. <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(205, 168, 105);">usb</span> udc -i <span class="hljs-number" style="box-sizing: border-box; color: rgb(165, 194, 97);">0</span>

  • 卸载udc驱动(以USB0为例)
  1. <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(205, 168, 105);">usb</span> udc -r <span class="hljs-number" style="box-sizing: border-box; color: rgb(165, 194, 97);">0</span>

UVC功能测试
命令形式:usb uvc_test
  • 启动uvs功能测试
  1. <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(205, 168, 105);">usb</span> uvc_test

phy range参数调整
命令形式:usb phy_range {-s|-g} {<port>} [<phyrange>]
  • 读取phy range参数(以USB0为例)
  1. usb phy_range -g 0

  2. OTG0 phy range
  3. phy_range = 0xa07, details:
  4. bit[12] = 0x0, mode iref-1 vref-0
  5. <span class="hljs-section" style="box-sizing: border-box; color: rgb(255, 198, 109);">bit[11:9] = 0x5, rise time(all usb)</span>
  6. <span class="hljs-section" style="box-sizing: border-box; color: rgb(255, 198, 109);">bit[8:6] = 0x0, rise time(current usb)</span>
  7. <span class="hljs-section" style="box-sizing: border-box; color: rgb(255, 198, 109);">bit[5:4] = 0x0, pre-emphasis</span>
  8. <span class="hljs-section" style="box-sizing: border-box; color: rgb(255, 198, 109);">bit[3:0] = 0x7, resistance</span>

USB0较为特殊,host和device的参数是分开调整的,注意打印,例如上述例子中,“OTG0 phy range”表示目前处于device模式,显示的是device端的phy range。
phy_range就是目前的值,调整参数可以在此基础上进行调整,具体含义参考上面打印中的提示。
  • 设置phy range参数(以USB0为例)
  1. usb phy_range -s <span class="hljs-number" style="box-sizing: border-box; color: rgb(165, 194, 97);">0</span> <span class="hljs-number" style="box-sizing: border-box; color: rgb(165, 194, 97);">0xa08</span>

  2. OTG0 phy range
  3. phy_range config <span class="hljs-keyword" style="box-sizing: border-box; color: rgb(194, 98, 48);">in</span> vref mode success!

同理,“OTG0 phy range”表示目前处于device模式,设置的是device端的phy range。
ed test测试模式设置
命令形式:usb ed_test {<port>} {<type>}
  • 设置ed_test测试模式(以USB1为例)
  1. <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(205, 168, 105);">usb</span> ed_test <span class="hljs-number" style="box-sizing: border-box; color: rgb(165, 194, 97);">1</span> test_j_state

usb debug功能启停
命令形式:usb debug {<status>}
  • 打开debug模式
  1. <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(205, 168, 105);">usb</span> <span class="hljs-literal" style="box-sizing: border-box;">debug</span> <span class="hljs-number" style="box-sizing: border-box; color: rgb(165, 194, 97);">1</span>
  • 关闭debug模式
  1. <span class="hljs-attribute" style="box-sizing: border-box; color: rgb(205, 168, 105);">usb</span> <span class="hljs-literal" style="box-sizing: border-box;">debug</span> <span class="hljs-number" style="box-sizing: border-box; color: rgb(165, 194, 97);">0</span>
您需要登录后才可以回帖 登录 | 注册

本版积分规则

284

主题

292

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部