chegewara / EspTinyUSB

ESP32S2 native USB library. Implemented few common classes, like MIDI, CDC, HID or DFU (update).
MIT License
475 stars 70 forks source link

Library compatibility and future #36

Closed chegewara closed 2 years ago

chegewara commented 3 years ago

I am trying to fix now all breaking changes introduced in upstream tinyusb library and i found there is some issue which i cant fix. As you all know the core repository for all espressif boards is https://github.com/espressif/arduino-esp32. Maintainers of that repository also are making tinyusb library built-in as a core library and with most recent they did i think i am not able to "fix" my library to let it run alongside core-tinyusb. Here is error log i am having now:

hardware/espressif/esp32/tools/xtensa-esp32s2-elf/bin/../lib/gcc/xtensa-esp32s2-elf/8.4.0/../../../../xtensa-esp32s2-elf/bin/ld.exe: arduino_cache_480191\core\core_dffc23aa76a67c47fb55ef1b712972c1.a(esp32-hal-tinyusb.c.o): in function `tud_descriptor_configuration_cb':
hardware\espressif\esp32\cores\esp32/esp32-hal-tinyusb.c:267: multiple definition of `tud_descriptor_configuration_cb'; libraries\esptinyusb\usb_descriptors.cpp.o:C:\Users\darek\Documents\Arduino\libraries\esptinyusb\src/usb_descriptors.cpp:132: first defined here
hardware/espressif/esp32/tools/xtensa-esp32s2-elf/bin/../lib/gcc/xtensa-esp32s2-elf/8.4.0/../../../../xtensa-esp32s2-elf/bin/ld.exe: arduino_cache_480191\core\core_dffc23aa76a67c47fb55ef1b712972c1.a(esp32-hal-tinyusb.c.o): in function `tud_descriptor_device_cb':
hardware\espressif\esp32\cores\esp32/esp32-hal-tinyusb.c:276: multiple definition of `tud_descriptor_device_cb'; libraries\esptinyusb\usb_descriptors.cpp.o:C:\Users\darek\Documents\Arduino\libraries\esptinyusb\src/usb_descriptors.cpp:120: first defined here
hardware/espressif/esp32/tools/xtensa-esp32s2-elf/bin/../lib/gcc/xtensa-esp32s2-elf/8.4.0/../../../../xtensa-esp32s2-elf/bin/ld.exe: arduino_cache_480191\core\core_dffc23aa76a67c47fb55ef1b712972c1.a(esp32-hal-tinyusb.c.o): in function `tud_descriptor_string_cb':
hardware\espressif\esp32\cores\esp32/esp32-hal-tinyusb.c:285: multiple definition of `tud_descriptor_string_cb'; libraries\esptinyusb\usb_descriptors.cpp.o:C:\Users\darek\Documents\Arduino\libraries\esptinyusb\src/usb_descriptors.cpp:148: first defined here

The problem is any of those upstream callbacks cant be overridden. Maybe there is some way to fix it all, but i spent few hours and endup in deep hole and without changes in arduino-esp32 i dont see option to continue developing this library.

chegewara commented 2 years ago

PlatformIO just wont work with 2.0.0-rc1, with or without this library. Its issue with PIO. You can try empty sketch.

You can try this: https://github.com/espressif/arduino-esp32/issues/5436#issuecomment-885487369

oliverparis commented 2 years ago

Brilliant! That worked, thank you.

nikthefix commented 2 years ago

I confirm that all 1.3.4 examples compile (except all-in-one example) with the latest arduino esp32 master branch without the need to modify esp32-hal-tinyusb.c now that these functions have been weakened in the core.

rahmanshaber commented 2 years ago

@chegewara stable ESP32 Arduino 2.0.0 is released, should there be a release from you for this lib?

chegewara commented 2 years ago

And whats wrong with current version?

rahmanshaber commented 2 years ago

i did not tested the latest release of the lib with the esp32's stable release, because right now everything works for me with old release. so asking if all good with latest release so i can move to that.

nikthefix commented 2 years ago

I can confirm that all EspTinyUSB 1.3.4 examples compile successfully with Esp32 2.0.0-rc2 with the exception of the all-in-one sketch.

calcut commented 2 years ago

1.3.4 is also working for me. Although I get a lot of warning/info messages similar to the following.

I'm guessing this is this expected / unavoidable?

In file included from .pio/libdeps/esp32-s2/ESP32TinyUSB/src/esptinyusb.h:7,
                 from .pio/libdeps/esp32-s2/ESP32TinyUSB/src/usb_descriptors.cpp:15:
/Users/calum/.platformio/packages/framework-arduinoespressif32@src-2f93b7a1f9ab38960d06c047f239b2f9/tools/sdk/esp32s2/include/arduino_tinyusb/include/tusb_config.h:104: warning: "CFG_TUD_VENDOR" redefined
 #define CFG_TUD_VENDOR     CONFIG_TINYUSB_VENDOR_ENABLED

In file included from /Users/calum/.platformio/packages/framework-arduinoespressif32@src-2f93b7a1f9ab38960d06c047f239b2f9/tools/sdk/esp32s2/include/arduino_tinyusb/include/tusb_config.h:28,
                 from .pio/libdeps/esp32-s2/ESP32TinyUSB/src/esptinyusb.h:7,
                 from .pio/libdeps/esp32-s2/ESP32TinyUSB/src/usb_descriptors.cpp:15:
/Users/calum/.platformio/packages/framework-arduinoespressif32@src-2f93b7a1f9ab38960d06c047f239b2f9/tools/sdk/esp32s2/include/arduino_tinyusb/tinyusb/src/tusb_option.h:238: note: this is the location of the previous definition
   #define CFG_TUD_VENDOR          0

Side note, not an issue with this lib, but when using PlatformIO, I needed to use platform = https://github.com/platformio/platform-espressif32.git#feature/arduino-upstream However, the automatic (button press free) upload still doesn't work for me in PlatformIO, see https://github.com/platformio/platform-espressif32/issues/591

nikthefix commented 2 years ago

@calcut Yes I get similar warnings too (in arduino ide) but if my memory serves correctly they're associated with compile-time redefines and to be expected at this time.