-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Plug in two devices at once, no devices found, panic #2556
Comments
Those messages are a bit spammy. I reduced the debugging level to 2, and this is what I got: [0:] USBH DEVICE ATTACH Set Address = 5 [0:5] Open EP0 with Size = 64 Get Configuration[0] Descriptor (9 bytes) Get Configuration[0] Descriptor Set Configuration = 1 Device configured HUB Set Feature: PORT_POWER, addr = 5 port = 1 HUB Set Feature: PORT_POWER, addr = 5 port = 2 HUB Set Feature: PORT_POWER, addr = 5 port = 3 *** PANIC *** Invalid speed |
The panic is coming from "hdc_rp2040.c", here:
The value being returned by
If I'm reading the docs right, this is asserting "ACK received" and "VBUS Detected". But the speed bits are reading zero, which means "disconnected." But obviously it's not disconnected. All of those debug messages I pasted came from me plugging devices in. |
This can be overcome in user code. See https://github.com/UKTailwind/PicoMite/blob/main/USBKeyboard.c for how I do it. Note you MUST NOT issue any tuh_hid_send_report commands or similar in the mount callback or you will hit issues |
Can you give me a hint about how this example overcomes the problem? I've looked through the mount code, and I'm not seeing it do anything special with regard to USB. Also, my mount code doesn't send any reports. In fact, for me, if I plug in two devices at once, the mount callback never gets called at all, so there's nothing in my mount callback that could either cause or mitigate the problem. The only indication I have that anything happens is that |
I don't know anything about USB, so this is slow going for me, but it looks like the problem is being caused by an attempt to set power management on a hub, and TinyUSB may not be giving it sufficient time to complete that setup before performing further communication. I've tried putting delays in various places, but I'm stabbing randomly. If someone who knows what they're doing could give me some hints about where I might put strategic delays, that would be really helpful. Basically, we have some hubs being set up successfully, like this:
But then the last one dies when
And this is what I get from that:
I'm guessing some command is being sent to the hub, and then insufficient time is being allotted for a response. But it's not clear to me where these transfers are happening or when to insert any sort of delay. |
It also occurred to me that perhaps the end point it's trying to get the speed for doesn't really exist, so I modified hcd_port_speed_get to return TUSB_SPEED_INVALID on an invalid speed. It got a little further and then died here:
It prints this:
|
I'm comparing the success and failure cases. The success case is when only the keyboard (with its internal hub) is plugged in, while the failure case has the mouse also plugged in. The logs are identical up to a certain point. Everything is pretty much the same as I shared above, ending with this:
At this point, the failure case panics due to an "Invalid speed." The success case is identical up to that point, but then it finishes with this operation as so:
The success case then goes on to mount that hub and so on.
So there's definitely a problem with handling hubs. BTW, one time I had the same invalid speed panic with just the keyboard. I think the presence of the mouse is affecting the behavior of the hub, and TinyUSB isn't accounting for that. |
Operating System
Linux
Board
Raspberry Pi Pico
Firmware
Custom firmware. You can see my whole project here: https://github.com/theosib/pico_vga/tree/main
What happened ?
TinyUSB detects no new devices when two are plugged in at once
How to reproduce ?
Plug in a keyboard and mouse simultaneously.
I'm undertaking an investigation to find out why nothing happens when I plug in a keyboard and mouse at the same time. A log is attached. The logging seems to be interfering, however, with the investigation because the panic you see at the end was not occurring until I enabled debug messages. Still, hopefully there is something informative in the log. I'll keep updating this with more information.
Debug Log as txt file (LOG/CFG_TUSB_DEBUG=2)
delay 540060, 993, 536098, 83557
[0:] USBH DEVICE ATTACH
hcd_port_reset
hcd_port_connect_status
Full Speed
[0:0] Open EP0 with Size = 8
hcd_edpt_open dev_addr 0, ep_addr 0
hw_endpoint_init dev 0 ep 0 out xfer 0
dev 0 ep 0 out setup buffer @ 0x50100180
endpoint control (0x50100100) <- 0xa0000180
Get 8 byte of Device Descriptor
[0:0] Get Descriptor: 80 06 00 01 00 00 08 00
hw_endpoint_init dev 0 ep 0 out xfer 0
dev 0 ep 0 out setup buffer @ 0x50100180
endpoint control (0x50100100) <- 0xa0000180
Transfer complete
Sent setup packet
on EP 00 with 8 bytes: OK
hcd_edpt_xfer dev_addr 0, ep_addr 0x80, len 8
hw_endpoint_init dev 0 ep 0 in xfer 0
dev 0 ep 0 in setup buffer @ 0x50100180
endpoint control (0x50100100) <- 0xa0000180
Prepare BufCtrl: [0] = 0x7408 [1] = 0x0000
Buffer complete
buf_status 0x00000001
Single Buffered: ep_ctrl = 0xA0000180
Sync BufCtrl: [0] = 0xe008 [1] = 0x0000
Completed transfer of 8 bytes on ep 80
Transfer complete
on EP 80 with 8 bytes: OK
[0:0] Control data:
0000: 12 01 00 02 09 00 00 40 |.......@|
hcd_edpt_xfer dev_addr 0, ep_addr 0x0, len 0
hw_endpoint_init dev 0 ep 0 out xfer 0
dev 0 ep 0 out setup buffer @ 0x50100180
endpoint control (0x50100100) <- 0xa0000180
Prepare BufCtrl: [0] = 0xf400 [1] = 0x0000
Buffer complete
buf_status 0x00000001
Single Buffered: ep_ctrl = 0xA0000180
Sync BufCtrl: [0] = 0x6000 [1] = 0x0000
Short packet on buffer 0 with 0 bytes
Completed transfer of 0 bytes on ep 00
Transfer complete
on EP 00 with 0 bytes: OK
Set Address = 5
[0:0] Set Address: 00 05 05 00 00 00 00 00
hw_endpoint_init dev 0 ep 0 out xfer 0
dev 0 ep 0 out setup buffer @ 0x50100180
endpoint control (0x50100100) <- 0xa0000180
Transfer complete
Sent setup packet
on EP 00 with 8 bytes: OK
hcd_edpt_xfer dev_addr 0, ep_addr 0x80, len 0
hw_endpoint_init dev 0 ep 0 in xfer 0
dev 0 ep 0 in setup buffer @ 0x50100180
endpoint control (0x50100100) <- 0xa0000180
Prepare BufCtrl: [0] = 0x7400 [1] = 0x0000
Buffer complete
buf_status 0x00000001
Single Buffered: ep_ctrl = 0xA0000180
Sync BufCtrl: [0] = 0xe000 [1] = 0x0000
Short packet on buffer 0 with 0 bytes
Completed transfer of 0 bytes on ep 80
Transfer complete
on EP 80 with 0 bytes: OK
hcd_device_close 0
[0:5] Open EP0 with Size = 64
hcd_edpt_open dev_addr 5, ep_addr 0
hw_endpoint_init dev 5 ep 0 out xfer 0
dev 5 ep 0 out setup buffer @ 0x50100180
endpoint control (0x50100100) <- 0xa0000180
Get Device Descriptor
[0:5] Get Descriptor: 80 06 00 01 00 00 12 00
hw_endpoint_init dev 5 ep 0 out xfer 0
dev 5 ep 0 out setup buffer @ 0x50100180
endpoint control (0x50100100) <- 0xa0000180
Transfer complete
Sent setup packet
on EP 00 with 8 bytes: OK
hcd_edpt_xfer dev_addr 5, ep_addr 0x80, len 18
hw_endpoint_init dev 5 ep 0 in xfer 0
dev 5 ep 0 in setup buffer @ 0x50100180
endpoint control (0x50100100) <- 0xa0000180
Prepare BufCtrl: [0] = 0x7412 [1] = 0x0000
Buffer complete
buf_status 0x00000001
Single Buffered: ep_ctrl = 0xA0000180
Sync BufCtrl: [0] = 0xe012 [1] = 0x0000
Short packet on buffer 0 with 18 bytes
Completed transfer of 18 bytes on ep 80
Transfer complete
on EP 80 with 18 bytes: OK
[0:5] Control data:
0000: 12 01 00 02 09 00 00 40 AC 05 06 10 15 96 01 02 |.......@........|
0010: 03 01 |..|
hcd_edpt_xfer dev_addr 5, ep_addr 0x0, len 0
hw_endpoint_init dev 5 ep 0 out xfer 0
dev 5 ep 0 out setup buffer @ 0x50100180
endpoint control (0x50100100) <- 0xa0000180
Prepare BufCtrl: [0] = 0xf400 [1] = 0x0000
Buffer complete
buf_status 0x00000001
Single Buffered: ep_ctrl = 0xA0000180
Sync BufCtrl: [0] = 0x6000 [1] = 0x0000
Short packet on buffer 0 with 0 bytes
Completed transfer of 0 bytes on ep 00
Transfer complete
on EP 00 with 0 bytes: OK
Get Configuration[0] Descriptor (9 bytes)
[0:5] Get Descriptor: 80 06 00 02 00 00 09 00
hw_endpoint_init dev 5 ep 0 out xfer 0
dev 5 ep 0 out setup buffer @ 0x50100180
endpoint control (0x50100100) <- 0xa0000180
Transfer complete
Sent setup packet
on EP 00 with 8 bytes: OK
hcd_edpt_xfer dev_addr 5, ep_addr 0x80, len 9
hw_endpoint_init dev 5 ep 0 in xfer 0
dev 5 ep 0 in setup buffer @ 0x50100180
endpoint control (0x50100100) <- 0xa0000180
Prepare BufCtrl: [0] = 0x7409 [1] = 0x0000
Buffer complete
buf_status 0x00000001
Single Buffered: ep_ctrl = 0xA0000180
Sync BufCtrl: [0] = 0xe009 [1] = 0x0000
Short packet on buffer 0 with 9 bytes
Completed transfer of 9 bytes on ep 80
Transfer complete
on EP 80 with 9 bytes: OK
[0:5] Control data:
0000: 09 02 19 00 01 01 00 A0 28 |........(|
hcd_edpt_xfer dev_addr 5, ep_addr 0x0, len 0
hw_endpoint_init dev 5 ep 0 out xfer 0
dev 5 ep 0 out setup buffer @ 0x50100180
endpoint control (0x50100100) <- 0xa0000180
Prepare BufCtrl: [0] = 0xf400 [1] = 0x0000
Buffer complete
buf_status 0x00000001
Single Buffered: ep_ctrl = 0xA0000180
Sync BufCtrl: [0] = 0x6000 [1] = 0x0000
Short packet on buffer 0 with 0 bytes
Completed transfer of 0 bytes on ep 00
Transfer complete
on EP 00 with 0 bytes: OK
Get Configuration[0] Descriptor
[0:5] Get Descriptor: 80 06 00 02 00 00 19 00
hw_endpoint_init dev 5 ep 0 out xfer 0
dev 5 ep 0 out setup buffer @ 0x50100180
endpoint control (0x50100100) <- 0xa0000180
Transfer complete
Sent setup packet
on EP 00 with 8 bytes: OK
hcd_edpt_xfer dev_addr 5, ep_addr 0x80, len 25
hw_endpoint_init dev 5 ep 0 in xfer 0
dev 5 ep 0 in setup buffer @ 0x50100180
endpoint control (0x50100100) <- 0xa0000180
Prepare BufCtrl: [0] = 0x7419 [1] = 0x0000
Buffer complete
buf_status 0x00000001
Single Buffered: ep_ctrl = 0xA0000180
Sync BufCtrl: [0] = 0xe019 [1] = 0x0000
Short packet on buffer 0 with 25 bytes
Completed transfer of 25 bytes on ep 80
Transfer complete
on EP 80 with 25 bytes: OK
[0:5] Control data:
0000: 09 02 19 00 01 01 00 A0 28 09 04 00 00 01 09 00 |........(.......|
0010: 00 00 07 05 81 03 01 00 FF |.........|
hcd_edpt_xfer dev_addr 5, ep_addr 0x0, len 0
hw_endpoint_init dev 5 ep 0 out xfer 0
dev 5 ep 0 out setup buffer @ 0x50100180
endpoint control (0x50100100) <- 0xa0000180
Prepare BufCtrl: [0] = 0xf400 [1] = 0x0000
Buffer complete
buf_status 0x00000001
Single Buffered: ep_ctrl = 0xA0000180
Sync BufCtrl: [0] = 0x6000 [1] = 0x0000
Short packet on buffer 0 with 0 bytes
Completed transfer of 0 bytes on ep 00
Transfer complete
on EP 00 with 0 bytes: OK
Set Configuration = 1
[0:5] Set Configuration: 00 09 01 00 00 00 00 00
hw_endpoint_init dev 5 ep 0 out xfer 0
dev 5 ep 0 out setup buffer @ 0x50100180
endpoint control (0x50100100) <- 0xa0000180
Transfer complete
Sent setup packet
on EP 00 with 8 bytes: OK
hcd_edpt_xfer dev_addr 5, ep_addr 0x80, len 0
hw_endpoint_init dev 5 ep 0 in xfer 0
dev 5 ep 0 in setup buffer @ 0x50100180
endpoint control (0x50100100) <- 0xa0000180
Prepare BufCtrl: [0] = 0x7400 [1] = 0x0000
Buffer complete
buf_status 0x00000001
Single Buffered: ep_ctrl = 0xA0000180
Sync BufCtrl: [0] = 0xe000 [1] = 0x0000
Short packet on buffer 0 with 0 bytes
Completed transfer of 0 bytes on ep 80
Transfer complete
on EP 80 with 0 bytes: OK
[5] Aborted transfer on EP 01
[5] Aborted transfer on EP 81
[5] Aborted transfer on EP 02
[5] Aborted transfer on EP 82
[5] Aborted transfer on EP 03
[5] Aborted transfer on EP 83
[5] Aborted transfer on EP 04
[5] Aborted transfer on EP 84
[5] Aborted transfer on EP 05
[5] Aborted transfer on EP 85
[5] Aborted transfer on EP 06
[5] Aborted transfer on EP 86
[5] Aborted transfer on EP 07
[5] Aborted transfer on EP 87
[5] Aborted transfer on EP 08
[5] Aborted transfer on EP 88
[5] Aborted transfer on EP 09
[5] Aborted transfer on EP 89
[5] Aborted transfer on EP 0A
[5] Aborted transfer on EP 8A
[5] Aborted transfer on EP 0B
[5] Aborted transfer on EP 8B
[5] Aborted transfer on EP 0C
[5] Aborted transfer on EP 8C
[5] Aborted transfer on EP 0D
[5] Aborted transfer on EP 8D
[5] Aborted transfer on EP 0E
[5] Aborted transfer on EP 8E
[5] Aborted transfer on EP 0F
[5] Aborted transfer on EP 8F
Device configured
Parsing Configuration descriptor (wTotalLength = 25)
Open EP 81 with Size = 1
hcd_edpt_open dev_addr 5, ep_addr 129
Allocate interrupt ep 0
hw_endpoint_init dev 5 ep 1 in xfer 3
dev 5 ep 1 in setup buffer @ 0x50100200
endpoint control (0x50100008) <- 0xacfe0200
HUB opened
Bind EP 81 to driver id 1
HUB set config: itf = 0
[0:5] Class Request: A0 06 00 00 00 00 09 00
hw_endpoint_init dev 5 ep 0 out xfer 0
dev 5 ep 0 out setup buffer @ 0x50100180
endpoint control (0x50100100) <- 0xa0000180
Transfer complete
Sent setup packet
on EP 00 with 8 bytes: OK
hcd_edpt_xfer dev_addr 5, ep_addr 0x80, len 9
hw_endpoint_init dev 5 ep 0 in xfer 0
dev 5 ep 0 in setup buffer @ 0x50100180
endpoint control (0x50100100) <- 0xa0000180
Prepare BufCtrl: [0] = 0x7409 [1] = 0x0000
Buffer complete
buf_status 0x00000001
Single Buffered: ep_ctrl = 0xA0000180
Sync BufCtrl: [0] = 0xe009 [1] = 0x0000
Short packet on buffer 0 with 9 bytes
Completed transfer of 9 bytes on ep 80
Transfer complete
on EP 80 with 9 bytes: OK
[0:5] Control data:
0000: 09 29 03 8D 00 32 50 04 FF |.)...2P..|
hcd_edpt_xfer dev_addr 5, ep_addr 0x0, len 0
hw_endpoint_init dev 5 ep 0 out xfer 0
dev 5 ep 0 out setup buffer @ 0x50100180
endpoint control (0x50100100) <- 0xa0000180
Prepare BufCtrl: [0] = 0xf400 [1] = 0x0000
Buffer complete
buf_status 0x00000001
Single Buffered: ep_ctrl = 0xA0000180
Sync BufCtrl: [0] = 0x6000 [1] = 0x0000
Short packet on buffer 0 with 0 bytes
Completed transfer of 0 bytes on ep 00
Transfer complete
on EP 00 with 0 bytes: OK
HUB Set Feature: PORT_POWER, addr = 5 port = 1
[0:5] Class Request: 23 03 08 00 01 00 00 00
hw_endpoint_init dev 5 ep 0 out xfer 0
dev 5 ep 0 out setup buffer @ 0x50100180
endpoint control (0x50100100) <- 0xa0000180
Transfer complete
Sent setup packet
on EP 00 with 8 bytes: OK
hcd_edpt_xfer dev_addr 5, ep_addr 0x80, len 0
hw_endpoint_init dev 5 ep 0 in xfer 0
dev 5 ep 0 in setup buffer @ 0x50100180
endpoint control (0x50100100) <- 0xa0000180
Prepare BufCtrl: [0] = 0x7400 [1] = 0x0000
Buffer complete
buf_status 0x00000001
Single Buffered: ep_ctrl = 0xA0000180
Sync BufCtrl: [0] = 0xe000 [1] = 0x0000
Short packet on buffer 0 with 0 bytes
Completed transfer of 0 bytes on ep 80
Transfer complete
on EP 80 with 0 bytes: OK
HUB Set Feature: PORT_POWER, addr = 5 port = 2
[0:5] Class Request: 23 03 08 00 02 00 00 00
hw_endpoint_init dev 5 ep 0 out xfer 0
dev 5 ep 0 out setup buffer @ 0x50100180
endpoint control (0x50100100) <- 0xa0000180
Transfer complete
Sent setup packet
on EP 00 with 8 bytes: OK
hcd_edpt_xfer dev_addr 5, ep_addr 0x80, len 0
hw_endpoint_init dev 5 ep 0 in xfer 0
dev 5 ep 0 in setup buffer @ 0x50100180
endpoint control (0x50100100) <- 0xa0000180
Prepare BufCtrl: [0] = 0x7400 [1] = 0x0000
Buffer complete
buf_status 0x00000001
Single Buffered: ep_ctrl = 0xA0000180
Sync BufCtrl: [0] = 0xe000 [1] = 0x0000
Short packet on buffer 0 with 0 bytes
Completed transfer of 0 bytes on ep 80
Transfer complete
on EP 80 with 0 bytes: OK
HUB Set Feature: PORT_POWER, addr = 5 port = 3
[0:5] Class Request: 23 03 08 00 03 00 00 00
hw_endpoint_init dev 5 ep 0 out xfer 0
dev 5 ep 0 out setup buffer @ 0x50100180
endpoint control (0x50100100) <- 0xa0000180
Transfer complete
Sent setup packet
on EP 00 with 8 bytes: OK
hcd_edpt_xfer dev_addr 5, ep_addr 0x80, len 0
hw_endpoint_init dev 5 ep 0 in xfer 0
dev 5 ep 0 in setup buffer @ 0x50100180
endpoint control (0x50100100) <- 0xa0000180
Prepare BufCtrl: [0] = 0x7400 [1] = 0x0000
*** PANIC ***
Invalid speed
Screenshots
No response
I have checked existing issues, dicussion and documentation
The text was updated successfully, but these errors were encountered: