sekigon-gonnoc / Pico-PIO-USB

USB host/device implementation using PIO of raspberry pi pico (RP2040).
MIT License
1.36k stars 145 forks source link

🪲[BUG] host code (or at least sample) should assert bus reset #143

Open shuffle2 opened 1 month ago

shuffle2 commented 1 month ago

Describe the bug you encountered:

I'm new user of pico-pio-usb, so I started with usb host example code. I was confused because I wasn't seeing the device respond to host packets at all. Eventually I realized that bus reset was required.

What did you expect to happen instead?

Example code to work.

What actually happened in your case?

host example code appeared to not work for unknown reason.

Additional information

Following code should be put somewhere.

pio_usb_host_port_reset_start(0);
// 10ms by spec. Note e.g. Windows uses ~15ms
sleep_ms(10);
pio_usb_host_port_reset_end(0);
sweetlilmre commented 1 month ago

@shuffle2 I've followed your comments from #122 I'm going to give this a try and see if it helps in my use-case. Do you have any example you can share where you have host support working and can you give some detail on what device you have connected and your configuration? I'll be basing my tests on the host_hid_to_device_cdc project, now that the others have been deprecated in main.

sweetlilmre commented 1 month ago

I finally had time to have a look. Using the host_hid_to_device_cdc project, my device (PS3 controller) enumerates.

This is without using your bus reset code example (the device also works when adding the bus reset code).

With the deprecation of the Pico-PIO-USB host stack (528616d) I'm assuming my issue was related to that and using TinyUSB as the host stack sorts that out. I do have some weird issues with quickly disconnecting and reconnecting the device, seem to have to wait around 3-5s between reconnects for it to be successfully recognised again (I think I saw an issue on this somewhere).

HTH

-(e)

sweetlilmre commented 1 month ago

@shuffle2 further testing:

  multicore_launch_core1(core1_main);

  pio_usb_host_port_reset_start(0);
  // 10ms by spec. Note e.g. Windows uses ~15ms
  sleep_ms(10);
  pio_usb_host_port_reset_end(0);

Adding your reset example as above seems to make disconnect / reconnect more reliable, though not totally so.