tinyusb icon indicating copy to clipboard operation
tinyusb copied to clipboard

tud_umount_cb not called on Raspberry Pi Pico W

Open Slion opened this issue 1 year ago • 2 comments

Operating System

Others

Board

Raspberry Pi Pico WH

Firmware

Modified dev_hid_composite example from Pico SDK examples. https://github.com/raspberrypi/pico-examples/tree/master/usb/device/dev_hid_composite

What happened ?

tud_umount_cb is never called after calling tud_disconnect though if you call tud_connect then tud_mount_cb is called as expected.

How to reproduce ?

Here is a modified version of Pico SDK dev_hid_composite example. You can disconnect and connect by pushing the board's button. I've added logs to mount and unmount callback. main.zip

Debug Log as txt file (LOG/CFG_TUSB_DEBUG=2)

no-unmount.txt

Screenshots

No response

I have checked existing issues, dicussion and documentation

  • [X] I confirm I have checked existing issues, dicussion and documentation.

I'm not the only one seeing this: https://stackoverflow.com/questions/78655855/rpi-pico-not-receiving-tinyusb-unmount-callbacks/78711334

Slion avatar Jul 05 '24 12:07 Slion

Updated the first post with logs and example.

Slion avatar Jul 06 '24 10:07 Slion

I could bypass this problem using tud_ready function instead of waiting tud_umount_cb getting called. It can be bypassed like: (temporary solution)

int main(void) {
   tud_init(0);
   // ...
   uint8_t last = 0;
   while (1) {
      tud_task();
      uint8_t now = tud_ready();
      if (now != last) {
          if (!(last = now)) {
              // unmounted.
          } else {
              // mounted.
          }
      }
   }
}

jay94ks avatar Dec 23 '24 14:12 jay94ks