Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solved USB device class issue. #3643

Merged
merged 2 commits into from Oct 24, 2020
Merged

Conversation

@wosayttn
Copy link
Contributor

@wosayttn wosayttn commented Jun 2, 2020

拉取/合并请求描述:(PR description)

[
Enable HS device functions(VCOM, HID, MSTORAGE) for Nuvoton M487 platform.
]

以下的内容不应该在提交PR时的message修改,修改下述message,PR会被直接关闭。请在提交PR后,浏览器查看PR并对以下检查项逐项check,没问题后逐条在页面上打钩。
The following content must not be changed in submitted PR message. Otherwise, the PR will be closed immediately. After submitted PR, please use web browser to visit PR, and check items one by one, and ticked them if no problem.

当前拉取/合并请求的状态 Intent for your PR

必须选择一项 Choose one (Mandatory):

  • 本拉取/合并请求是一个草稿版本 This PR is for a code-review and is intended to get feedback
  • 本拉取/合并请求是一个成熟版本 This PR is mature, and ready to be integrated into the repo

代码质量 Code Quality:

我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:

  • 已经仔细查看过代码改动的对比 Already check the difference between PR and old code
  • 代码风格正确,包括缩进空格,命名及其他风格 Style guide is adhered to, including spacing, naming and other style
  • 没有垃圾代码,代码尽量精简,不包含#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up
  • 所有变更均有原因及合理的,并且不会影响到其他软件组件代码或BSP All modifications are justified and not affect other components or BSP
  • 对难懂代码均提供对应的注释 I've commented appropriately where code is tricky
  • 本拉取/合并请求代码是高质量的 Code in this PR is of high quality
@wosayttn wosayttn mentioned this pull request Jun 29, 2020
7 of 8 tasks complete
@BernardXiong BernardXiong requested a review from Guozhanxin Sep 27, 2020
//rt_usbd_device_set_qualifier(device, &dev_qualifier);

/* support HS */
rt_usbd_device_set_qualifier(device, &dev_qualifier);

This comment has been minimized.

@balanceTWK

balanceTWK Sep 29, 2020
Member

cdc_vcom 支持 HS 应该没这么简单。可能还需要改些其他的(甚至是重构)。

    //not support HS
    //rt_usbd_device_set_qualifier(device, &dev_qualifier);

这笔代码是 大法师 @lymzzyh 当年注释掉,这个应该是有原因的。

下面的当年修改的 Commit 信息:

Commit:        5035662cd95d9fae90d31608329f31fac3a67362
...
...

[Components][USB Device]各个class对HS进行了适配

部分class还不支持HS,RNDIS存在暂时无法解决的已知bug

-----------------------------

 components/drivers/usb/usbdevice/class/cdc_vcom.c | 19 +++++++------
 components/drivers/usb/usbdevice/class/ecm.c      | 30 +++++++++++---------
 components/drivers/usb/usbdevice/class/hid.c      | 22 +++++++++------
 components/drivers/usb/usbdevice/class/mstorage.c | 30 +++++++++++---------
 components/drivers/usb/usbdevice/class/rndis.c    | 34 ++++++++++++-----------
 5 files changed, 76 insertions(+), 59 deletions(-)

This comment has been minimized.

@wosayttn

wosayttn Oct 12, 2020
Author Contributor

我們在 M487 平台上,使用 HS USB DEVICE 整合測試過 RTT USB device 的 classes 包含 VCOM, HID, Mass storage, WinUSB; 未測試過 RNDIS。

@@ -246,7 +246,7 @@ static struct udevice_descriptor _dev_desc =
USB_DESC_LENGTH_DEVICE, //bLength;
USB_DESC_TYPE_DEVICE, //type;
USB_BCD_VERSION, //bcdUSB;
USB_CLASS_HID, //bDeviceClass;
0x0, //bDeviceClass;

This comment has been minimized.

@balanceTWK

balanceTWK Sep 29, 2020
Member

为啥要改成 0x0 。

This comment has been minimized.

@wosayttn

wosayttn Oct 12, 2020
Author Contributor

改為 USB_CLASS_DEVICE(0),由 interface 指定 own class code。

USB_CLASS_MASS_STORAGE, //bDeviceClass
0x06, //bDeviceSubClass
0x0, //bDeviceClass
0x0, //bDeviceSubClass

This comment has been minimized.

@balanceTWK

balanceTWK Sep 29, 2020
Member

同上,能不能贴下这样改的相关依据不?(比如 usb 白皮书之类的截图)

This comment has been minimized.

@wosayttn

wosayttn Oct 12, 2020
Author Contributor

(1) 修正錯誤宣告 - USB_CLASS_MASS_STORAGE。
(2) 同步上述 "USB_CLASS_DEVICE(0),由 interface 指定 own class code。" 的做法。

@@ -347,7 +347,7 @@ const static struct uhid_comm_descriptor _hid_comm_desc =
USB_DYNAMIC | USB_DIR_IN,
USB_EP_ATTR_INT,
0x40,
0x01,
0x0A,

This comment has been minimized.

@balanceTWK

balanceTWK Sep 29, 2020
Member

额 这样直接改成 0x0A 应该不合适吧,我这边查到的资料是:轮询间隔值 4,但对高速设备来说是 8 。 如果这个值没有严格要求,那么是不是可以改成宏,默认值 0x0A。然后开发者可以根据自己的实际情况修改调节。

This comment has been minimized.

@wosayttn

wosayttn Oct 12, 2020
Author Contributor

此值 0xA (for HS USB device) 是在 RTT@M487 實測後,較 safety 設定值 。
Image 82

@@ -486,7 +487,7 @@ static rt_err_t _interface_handler(ufunction_t func, ureq_t setup)
dcd_ep0_send_status(func->device->dcd);
break;
case USB_HID_REQ_GET_PROTOCOL:
rt_usbd_ep0_write(func->device, &data->protocol,2);
rt_usbd_ep0_write(func->device, &data->protocol,1);

This comment has been minimized.

@balanceTWK

balanceTWK Sep 29, 2020
Member

还是和前面一样,贴下 USB HID 白皮书里的内容吧,需要给出依据来,才能合并。👀

This comment has been minimized.

@BernardXiong

BernardXiong Oct 1, 2020
Member

@balanceTWK please try it under M487.

This comment has been minimized.

@wosayttn

wosayttn Oct 12, 2020
Author Contributor

See hid1_11.pdf
HID_GET_PROTOCOL

HID USB device should response Data length is 1 byte to HOST by wLength=1 in this Get_Protocol request.

@Guozhanxin Guozhanxin removed their request for review Sep 29, 2020
@wosayttn wosayttn requested review from balanceTWK and BernardXiong Oct 12, 2020
Copy link
Member

@balanceTWK balanceTWK left a comment

M487 :虚拟串口,以及 模拟鼠标 验证 OK

STM32F407-ATK : 虚拟串口 验证 OK

@BernardXiong BernardXiong merged commit bd91d54 into RT-Thread:master Oct 24, 2020
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
license/cla Contributor License Agreement is signed.
Details
@wosayttn wosayttn deleted the OpenNuvoton:rtt_usb_issues branch Oct 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.