New TinyUSB doesn't allow compile?

I just upgraded to the new TinyUSB version that was released, from 3.1.4 to 3.4.0, and I’m getting all of these messages when I try to compile:

I’m totally lost on what this could be. I even switched back to 3.1.4, and PlatformIO reinstalled that version in my project, and yet I’m getting the same message again! Any ideas?

In file included from .pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/Adafruit_TinyUSB.h:30,
from .pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/arduino/Adafruit_TinyUSB_API.cpp:29:
.pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/arduino/ports/esp32/tusb_config_esp32.h:92: warning: “CFG_TUH_ENABLED” redefined
#define CFG_TUH_ENABLED 1

In file included from .pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/arduino/Adafruit_TinyUSB_API.cpp:25:
.pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/tusb_option.h:318: note: this is the location of the previous definition
#define CFG_TUH_ENABLED (TUH_RHPORT_MODE & OPT_MODE_HOST)

In file included from .pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/Adafruit_TinyUSB.h:30,
from .pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/arduino/Adafruit_TinyUSB_API.cpp:29:
.pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/arduino/ports/esp32/tusb_config_esp32.h:93: warning: “CFG_TUH_MAX_SPEED” redefined
#define CFG_TUH_MAX_SPEED OPT_MODE_FULL_SPEED

In file included from .pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/arduino/Adafruit_TinyUSB_API.cpp:25:
.pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/tusb_option.h:323: note: this is the location of the previous definition
#define CFG_TUH_MAX_SPEED (TUH_RHPORT_MODE & OPT_MODE_SPEED_MASK)

In file included from .pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/Adafruit_TinyUSB.h:30,
from .pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/arduino/Adafruit_TinyUSB_API.cpp:29:
.pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/arduino/ports/esp32/tusb_config_esp32.h:94: warning: “CFG_TUH_MAX3421” redefined
#define CFG_TUH_MAX3421 1

In file included from .pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/arduino/Adafruit_TinyUSB_API.cpp:25:
.pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/tusb_option.h:267: note: this is the location of the previous definition
#define CFG_TUH_MAX3421 0

In file included from .pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/Adafruit_TinyUSB.h:30,
from .pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/arduino/Adafruit_TinyUSB_API.cpp:29:
.pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/arduino/ports/esp32/tusb_config_esp32.h:104: warning: “CFG_TUH_HUB” redefined
#define CFG_TUH_HUB 1

In file included from .pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/arduino/Adafruit_TinyUSB_API.cpp:25:
.pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/tusb_option.h:512: note: this is the location of the previous definition
#define CFG_TUH_HUB 0

In file included from .pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/Adafruit_TinyUSB.h:30,
from .pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/arduino/Adafruit_TinyUSB_API.cpp:29:
.pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/arduino/ports/esp32/tusb_config_esp32.h:113: warning: “CFG_TUH_MSC” redefined
#define CFG_TUH_MSC 1

In file included from .pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/arduino/Adafruit_TinyUSB_API.cpp:25:
.pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/tusb_option.h:569: note: this is the location of the previous definition
#define CFG_TUH_MSC 0

In file included from .pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/Adafruit_TinyUSB.h:30,
from .pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/arduino/Adafruit_TinyUSB_API.cpp:29:
.pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/arduino/ports/esp32/tusb_config_esp32.h:117: warning: “CFG_TUH_HID” redefined
#define CFG_TUH_HID (3 * CFG_TUH_DEVICE_MAX)

In file included from .pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/arduino/Adafruit_TinyUSB_API.cpp:25:
.pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/tusb_option.h:561: note: this is the location of the previous definition
#define CFG_TUH_HID 0

In file included from .pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/Adafruit_TinyUSB.h:30,
from .pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/arduino/Adafruit_TinyUSB_API.cpp:29:
.pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/arduino/ports/esp32/tusb_config_esp32.h:121: warning: “CFG_TUH_CDC” redefined
#define CFG_TUH_CDC 1

In file included from .pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/arduino/Adafruit_TinyUSB_API.cpp:25:
.pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/tusb_option.h:516: note: this is the location of the previous definition
#define CFG_TUH_CDC 0

In file included from .pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/Adafruit_TinyUSB.h:30,
from .pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/arduino/Adafruit_TinyUSB_API.cpp:29:
.pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/arduino/ports/esp32/tusb_config_esp32.h:122: warning: “CFG_TUH_CDC_FTDI” redefined
#define CFG_TUH_CDC_FTDI 1

In file included from .pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/arduino/Adafruit_TinyUSB_API.cpp:25:
.pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/tusb_option.h:521: note: this is the location of the previous definition
#define CFG_TUH_CDC_FTDI 0

In file included from .pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/Adafruit_TinyUSB.h:30,
from .pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/arduino/Adafruit_TinyUSB_API.cpp:29:
.pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/arduino/ports/esp32/tusb_config_esp32.h:123: warning: “CFG_TUH_CDC_CP210X” redefined
#define CFG_TUH_CDC_CP210X 1

