← index #10533Issue #18990
Off-topic · high · value 0.864
QUERY · ISSUE

Add support for dual usb serial on the Pico.

openby gsrunionopened 2023-01-21updated 2023-11-21
enhancement

The pico has the hardware to support for enumerating as multiple usb serial ports on the host computer. This is proven by the fact that CircuitPython exposes the ability to do so.

CANDIDATE · ISSUE

MicroPython USB-CDC Regression on RP2350 (Pico 2W)

closedby LofiFrenopened 2026-03-24updated 2026-03-25
bug

Port, board and/or hardware

RP2350 Pico 2W

MicroPython version

MicroPython versions v1.26.0 through v1.27.0 (and likely v1.28.0+) fail to enumerate USB-CDC on the RP2350 (Raspberry Pi Pico 2W). The device does not appear as a serial port on the host. The last working version is v1.25.0-preview (commit f187c77da).

Reproduction

  1. Build MicroPython v1.27.0 for BOARD=RPI_PICO2_W
  2. Flash the .uf2 to a Raspberry Pi Pico 2W
  3. Connect via USB -- no serial port appears (ls /dev/tty.usbmodem* on macOS returns nothing)
  4. Apply the two-line fix above, rebuild, reflash
  5. USB serial port appears and works normally

Expected behaviour

you should be able to connect usb to mac or windows (mac in this case)

Observed behaviour

Plug in usb and nothing happens

Additional Information

Root Cause

In the transition from v1.25.0 to v1.26.0, the --wrap=dcd_event_handler linker flag and its corresponding __wrap_dcd_event_handler() function were removed from ports/rp2/CMakeLists.txt and shared/tinyusb/mp_usbd.c.

The removal was intentional -- TinyUSB added a tud_event_hook_cb() callback (called from usbd.c:383) meant to replace the linker wrap. MicroPython v1.26.0+ implements this hook via MICROPY_WRAP_TUD_EVENT_HOOK_CB in shared/tinyusb/mp_usbd.c.

However, on the RP2350, the TinyUSB hook alone is not sufficient for USB device enumeration to succeed. The linker wrap is still needed. The RP2040 may not be affected (untested).

The Fix

Two changes restore USB functionality on RP2350 while keeping all v1.27.0 features (including BLE security):

1. ports/rp2/CMakeLists.txt -- Re-add linker wrap

 target_link_options(${MICROPY_TARGET} PRIVATE
     -Wl,--defsym=__micropy_c_heap_size__=${MICROPY_C_HEAP_SIZE}
+    -Wl,--wrap=dcd_event_handler
     -Wl,--wrap=runtime_init_clocks
 )

2. shared/tinyusb/mp_usbd.c -- Re-add wrapper function

Add before the tud_event_hook_cb function:

extern void __real_dcd_event_handler(dcd_event_t const *event, bool in_isr);

TU_ATTR_FAST_FUNC void __wrap_dcd_event_handler(dcd_event_t const *event, bool in_isr) {
    __real_dcd_event_handler(event, in_isr);
    mp_usbd_schedule_task();
    mp_hal_wake_main_task_from_isr();
}

Both the hook (tud_event_hook_cb) and the wrap (__wrap_dcd_event_handler) can coexist safely -- v1.25.0-preview had both. The wrap ensures the USB task is scheduled from the ISR context, which appears to be required on RP2350 for enumeration to complete.

Affected Versions

Version USB on RP2350 BLE Security
v1.25.0-preview (f187c77da) Works No (config params unknown)
v1.26.0 Broken Yes
v1.27.0 Broken Yes
v1.27.0 + patch (above) Works Yes
v1.28.0-preview Broken (untested, assumed) Yes

Discovered

2026-03-24 by LofiFren (PicoCalc project)
https://github.com/LofiFren/PicoCalc

Code of Conduct

Yes, I agree

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied