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

PIO USB v0.6.0 no longer enumerates devices #122

Closed
Kokovec opened this issue Jun 17, 2024 · 16 comments · Fixed by #132
Closed

PIO USB v0.6.0 no longer enumerates devices #122

Kokovec opened this issue Jun 17, 2024 · 16 comments · Fixed by #132
Labels
bug Something isn't working

Comments

@Kokovec
Copy link

Kokovec commented Jun 17, 2024

After upgrading the PIO USB library to version 0.6.0 the callback for a HID device mounting (void tuh_hid_mount_cb) no longer works.

@Kokovec Kokovec added the bug Something isn't working label Jun 17, 2024
@Kokovec
Copy link
Author

Kokovec commented Jun 17, 2024

I should not that this is happening while using the Adafruit Tiny USB library.

@sekigon-gonnoc
Copy link
Owner

set the optimize option to something other than -Os

@Kokovec
Copy link
Author

Kokovec commented Jun 19, 2024

This works but breaks other libraries (like NeoPixel).

@edwardsharp
Copy link

set the optimize option to something other than -Os

👋 can you explain how to do that?

fwiw: i stumbled upon this with similar experience, 0.6.0 doesn't run the callback, 0.5.3 seems to still work as i expect.

@Kokovec
Copy link
Author

Kokovec commented Jul 2, 2024

set the optimize option to something other than -Os

👋 can you explain how to do that?

fwiw: i stumbled upon this with similar experience, 0.6.0 doesn't run the callback, 0.5.3 seems to still work as i expect.

In the Arduino IDE it's under "Tools->Optimize"

@lyusupov
Copy link
Contributor

lyusupov commented Jul 18, 2024

set the optimize option to something other than -Os

@sekigon-gonnoc (with CC: to @hathach ) , is it possible to apply a local area "no-optimize" effect by using #pragma GCC optimize feature https://gcc.gnu.org/onlinedocs/gcc/Function-Specific-Option-Pragmas.html with the PIO USB library and/or Adafruit Tiny USB library while keeping the rest of source codes (a sketch, Arduino Core, other libraries) compiled with -Os flag ?

@sweetlilmre
Copy link

sweetlilmre commented Jul 27, 2024

Compiling and running capture_hid_report on v0.6.0 under VSCode in:

  • debug -Og
  • release -O3

results in the same behaviour: no devices enumerated. v0.5.3 works as expected. Am I missing something?

(I am not familiar with cmake so I may well be). Output from compile_commands.json for a debug build:

C:\\PROGRA~1\\RASPBE~1\\PICOSD~1.1\\GCC-AR~1\\bin\\AR19DD~1.EXE -DPICO_BOARD=\\\"pico\\\" -DPICO_BUILD=1 -DPICO_NO_HARDWARE=0 -DPICO_ON_DEVICE=1 -I\"C:/Program Files/Raspberry Pi/Pico SDK v1.5.1/pico-sdk/src/rp2_common/boot_stage2/asminclude\" -I\"C:/Program Files/Raspberry Pi/Pico SDK v1.5.1/pico-sdk/src/rp2040/hardware_regs/include\" -I\"C:/Program Files/Raspberry Pi/Pico SDK v1.5.1/pico-sdk/src/rp2_common/hardware_base/include\" -I\"C:/Program Files/Raspberry Pi/Pico SDK v1.5.1/pico-sdk/src/common/pico_base/include\" -IC:/source/Pico-PIO-USB/examples/build/generated/pico_base -I\"C:/Program Files/Raspberry Pi/Pico SDK v1.5.1/pico-sdk/src/boards/include\" -I\"C:/Program Files/Raspberry Pi/Pico SDK v1.5.1/pico-sdk/src/rp2_common/pico_platform/include\" -I\"C:/Program Files/Raspberry Pi/Pico SDK v1.5.1/pico-sdk/src/rp2_common/boot_stage2/include\" -mcpu=cortex-m0plus -mthumb -Og -g -o pico-sdk\\src\\rp2_common\\boot_stage2\\CMakeFiles\\bs2_default.dir\\compile_time_choice.S.obj -c \"C:\\Program Files\\Raspberry Pi\\Pico SDK v1.5.1\\pico-sdk\\src\\rp2_common\\boot_stage2\\compile_time_choice.S\"

@sweetlilmre
Copy link

sweetlilmre commented Jul 28, 2024

More info.  I tried a fully unoptimized build -O0 and a debug build -Og

