Skip to content

macro redefinitions for ESP32S2 and ESP32S3 #484

Open
@dhebbeker

Description

@dhebbeker

Operating System

Linux

Arduino IDE version

PIO PlatformIO Core, version 6.1.16

Board

esp32-s3-devkitc-1

ArduinoCore version

framework-arduinoespressif32 @ 3.20017.0 (2.0.17)

TinyUSB Library version

3.4.2

Sketch as ATTACHED TXT

main.cpp.txt

Compiled Log as ATTACHED TXT

compile.txt

What happened ?

Compiler warns about redefinitions of preprocessor macros. The definitions are conflicting. For example:

Compiling .pio/build/esp32-s3-devkitc-1/lib663/Adafruit TinyUSB Library/arduino/Adafruit_TinyUSB_API.cpp.o
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)

See compiler log for all conflicts.


I analysed the code and noted:

  1. includes
  2. #include "arduino/ports/esp32/tusb_config_esp32.h"

But

  1. includes
  2. #include "tusb_config.h"
    includes
  3. #include "../../arduino_tinyusb/include/tusb_config.h"
    on the following conditions:
    #elif defined(ARDUINO_ARCH_ESP32)
    // Note: when compiling core Arduino IDEs will include tusb_config.h in the BSP
    // sdk/include/arduino_tinyusb/include. While compiling .c file in this library this
    // file will be used instead. For consistency: include the one in BSP here as well
    #include "sdkconfig.h"
    #if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
      #include "../../arduino_tinyusb/include/tusb_config.h"
    #else
      #include "arduino/ports/esp32/tusb_config_esp32.h"
    #endif

In summary:

If both would include the same header, there wouldn't be the conflicts.

How to reproduce ?

Using PlatformIO, build the above "sketch", or use this MVP: https://github.com/Task-Tracker-Systems/Task-Tracker-Device/tree/ec83e905c7b1b328fd92ee1322906067698a20e0

Debug Log

No response

Screenshots

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions