diff options
| author | Ha Thach <[email protected]> | 2025-09-16 22:10:53 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-09-16 22:10:53 +0700 |
| commit | d9ad09a8dce9e54cbd23062f8dec6c4fd49dc906 (patch) | |
| tree | 98da2b93ae00831c64a78b8a4773779adcb873d0 | |
| parent | feef534921446e1a3ded54a0c46191fe1709bdb4 (diff) | |
| parent | 4182342112d92898d2b55ef9562c545a9ebf52ac (diff) | |
Merge pull request #3252 from espressif/feat/esp32h4_support
Add ESP32-H4 as a supported MCU in TinyUSB and wire it into build/run…
| -rw-r--r-- | README.rst | 2 | ||||
| -rw-r--r-- | hw/bsp/espressif/boards/family.c | 6 | ||||
| -rw-r--r-- | src/common/tusb_mcu.h | 2 | ||||
| -rw-r--r-- | src/portable/synopsys/dwc2/dwc2_esp32.h | 17 | ||||
| -rw-r--r-- | src/tusb_option.h | 1 |
5 files changed, 24 insertions, 4 deletions
diff --git a/README.rst b/README.rst index d6830e707..4a17e1d1f 100644 --- a/README.rst +++ b/README.rst @@ -124,6 +124,8 @@ Supported CPUs | Espressif | S2, S3 | ✔ | ✔ | ✖ | dwc2 or esp32sx | | | ESP32 +-----------------------------+--------+------+-----------+------------------------+-------------------+ | | P4 | ✔ | ✔ | ✔ | dwc2 | | + +-----------------------------+--------+------+-----------+------------------------+-------------------+ +| | H4 | ✔ | ✔ | ✖ | dwc2 | | +--------------+----+------------------------+--------+------+-----------+------------------------+-------------------+ | GigaDevice | GD32VF103 | ✔ | | ✖ | dwc2 | | +--------------+-----------------------------+--------+------+-----------+------------------------+-------------------+ diff --git a/hw/bsp/espressif/boards/family.c b/hw/bsp/espressif/boards/family.c index 2a5deed26..28dd49143 100644 --- a/hw/bsp/espressif/boards/family.c +++ b/hw/bsp/espressif/boards/family.c @@ -49,7 +49,7 @@ static led_strip_handle_t led_strip; static void max3421_init(void); #endif -#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3, OPT_MCU_ESP32P4) +#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3, OPT_MCU_ESP32H4, OPT_MCU_ESP32P4) static bool usb_init(void); #endif @@ -105,7 +105,7 @@ void board_init(void) { #endif } -#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3) +#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3, OPT_MCU_ESP32H4) #endif @@ -164,7 +164,7 @@ void board_putchar(int c) { // PHY Init //-------------------------------------------------------------------- -#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3, OPT_MCU_ESP32P4) +#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3, OPT_MCU_ESP32H4, OPT_MCU_ESP32P4) #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0) #include "esp_private/usb_phy.h" diff --git a/src/common/tusb_mcu.h b/src/common/tusb_mcu.h index 7722ca1e6..b647b2a7f 100644 --- a/src/common/tusb_mcu.h +++ b/src/common/tusb_mcu.h @@ -387,7 +387,7 @@ //--------------------------------------------------------------------+ // Espressif //--------------------------------------------------------------------+ -#elif TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3) +#elif TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3, OPT_MCU_ESP32H4) #define TUP_USBIP_DWC2 #define TUP_USBIP_DWC2_ESP32 #define TUP_DCD_ENDPOINT_MAX 7 // only 5 TX FIFO for endpoint IN diff --git a/src/portable/synopsys/dwc2/dwc2_esp32.h b/src/portable/synopsys/dwc2/dwc2_esp32.h index 49b8c54cb..a4e0d1770 100644 --- a/src/portable/synopsys/dwc2/dwc2_esp32.h +++ b/src/portable/synopsys/dwc2/dwc2_esp32.h @@ -47,6 +47,23 @@ static const dwc2_controller_t _dwc2_controller[] = { { .reg_base = DWC2_FS_REG_BASE, .irqnum = ETS_USB_INTR_SOURCE, .ep_count = 7, .ep_in_count = 5, .ep_fifo_size = 1024 } }; +#elif TU_CHECK_MCU(OPT_MCU_ESP32H4) +// H4's USB_WRAP register block uses "wrap_*" field names. Map them to the +// names used by TinyUSB's DWC2 port to keep the source unchanged. +#define otg_conf wrap_otg_conf +#define pad_pull_override wrap_pad_pull_override +#define dp_pullup wrap_dp_pullup +#define dp_pulldown wrap_dp_pulldown +#define dm_pullup wrap_dm_pullup +#define dm_pulldown wrap_dm_pulldown + +#define DWC2_FS_REG_BASE 0x60040000UL +#define DWC2_EP_MAX 7 + +static const dwc2_controller_t _dwc2_controller[] = { + { .reg_base = DWC2_FS_REG_BASE, .irqnum = ETS_USB_OTG11_INTR_SOURCE, .ep_count = 7, .ep_in_count = 5, .ep_fifo_size = 1024 } +}; + #elif TU_CHECK_MCU(OPT_MCU_ESP32P4) #define DWC2_FS_REG_BASE 0x50040000UL #define DWC2_HS_REG_BASE 0x50000000UL diff --git a/src/tusb_option.h b/src/tusb_option.h index b2dd5fcb2..fe7e34111 100644 --- a/src/tusb_option.h +++ b/src/tusb_option.h @@ -131,6 +131,7 @@ #define OPT_MCU_ESP32P4 907 ///< Espressif ESP32-P4 #define OPT_MCU_ESP32C5 908 ///< Espressif ESP32-C5 #define OPT_MCU_ESP32C61 909 ///< Espressif ESP32-C61 +#define OPT_MCU_ESP32H4 910 ///< Espressif ESP32-H4 #define TUSB_MCU_VENDOR_ESPRESSIF (CFG_TUSB_MCU >= 900 && CFG_TUSB_MCU < 1000) // check if Espressif MCU #define TUP_MCU_ESPRESSIF TUSB_MCU_VENDOR_ESPRESSIF // for backward compatibility |
