Unable to compile pico sketch with -DUSE_TINYUSB build flags. Getting conflicting declaration for Serial

I have a simple example sketch that uses the built in Adafruit_TinyUSB library which compiles fine with Arduino IDE but I cant get it to work with PlatformIO.

I am using a Pi Pico. I get conflicting declaration compile errors when I use build_flags = -DUSE_TINYUSB

In file included from .pio\libdeps\pico\Adafruit TinyUSB Library\src\arduino\Adafruit_USBD_CDC.cpp:29:
C:\Users\ali.platformio\packages\framework-arduino-mbed@3.5.4\cores\arduino/Arduino.h:105:17: error: conflicting declaration ‘Adafruit_USBD_CDC UART_USB
105 | #define Serial UART_USB
| ^~~~~~~~~~
.pio\libdeps\pico\Adafruit TinyUSB Library\src\arduino\Adafruit_USBD_CDC.h:97:26: note: in expansion of macro ‘Serial’
97 | extern Adafruit_USBD_CDC Serial;
| ^~~~~~
In file included from C:\Users\ali.platformio\packages\framework-arduino-mbed@3.5.4\cores\arduino/Arduino.h:102,
from .pio\libdeps\pico\Adafruit TinyUSB Library\src\arduino\Adafruit_USBD_CDC.cpp:29:
C:\Users\ali.platformio\packages\framework-arduino-mbed@3.5.4\cores\arduino/Serial.h:88:22: note: previous declaration as ‘arduino::UART UART_USB
88 | extern arduino::UART UART_USB;

If I remove the define USE_TINYUSB build flag, it compiles but it does not work because it uses Pico SDK USB stack.

I have tried also adding dependency to the GitHub - adafruit/Adafruit_TinyUSB_Arduino: Arduino library for TinyUSB library but no change as its already built in.

My platformio.ini has:

platform = raspberrypi
board = pico
framework = arduino
lib_archive = no
build_flags = -DUSE_TINYUSB
upload_protocol = picotool

Any ideas on how I can get overcome this compile error in platformIO?

But is that with GitHub - earlephilhower/arduino-pico: Raspberry Pi Pico Arduino core, for all RP2040 boards as your core or GitHub - arduino/ArduinoCore-mbed?

Thanks for the tip! I switched platform to yours and core to earlephilhower and it compiles and works!

platform = GitHub - maxgerhardt/platform-raspberrypi: Raspberry Pi: development platform for PlatformIO
board_build.core = earlephilhower

And BTW, I tried GitHub - earlephilhower/arduino-pico: Raspberry Pi Pico Arduino core, for all RP2040 boards and that one would provide other errors but your version worked.