In file included from .pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/arduino/Adafruit_TinyUSB_API.cpp:25:
.pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/tusb_option.h:534: note: this is the location of the previous definition
#define CFG_TUH_CDC_CP210X 0

In file included from .pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/Adafruit_TinyUSB.h:30,
from .pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/arduino/Adafruit_TinyUSB_API.cpp:29:
.pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/arduino/ports/esp32/tusb_config_esp32.h:124: warning: “CFG_TUH_CDC_CH34X” redefined
#define CFG_TUH_CDC_CH34X 1

In file included from .pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/arduino/Adafruit_TinyUSB_API.cpp:25:
.pio/libdeps/esp32-s3-devkitc-1/Adafruit TinyUSB Library/src/tusb_option.h:545: note: this is the location of the previous definition
#define CFG_TUH_CDC_CH34X 0

Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/arduino/Adafruit_USBD_Interface.cpp.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/arduino/Adafruit_USBH_Host.cpp.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/arduino/cdc/Adafruit_USBH_CDC.cpp.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/arduino/hid/Adafruit_USBD_HID.cpp.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/arduino/midi/Adafruit_USBD_MIDI.cpp.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/arduino/msc/Adafruit_USBD_MSC.cpp.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/arduino/msc/Adafruit_USBH_MSC.cpp.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/arduino/ports/ch32/Adafruit_TinyUSB_ch32.cpp.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/arduino/ports/esp32/Adafruit_TinyUSB_esp32.cpp.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/arduino/ports/nrf/Adafruit_TinyUSB_nrf.cpp.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/arduino/ports/rp2040/Adafruit_TinyUSB_rp2040.cpp.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/arduino/ports/samd/Adafruit_TinyUSB_samd.cpp.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/arduino/video/Adafruit_USBD_Video.cpp.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/arduino/webusb/Adafruit_USBD_WebUSB.cpp.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/class/audio/audio_device.c.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/class/bth/bth_device.c.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/class/cdc/cdc_device.c.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/class/cdc/cdc_host.c.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/class/dfu/dfu_device.c.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/class/dfu/dfu_rt_device.c.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/class/hid/hid_device.c.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/class/hid/hid_host.c.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/class/midi/midi_device.c.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/class/msc/msc_device.c.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/class/msc/msc_host.c.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/class/net/ecm_rndis_device.c.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/class/net/ncm_device.c.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/class/usbtmc/usbtmc_device.c.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/class/vendor/vendor_device.c.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/class/video/video_device.c.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/common/tusb_fifo.c.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/device/usbd.c.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/device/usbd_control.c.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/host/hub.c.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/host/usbh.c.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/portable/analog/max3421/hcd_max3421.c.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/portable/microchip/samd/dcd_samd.c.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/portable/nordic/nrf5x/dcd_nrf5x.c.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/portable/raspberrypi/pio_usb/dcd_pio_usb.c.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/portable/raspberrypi/pio_usb/hcd_pio_usb.c.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/portable/raspberrypi/rp2040/dcd_rp2040.c.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/portable/raspberrypi/rp2040/hcd_rp2040.c.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/portable/raspberrypi/rp2040/rp2040_usb.c.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/portable/st/stm32_fsdev/dcd_stm32_fsdev.c.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/portable/synopsys/dwc2/dcd_dwc2.c.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/portable/wch/dcd_ch32_usbfs.c.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/portable/wch/dcd_ch32_usbhs.c.o
Compiling .pio/build/esp32-s3-devkitc-1/lib4ad/Adafruit TinyUSB Library/tusb.c.o
Compiling .pio/build/esp32-s3-devkitc-1/lib041/MIDI Library/MIDI.cpp.o
Compiling .pio/build/esp32-s3-devkitc-1/src/main.cpp.o
Building .pio/build/esp32-s3-devkitc-1/bootloader.bin
Generating partitions .pio/build/esp32-s3-devkitc-1/partitions.bin
esptool.py v4.5.1
Creating esp32s3 image…
Merged 1 ELF section
Successfully created esp32s3 image.
Compiling .pio/build/esp32-s3-devkitc-1/FrameworkArduino/Esp.cpp.o
Compiling .pio/build/esp32-s3-devkitc-1/FrameworkArduino/FirmwareMSC.cpp.o
Compiling .pio/build/esp32-s3-devkitc-1/FrameworkArduino/FunctionalInterrupt.cpp.o
Compiling .pio/build/esp32-s3-devkitc-1/FrameworkArduino/HWCDC.cpp.o
Compiling .pio/build/esp32-s3-devkitc-1/FrameworkArduino/HardwareSerial.cpp.o
Compiling .pio/build/esp32-s3-devkitc-1/FrameworkArduino/IPAddress.cpp.o
Compiling .pio/build/esp32-s3-devkitc-1/FrameworkArduino/IPv6Address.cpp.o
Compiling .pio/build/esp32-s3-devkitc-1/FrameworkArduino/MD5Builder.cpp.o
Compiling .pio/build/esp32-s3-devkitc-1/FrameworkArduino/Print.cpp.o

1 Like

