Skip to content

Commit d9ad09a

Browse files
authored
Merge pull request #3252 from espressif/feat/esp32h4_support
Add ESP32-H4 as a supported MCU in TinyUSB and wire it into build/run…
2 parents feef534 + 4182342 commit d9ad09a

File tree

5 files changed

+24
-4
lines changed

5 files changed

+24
-4
lines changed

README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ Supported CPUs
124124
| Espressif | S2, S3 |||| dwc2 or esp32sx | |
125125
| ESP32 +-----------------------------+--------+------+-----------+------------------------+-------------------+
126126
| | P4 |||| dwc2 | |
127+
+-----------------------------+--------+------+-----------+------------------------+-------------------+
128+
| | H4 |||| dwc2 | |
127129
+--------------+----+------------------------+--------+------+-----------+------------------------+-------------------+
128130
| GigaDevice | GD32VF103 || || dwc2 | |
129131
+--------------+-----------------------------+--------+------+-----------+------------------------+-------------------+

hw/bsp/espressif/boards/family.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static led_strip_handle_t led_strip;
4949
static void max3421_init(void);
5050
#endif
5151

52-
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3, OPT_MCU_ESP32P4)
52+
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3, OPT_MCU_ESP32H4, OPT_MCU_ESP32P4)
5353
static bool usb_init(void);
5454
#endif
5555

@@ -105,7 +105,7 @@ void board_init(void) {
105105
#endif
106106
}
107107

108-
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
108+
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3, OPT_MCU_ESP32H4)
109109

110110
#endif
111111

@@ -164,7 +164,7 @@ void board_putchar(int c) {
164164
// PHY Init
165165
//--------------------------------------------------------------------
166166

167-
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3, OPT_MCU_ESP32P4)
167+
#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3, OPT_MCU_ESP32H4, OPT_MCU_ESP32P4)
168168
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)
169169

170170
#include "esp_private/usb_phy.h"

src/common/tusb_mcu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@
387387
//--------------------------------------------------------------------+
388388
// Espressif
389389
//--------------------------------------------------------------------+
390-
#elif TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
390+
#elif TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3, OPT_MCU_ESP32H4)
391391
#define TUP_USBIP_DWC2
392392
#define TUP_USBIP_DWC2_ESP32
393393
#define TUP_DCD_ENDPOINT_MAX 7 // only 5 TX FIFO for endpoint IN

src/portable/synopsys/dwc2/dwc2_esp32.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,23 @@ static const dwc2_controller_t _dwc2_controller[] = {
4747
{ .reg_base = DWC2_FS_REG_BASE, .irqnum = ETS_USB_INTR_SOURCE, .ep_count = 7, .ep_in_count = 5, .ep_fifo_size = 1024 }
4848
};
4949

50+
#elif TU_CHECK_MCU(OPT_MCU_ESP32H4)
51+
// H4's USB_WRAP register block uses "wrap_*" field names. Map them to the
52+
// names used by TinyUSB's DWC2 port to keep the source unchanged.
53+
#define otg_conf wrap_otg_conf
54+
#define pad_pull_override wrap_pad_pull_override
55+
#define dp_pullup wrap_dp_pullup
56+
#define dp_pulldown wrap_dp_pulldown
57+
#define dm_pullup wrap_dm_pullup
58+
#define dm_pulldown wrap_dm_pulldown
59+
60+
#define DWC2_FS_REG_BASE 0x60040000UL
61+
#define DWC2_EP_MAX 7
62+
63+
static const dwc2_controller_t _dwc2_controller[] = {
64+
{ .reg_base = DWC2_FS_REG_BASE, .irqnum = ETS_USB_OTG11_INTR_SOURCE, .ep_count = 7, .ep_in_count = 5, .ep_fifo_size = 1024 }
65+
};
66+
5067
#elif TU_CHECK_MCU(OPT_MCU_ESP32P4)
5168
#define DWC2_FS_REG_BASE 0x50040000UL
5269
#define DWC2_HS_REG_BASE 0x50000000UL

src/tusb_option.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
#define OPT_MCU_ESP32P4 907 ///< Espressif ESP32-P4
132132
#define OPT_MCU_ESP32C5 908 ///< Espressif ESP32-C5
133133
#define OPT_MCU_ESP32C61 909 ///< Espressif ESP32-C61
134+
#define OPT_MCU_ESP32H4 910 ///< Espressif ESP32-H4
134135
#define TUSB_MCU_VENDOR_ESPRESSIF (CFG_TUSB_MCU >= 900 && CFG_TUSB_MCU < 1000) // check if Espressif MCU
135136
#define TUP_MCU_ESPRESSIF TUSB_MCU_VENDOR_ESPRESSIF // for backward compatibility
136137

0 commit comments

Comments
 (0)