feat(esp32) resolve conflict with latest v3.1.3. better enforce tusb_config_esp32.h within tusb_option.h

also change CFG_TUD_MIDI_RX/TX_BUFSIZE for rp2040 to 64
This commit is contained in:
hathach 2025-03-06 21:18:54 +07:00
parent 41bde22a7c
commit 605d681c81
No known key found for this signature in database
GPG key ID: 26FAB84F615C3C52
26 changed files with 69 additions and 131 deletions

View file

@ -38,7 +38,9 @@ Following core has TinyUSB as either the primary usb stack or selectable via men
- [adafruit/Adafruit_nRF52_Arduino](https://github.com/adafruit/Adafruit_nRF52_Arduino)
- [adafruit/ArduinoCore-samd](https://github.com/adafruit/ArduinoCore-samd)
- [earlephilhower/arduino-pico](https://github.com/earlephilhower/arduino-pico)
- [espressif/arduino-esp32](https://github.com/espressif/arduino-esp32)
- [espressif/arduino-esp32](https://github.com/espressif/arduino-esp32) additional Tools menu is needed
- `USB Mode=USB-OTG (TinyUSB)` for S3 and P4
- `USB CDC On Boot=Enabled`, `USB Firmware MSC On Boot=Disabled`, `USB DFU On Boot=Disabled`
- [openwch/arduino_core_ch32](https://github.com/openwch/arduino_core_ch32)
Note: For ESP32 port, version before v3.0 requires all descriptors must be specified in usb objects declaration i.e constructors. Therefore all descriptor-related fields must be part of object declaration and descriptor-related API have no effect afterwards. This limitation is not the case for version from v3.0.

View file

@ -25,11 +25,6 @@
#ifndef ADAFRUIT_TINYUSB_H_
#define ADAFRUIT_TINYUSB_H_
// ESP32 out-of-sync
#ifdef ARDUINO_ARCH_ESP32
#include "arduino/ports/esp32/tusb_config_esp32.h"
#endif
#include "tusb_option.h"
// Device

View file

@ -38,17 +38,43 @@ extern "C" {
// libraries, this file is used to make it compatible with ESP32 Arduino core.
// This file also contains additional configuration for EPS32 in addition to
// tools/sdk/esp32xx/include/arduino_tinyusb/include/tusb_config.h
// tools/esp32-arduino-libs/esp32xx/include/arduino_tinyusb/include/tusb_config.h
//--------------------------------------------------------------------+
// ESP32 out-of-sync
//--------------------------------------------------------------------+
#include "esp_arduino_version.h"
#include "sdkconfig.h"
#if ESP_ARDUINO_VERSION < ESP_ARDUINO_VERSION_VAL(2, 0, 8)
#error "ESP32 Arduino core version 2.0.8 or later is required"
#endif
//--------------------------------------------------------------------
// COMMON CONFIGURATION
// Note: it is possible to use tinyusb + max3421e as host controller
// with no OTG USB MCU such as eps32, c3 etc...
//--------------------------------------------------------------------
#if CONFIG_IDF_TARGET_ESP32S2
#define CFG_TUSB_MCU OPT_MCU_ESP32S2
#elif CONFIG_IDF_TARGET_ESP32S3
#define CFG_TUSB_MCU OPT_MCU_ESP32S3
#elif CONFIG_IDF_TARGET_ESP32P4
#define CFG_TUSB_MCU OPT_MCU_ESP32P4
#else
#define CFG_TUSB_MCU OPT_MCU_ESP32
#define CFG_TUH_MAX3421 1
#endif
#if CONFIG_IDF_TARGET_ESP32P4
#define CFG_TUD_MAX_SPEED OPT_MODE_HIGH_SPEED
#define CFG_TUH_MAX_SPEED OPT_MODE_HIGH_SPEED
#else
#define CFG_TUD_MAX_SPEED OPT_MODE_FULL_SPEED
#define CFG_TUH_MAX_SPEED OPT_MODE_FULL_SPEED
#endif
#ifndef CFG_TUSB_OS
#define CFG_TUSB_OS OPT_OS_FREERTOS
// clang-format off
@ -64,12 +90,6 @@ extern "C" {
#define CFG_TUH_LOG_LEVEL 2
#endif
//--------------------------------------------------------------------
// COMMON CONFIGURATION
// Note: it is possible to use tinyusb + max3421e as host controller
// with no OTG USB MCU such as eps32, c3 etc...
//--------------------------------------------------------------------
#ifndef CFG_TUSB_DEBUG
#define CFG_TUSB_DEBUG 0
#endif
@ -77,12 +97,43 @@ extern "C" {
// For selectively disable device log (when > CFG_TUSB_DEBUG)
// #define CFG_TUD_LOG_LEVEL 3
#define CFG_TUSB_MEM_SECTION
#define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4)
//--------------------------------------------------------------------
// DEVICE CONFIGURATION
//--------------------------------------------------------------------
#define CFG_TUD_ENABLED 1
// device configuration is configured in BSP
// sdk/include/arduino_tinyusb/include/tusb_config.h
#define CFG_TUD_CDC 2
#define CFG_TUD_MSC 1
#define CFG_TUD_HID 2
#define CFG_TUD_MIDI 1
#define CFG_TUD_VENDOR 1
#define CFG_TUD_VIDEO 1
#define CFG_TUD_VIDEO_STREAMING 1
// video streaming endpoint buffer size
#define CFG_TUD_VIDEO_STREAMING_EP_BUFSIZE \
CONFIG_TINYUSB_VIDEO_STREAMING_BUFSIZE
// CDC FIFO size of TX and RX
#define CFG_TUD_CDC_RX_BUFSIZE CONFIG_TINYUSB_CDC_RX_BUFSIZE
#define CFG_TUD_CDC_TX_BUFSIZE CONFIG_TINYUSB_CDC_TX_BUFSIZE
// MSC Buffer size of Device Mass storage
#define CFG_TUD_MSC_EP_BUFSIZE CONFIG_TINYUSB_MSC_BUFSIZE
// HID buffer size Should be sufficient to hold ID (if any) + Data
#define CFG_TUD_HID_BUFSIZE CONFIG_TINYUSB_HID_BUFSIZE
// MIDI FIFO size of TX and RX
#define CFG_TUD_MIDI_RX_BUFSIZE CONFIG_TINYUSB_MIDI_RX_BUFSIZE
#define CFG_TUD_MIDI_TX_BUFSIZE CONFIG_TINYUSB_MIDI_TX_BUFSIZE
// Vendor FIFO size of TX and RX
#define CFG_TUD_VENDOR_RX_BUFSIZE CONFIG_TINYUSB_VENDOR_RX_BUFSIZE
#define CFG_TUD_VENDOR_TX_BUFSIZE CONFIG_TINYUSB_VENDOR_TX_BUFSIZE
//--------------------------------------------------------------------
// Host Configuration
@ -90,8 +141,6 @@ extern "C" {
// Enable host stack with MAX3421E (host shield)
#define CFG_TUH_ENABLED 1
#define CFG_TUH_MAX_SPEED OPT_MODE_FULL_SPEED
#define CFG_TUH_MAX3421 1
#ifndef CFG_TUH_MAX3421_ENDPOINT_TOTAL
#define CFG_TUH_MAX3421_ENDPOINT_TOTAL (8 + 4 * (CFG_TUH_DEVICE_MAX - 1))

View file

@ -117,8 +117,8 @@ extern "C" {
#define CFG_TUD_HID_EP_BUFSIZE 64
// MIDI FIFO size of TX and RX
#define CFG_TUD_MIDI_RX_BUFSIZE 128
#define CFG_TUD_MIDI_TX_BUFSIZE 128
#define CFG_TUD_MIDI_RX_BUFSIZE 64
#define CFG_TUD_MIDI_TX_BUFSIZE 64
// Vendor FIFO size of TX and RX
#define CFG_TUD_VENDOR_RX_BUFSIZE 64

View file

@ -56,11 +56,6 @@
//--------------------------------------------------------------------+
// INCLUDE
//--------------------------------------------------------------------+
// ESP32 out-of-sync
#ifdef ARDUINO_ARCH_ESP32
#include "arduino/ports/esp32/tusb_config_esp32.h"
#endif
#include "device/usbd.h"
#include "device/usbd_pvt.h"

View file

@ -31,12 +31,6 @@
//--------------------------------------------------------------------+
// INCLUDE
//--------------------------------------------------------------------+
// ESP32 out-of-sync
#ifdef ARDUINO_ARCH_ESP32
#include "arduino/ports/esp32/tusb_config_esp32.h"
#endif
#include "bth_device.h"
#include <device/usbd_pvt.h>

View file

@ -24,11 +24,6 @@
* This file is part of the TinyUSB stack.
*/
// ESP32 out-of-sync
#ifdef ARDUINO_ARCH_ESP32
#include "arduino/ports/esp32/tusb_config_esp32.h"
#endif
#include "tusb_option.h"
#if (CFG_TUD_ENABLED && CFG_TUD_CDC)

View file

@ -24,11 +24,6 @@
* This file is part of the TinyUSB stack.
*/
// ESP32 out-of-sync
#ifdef ARDUINO_ARCH_ESP32
#include "arduino/ports/esp32/tusb_config_esp32.h"
#endif
#include "tusb_option.h"
#if (CFG_TUD_ENABLED && CFG_TUD_DFU)

View file

@ -24,11 +24,6 @@
* This file is part of the TinyUSB stack.
*/
// ESP32 out-of-sync
#ifdef ARDUINO_ARCH_ESP32
#include "arduino/ports/esp32/tusb_config_esp32.h"
#endif
#include "tusb_option.h"
#if (CFG_TUD_ENABLED && CFG_TUD_DFU_RUNTIME)

View file

@ -24,11 +24,6 @@
* This file is part of the TinyUSB stack.
*/
// ESP32 out-of-sync
#ifdef ARDUINO_ARCH_ESP32
#include "arduino/ports/esp32/tusb_config_esp32.h"
#endif
#include "tusb_option.h"
#if (CFG_TUH_ENABLED && CFG_TUH_HID)

View file

@ -24,11 +24,6 @@
* This file is part of the TinyUSB stack.
*/
// ESP32 out-of-sync
#ifdef ARDUINO_ARCH_ESP32
#include "arduino/ports/esp32/tusb_config_esp32.h"
#endif
#include "tusb_option.h"
#if (CFG_TUD_ENABLED && CFG_TUD_MIDI)

View file

@ -24,11 +24,6 @@
* This file is part of the TinyUSB stack.
*/
// ESP32 out-of-sync
#ifdef ARDUINO_ARCH_ESP32
#include "arduino/ports/esp32/tusb_config_esp32.h"
#endif
#include "tusb_option.h"
#if (CFG_TUD_ENABLED && CFG_TUD_MSC)

View file

@ -24,11 +24,6 @@
* This file is part of the TinyUSB stack.
*/
// ESP32 out-of-sync
#ifdef ARDUINO_ARCH_ESP32
#include "arduino/ports/esp32/tusb_config_esp32.h"
#endif
#include "tusb_option.h"
#if CFG_TUH_ENABLED && CFG_TUH_MSC

View file

@ -67,11 +67,6 @@
// Ability to defer status byte transmission
// Transmission of status byte in response to USB488 SRQ condition
// ESP32 out-of-sync
#ifdef ARDUINO_ARCH_ESP32
#include "arduino/ports/esp32/tusb_config_esp32.h"
#endif
#include "tusb_option.h"
#if (CFG_TUD_ENABLED && CFG_TUD_USBTMC)

View file

@ -24,11 +24,6 @@
* This file is part of the TinyUSB stack.
*/
// ESP32 out-of-sync
#ifdef ARDUINO_ARCH_ESP32
#include "arduino/ports/esp32/tusb_config_esp32.h"
#endif
#include "tusb_option.h"
#if (CFG_TUD_ENABLED && CFG_TUD_VENDOR)

View file

@ -25,11 +25,6 @@
* This file is part of the TinyUSB stack.
*/
// ESP32 out-of-sync
#ifdef ARDUINO_ARCH_ESP32
#include "arduino/ports/esp32/tusb_config_esp32.h"
#endif
#include "tusb_option.h"
#if (CFG_TUD_ENABLED && CFG_TUD_VIDEO && CFG_TUD_VIDEO_STREAMING)

View file

@ -24,11 +24,6 @@
* This file is part of the TinyUSB stack.
*/
// ESP32 out-of-sync
#ifdef ARDUINO_ARCH_ESP32
#include "arduino/ports/esp32/tusb_config_esp32.h"
#endif
#include "tusb_option.h"
#if CFG_TUD_ENABLED

View file

@ -24,11 +24,6 @@
* This file is part of the TinyUSB stack.
*/
// ESP32 out-of-sync
#ifdef ARDUINO_ARCH_ESP32
#include "arduino/ports/esp32/tusb_config_esp32.h"
#endif
#include "tusb_option.h"
#if CFG_TUD_ENABLED

View file

@ -24,11 +24,6 @@
* This file is part of the TinyUSB stack.
*/
// ESP32 out-of-sync
#ifdef ARDUINO_ARCH_ESP32
#include "arduino/ports/esp32/tusb_config_esp32.h"
#endif
#include "tusb_option.h"
#if (CFG_TUH_ENABLED && CFG_TUH_HUB)

View file

@ -24,11 +24,6 @@
* This file is part of the TinyUSB stack.
*/
// ESP32 out-of-sync
#ifdef ARDUINO_ARCH_ESP32
#include "arduino/ports/esp32/tusb_config_esp32.h"
#endif
#include "tusb_option.h"
#if CFG_TUH_ENABLED

View file

@ -27,11 +27,6 @@
#ifndef _TUSB_USBH_PVT_H_
#define _TUSB_USBH_PVT_H_
// ESP32 out-of-sync
#ifdef ARDUINO_ARCH_ESP32
#include "arduino/ports/esp32/tusb_config_esp32.h"
#endif
#include "osal/osal.h"
#include "common/tusb_fifo.h"
#include "common/tusb_private.h"

View file

@ -24,11 +24,6 @@
* This file is part of the TinyUSB stack.
*/
// ESP32 out-of-sync
#ifdef ARDUINO_ARCH_ESP32
#include "arduino/ports/esp32/tusb_config_esp32.h"
#endif
#include "tusb_option.h"
#if CFG_TUH_ENABLED && defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421

View file

@ -27,11 +27,6 @@
* This file is part of the TinyUSB stack.
*/
// ESP32 out-of-sync
#ifdef ARDUINO_ARCH_ESP32
#include "arduino/ports/esp32/tusb_config_esp32.h"
#endif
#include "tusb_option.h"
#if CFG_TUD_ENABLED && defined(TUP_USBIP_DWC2)

View file

@ -24,11 +24,6 @@
* This file is part of the TinyUSB stack.
*/
// ESP32 out-of-sync
#ifdef ARDUINO_ARCH_ESP32
#include "arduino/ports/esp32/tusb_config_esp32.h"
#endif
#include "tusb_option.h"
#if CFG_TUH_ENABLED || CFG_TUD_ENABLED

View file

@ -39,17 +39,7 @@
#include "arduino/ports/rp2040/tusb_config_rp2040.h"
#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
// Note: For platformio prioritize this file over the one in BSP in all cases
// do nothing since we force include "arduino/ports/esp32/tusb_config_esp32.h" in tusb_option.h
#elif defined(ARDUINO_ARCH_CH32) || defined(CH32V20x) || defined(CH32V30x)
#include "arduino/ports/ch32/tusb_config_ch32.h"

View file

@ -240,6 +240,9 @@
// Allow to use command line to change the config name/location
#ifdef CFG_TUSB_CONFIG_FILE
#include CFG_TUSB_CONFIG_FILE
#elif defined(ARDUINO_ARCH_ESP32)
// ESP32 out-of-sync
#include "arduino/ports/esp32/tusb_config_esp32.h"
#else
#include "tusb_config.h"
#endif