For what it’s worth, I ran into the same error of a bunch of redefinitions this afternoon, and spent hours on it. I also couldn’t link due to double function definitions (not sure if you had the same and your log cut off, or if it built for you but had warnings). Here’s a sample of the first two linker errors:

Compiling .pio\build\sim_board\FrameworkArduino\wiring_shift.c.o
Archiving .pio\build\sim_board\libFrameworkArduino.a
Indexing .pio\build\sim_board\libFrameworkArduino.a
Linking .pio\build\sim_board\firmware.elf
c:/users/jeff/.platformio/packages/toolchain-xtensa-esp32s2/bin/../lib/gcc/xtensa-esp32s2-elf/12.2.0/../../../../xtensa-esp32s2-elf/bin/ld.exe: C:/Users/Jeff/.platformio/packages/framework-arduinoespressif32-libs/esp32s2/lib\libarduino_tinyusb.a(tusb.c.obj): in function `tusb_inited':
/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/components/arduino_tinyusb/tinyusb/src/tusb.c:60: multiple definition of `tusb_inited'; .pio/build/sim_board/lib49d/libAdafruit TinyUSB Library.a(tusb.c.o):C:\Users\Jeff\Nextcloud\Git\sim_project/.pio/libdeps/sim_project/Adafruit TinyUSB Library/src/tusb.c:102: first defined here
c:/users/jeff/.platformio/packages/toolchain-xtensa-esp32s2/bin/../lib/gcc/xtensa-esp32s2-elf/12.2.0/../../../../xtensa-esp32s2-elf/bin/ld.exe: C:/Users/Jeff/.platformio/packages/framework-arduinoespressif32-libs/esp32s2/lib\libarduino_tinyusb.a(tusb.c.obj): in function `tu_desc_find':
/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/components/arduino_tinyusb/tinyusb/src/tusb.c:78: multiple definition of `tu_desc_find'; .pio/build/sim_board/lib49d/libAdafruit TinyUSB Library.a(tusb.c.o):C:\Users\Jeff\Nextcloud\Git\sim_project/.pio/libdeps/sim_project/Adafruit TinyUSB Library/src/tusb.c:137: first defined here

It did work for me when I explicitly set the Adafruit TinyUSB library version to 3.3.1, but I don’t know why. I wish I’d tried that sooner.

Yes! That’s exactly what is happening to me.

So TinyUSB is already built into the Arduino-ESP32 core in a precompiled form? Then how can you just decide to update it or throw a different TinyUSB version in, on-top? You would need to recompile the core including that prebuilt lib, no? https://github.com/espressif/esp32-arduino-lib-builder

That makes sense, but what doesn’t make sense is that the Adafruit TinyUSB library v3.3.1 (and presumably others) has been working with normal deployment for quite a while. I have this in my platformio.ini file:

[env:develop]
platform = espressif32
board = lolin_s2_mini
framework = arduino
lib_deps =
	adafruit/Adafruit TinyUSB Library@3.3.1

…and this in the main header for my app:

#include <Arduino.h>
#include <SPI.h>
#include <Adafruit_TinyUSB.h>

…and this in the source file that initializes and uses the USB device:

Adafruit_USBD_HID usb_hid(usb_descriptor, sizeof(usb_descriptor), HID_ITF_PROTOCOL_NONE, 2, true);

// ...

void usbdev_init()
{
    // configure USB device
    TinyUSBDevice.setID(CUSTOM_USB_VID, CUSTOM_USB_PID);
    TinyUSBDevice.setDeviceVersion(CUSTOM_USB_DEVICE_VERSION);
    TinyUSBDevice.setManufacturerDescriptor(CUSTOM_USB_MANUFACTURER_STRING);
    TinyUSBDevice.setProductDescriptor(CUSTOM_USB_PRODUCT_STRING);

    // initialize USB HID via TinyUSB
    usb_hid.enableOutEndpoint(true);
    usb_hid.setPollInterval(2);
    usb_hid.setReportDescriptor(usb_descriptor, sizeof(usb_descriptor));
    usb_hid.setReportCallback(hid_get_report_callback, hid_set_report_callback);
    usb_hid.begin();
}

If we drop Adafruit’s library, do we lose the whole layer of functionality that they’ve built, or is it accessible some other way using the TinyUSB library that’s part of the core?

It looks like Adafruit’s v3.3.1 (or something pre-v3.4.0) is able to peacefully coexist without duplicate definitions. I’m all for whatever lets this continue going forward, including a change to Adafruit’s library code–since it seems like something on their end is what broke the v3.4.0 integration in the first place. Maybe.

Have you been able to figure it out? I still can’t - I confirmed that it is indeed adafruit tinyusb 3.4 and above that breaks it.

If I don’t need to install the adafruit library because it’s redundant, and I can create usb midi devices, this is great too! But this isn’t clear how to do this and how to use the build in MIDI object instead of Adafruit tinyusb

I haven’t spent any effort on making 3.4.x+ work since rolling back to the exact 3.3.1 version in platformio.ini allowed me to keep doing what I needed to do. It’s obviously not an ideal solution, but would the same work for you?