打印
[技术讨论]

一些RTOS系统的usb命令使用方法

[复制链接]
234|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
神棍地海棠|  楼主 | 2023-10-16 13:50 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 神棍地海棠 于 2023-10-16 13:52 编辑

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

Usage:
        usb hci {-i|-r} [<port>]
        usb udc {-i|-r} [<port>]
        usb phy_range {-s|-g} {<port>} [<phyrange>]
        usb ed_test {<port>} {<type>}
        usb debug {<status>}
        usb uvc_test

        - - - - - - - - - - - - - - - - - - - - -
Meaning:
        -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>

        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
        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
        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
        type     : [test_j_state/test_k_state/test_se0_nak/test_pack]--hci & otg
                   [<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

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

HCI功能测试
命令形式:usb hci {-i|-r} [<port>]
  • 加载hci驱动(以USB1为例)
<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为例)
<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为例)
<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为例)
<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功能测试
<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为例)
usb phy_range -g 0

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

OTG0 phy range
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为例)
<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模式
<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模式
<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>

使用特权

评论回复

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

260

主题

268

帖子

0

粉丝