c++usbunmountrp2040

RPi Pico not receiving TinyUSB unmount callbacks


I created simple keyboard on the Pico using the C SDK with TinyUSB. TinyUSB requires some callback functions to be defined, two of which being tud_mount_cb and tud_umount_cb. The first one works without issues, after plugging the USB I see the expected UART logs. What I found is that tud_umount_cb is not called when I unplug the Pico from the PC:

// Invoked when device is unmounted
void tud_umount_cb(void)
{
    global_callback.mounted = false;
}

Additionally I tried calling tud_mounted as well as tud_connected which were both unable to detect when the Pico USB disconnects.

Tried normal and callback TinyUSB functions. Crosschecked on 3 different Picos, 1 official design and 2 USB-C variants. Whatever I try it seems like the Pico is unable to detect USB disconnect/unmount.

Has anyone encountered similar problem?


Solution

  • For everyone finding this post in the future: this is known issue on Pico, see https://github.com/hathach/tinyusb/issues/2478