I seem to get as far as the device being recognised as connected, but all endpoints are NULL:

        if (!device->connected) {
          continue;
        }

        // Print received packet to EPs
        for (int ep_idx = 0; ep_idx < PIO_USB_DEV_EP_CNT; ep_idx++) {
          endpoint_t *ep = pio_usb_get_endpoint(device, ep_idx);

          if (ep == NULL) {
            break;
          }

i.e. ep is always NULL. This would suggest something else apart from a -Os issue is happening.

The device connected to the pico is a PS3 dual shock 3 controller. Standard pin connections (GP0 and GP1), as before the device enumerates (at least it has valid endpoints) with v0.5.3

@kripton
Copy link

kripton commented Sep 4, 2024

I am experiencing something similar. I tried running the capture_hid_report on an "Adafruit RP2040 Feather with USB host" (so I had to adapt the pins to 16 and 17 and also add code to drive GPIO 18 high since that enables power on the DFP. With commit 0f747aa the example works and the connected device (some USB RAW HID device that can be bought online) enumerates fine:

Root 0 connected
Device 0 Connected
control in[complete]
Enumerating 0b00:1000, class:0, address:1
...

However, with latest main (fe9133f) and exactly the same changes done by me, the enumeration fails:

Root 0 connected
Device 0 Connected
control in[error]
Enumeration failed(-1)

@sweetlilmre
Copy link

Same results here:
v0.5.3

hello!
Root 0 connected
Device 0 Connected
control in[complete]
Enumerating 054c:0268, class:0, address:1
control out[complete]
control in[error]
Failed to get string descriptor (Manufacture)
control in[error]
Failed to get string descriptor (Product)
control in[complete]
control in[complete]
control out[complete]
inum:0, altsetting:0, numep:2, iclass:3, isubclass:0, iprotcol:0, iface:0
        bcdHID:1.11, country:0, desc num:1, desc_type:34, desc_size:148
control out[error]
control in[complete]
                Report descriptor:05 01 09 04 a1 01 a1 02 85 01 75 08 95 01 15 00 26 ff 00 81 03 75 01 95 13 15 00 25 01 35 00 45 01 05 09 19 01 29 13 81 02 75 01 95 0d 06 00 ff 81 03 15 00 26 ff 00 05 01 09 01 a1 00 75 08 95 04 35 00 46 ff 00 09 30 09 31 09 32 09 35 81 02 c0 05 01 75 08 95 27 09 01 81 02 75 08 95 30 09 01 91 02 75 08 95 30 09 01 b1 02 c0 a1 02 85 02 75 08 95 30 09 01 b1 02 c0 a1 02 85 ee 75 08 95 30 09 01 b1 02 c0 a1 02 85 ef 75 08 95 30 09 01 b1 02 c0 c0 
                        epaddr:0x02, attr:3, size:64, interval:1
                        epaddr:0x81, attr:3, size:64, interval:1

v0.6.1 / master

hello!
Root 0 connected
Device 0 Connected
control in[error]
Enumeration failed(-1)
Root 0 disconnected
Disconnect
Disconnect device 0

@sekigon-gonnoc please can you reopen this issue?

@shuffle2
Copy link

shuffle2 commented Sep 18, 2024

I guess I'm having the same issue, I'm first-time user of pico-pio-usb. After setting up the library and trying to use it as usb host on gpio pins 2,3 on pico_w with pico-sdk 2.0 and pico-pio-usb 6.1, it doesn't work as described here. I guess we need some deeper debugging.

Changing optimization flags to gcc (gcc 13.2.1 arm-none-eabi) does not help.

@bitcores
Copy link

I have just started playing with this library, so I can't speak for how it was in v0.5.3, but I am experiencing much the same as the recent commenters.
One thing I have noticed, though, is that if I wait a while after resetting the Pico, or after unplugging the USB device, (about 15-30 seconds) and then plug the USB device in, it tends to enumerate it, but if I plug it in immediately, or unplug and plug quickly, it tends to fail to enumerate.

                Report descriptor:06 00 ff 09 01 a1 01 85 10 75 08 95 06 15 00 26 ff 00 09 01 81 00 09 01 91 00 c0 06 00 ff 09 02 a1 01 85 11 75 08 95 13 15 00 26 ff 00 09 02 81 00 09 02 91 00 c0 06 00 ff 09 04 a1 01 85 20 75 08 95 0e 15 00 26 ff 00 09 41 81 00 09 41 91 00 85 21 95 1f 15 00 26 ff 00 09 42 81 00 09 42 91 00 c0
                        epaddr:0x83, attr:3, size:32, interval:2
Root 0 disconnected
Disconnect
Disconnect device 1
Root 0 connected
Device 0 Connected
control in[error]
Enumeration failed(-1)
Root 0 disconnected
Disconnect
Disconnect device 0
Root 0 disconnected
Root 0 connected
Device 0 Connected
control in[error]
Enumeration failed(-1)
Root 0 disconnected
Disconnect
Disconnect device 0
Root 0 disconnected
Root 0 connected
Device 0 Connected
control in[complete]
Enumerating 046d:c52b, class:0, address:1

@shuffle2
Copy link

@bitcores does adding bus reset as shown in #143 help?

@bitcores
Copy link

@shuffle2 I tried adding it in a few different places but it didn't seem to help at all.

@sapfeer0k
Copy link

I have the same problem . Using any 0.6.* version USB enumeration fails.
I am on Windows + VScode Pico extension

@bitcores
Copy link

bitcores commented Nov 1, 2024

This particular example (capture hid report) has been deprecated. It's not really supposed to be functional anymore.
I suggest using the host_hid_to_device_cdc example for testing and then as a scaffold for whatever you are building.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants