Skip to content

fix: usbd_set_interface close unexpected endpoint#258

Closed
CutClassH wants to merge 1 commit intocherry-embedded:masterfrom
CutClassH:master
Closed

fix: usbd_set_interface close unexpected endpoint#258
CutClassH wants to merge 1 commit intocherry-embedded:masterfrom
CutClassH:master

Conversation

@CutClassH
Copy link
Copy Markdown
Contributor

当一个Interface多个AlternateSetting的时候,比如下面描述符的情况,当设置interface 1, alt setting 1时,会在遍历到alt setting 2时错误地关闭endpoint 2

        ---------------- Interface Descriptor -----------------
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x04 (Interface Descriptor)
bInterfaceNumber         : 0x01 (Interface 1)
bAlternateSetting        : 0x01
bNumEndpoints            : 0x02 (2 Endpoints)
bInterfaceClass          : 0x01 (Audio)
bInterfaceSubClass       : 0x02 (Audio Streaming)
bInterfaceProtocol       : 0x20 (Device Protocol Version 2.0)
iInterface               : 0x00 (No String Descriptor)
Data (HexDump)           : 09 04 01 01 02 01 02 20 00                       

 ....... .

        ---------------- Interface Descriptor -----------------
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x04 (Interface Descriptor)
bInterfaceNumber         : 0x01 (Interface 1)
bAlternateSetting        : 0x02
bNumEndpoints            : 0x02 (2 Endpoints)
bInterfaceClass          : 0x01 (Audio)
bInterfaceSubClass       : 0x02 (Audio Streaming)
bInterfaceProtocol       : 0x20 (Device Protocol Version 2.0)
iInterface               : 0x00 (No String Descriptor)
Data (HexDump)           : 09 04 01 02 02 01 02 20 00      

@CutClassH
Copy link
Copy Markdown
Contributor Author

没有考虑一个interface alt setting有多个endpoint的情况,暂时关闭

@CutClassH CutClassH closed this Sep 25, 2024
@sakumisu
Copy link
Copy Markdown
Collaborator

多个 alt setting的话,使用的ep也是一样的。不过这边循环遍历的话确实会有问题,重复关闭了多次。我的建议是在 reset 中判断,如果已经reset了一次则跳过即可。

@CutClassH
Copy link
Copy Markdown
Contributor Author

sorry,我没有把问题描述清楚。
多alt setting使用同一个endpoint的时候,如果要配置成alt setting 1,会先遍历到alt setting 1打开对应的endpoint,但是后面遍历到2的时候又会关闭对应的endpoint。

[D/USB] EP0 send 0 bytes, 0 remained
[D/USB] Start reading 4 bytes from ep0
[D/USB] EP0 recv 4 bytes, 0 remained
[D/USB] Audio Class request: bRequest 0x01
[D/USB] Audio entity_id:01, subtype:0a, cs:01
[D/USB] Set ep:0x02 192000 Hz
[D/USB] EP0 send 0 bytes, 0 remained
[D/USB] iface 1 alt_setting 1
[D/USB] Current iface 0 alt setting 0
[D/USB] Current iface 1 alt setting 0
[D/USB] Current iface 1 alt setting 1
[D/USB] Open ep:0x02 type:1 mps:96
[D/USB] Current iface 1 alt setting 2
[D/USB] Close ep:0x02 type:1
[D/USB] Current iface 2 alt setting 0
[D/USB] Current iface 2 alt setting 1
OPEN1
[D/USB] EP0 send 0 bytes, 0 remained

所以这里是需要修复的。但是我的PR会引入另一个问题,所以我把它关闭了。

@sakumisu
Copy link
Copy Markdown
Collaborator

恩我理解你的意思,这个我来改吧

@sakumisu
Copy link
Copy Markdown
Collaborator

fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants