Skip to content

Commit 82d0004

Browse files
committed
Enable USB on ESP32-P4
1 parent cd84d81 commit 82d0004

File tree

10 files changed

+63
-22
lines changed

10 files changed

+63
-22
lines changed

lib/tinyusb

Submodule tinyusb updated 409 files

ports/espressif/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ INC += \
9595
-isystem esp-idf/components/esp_hw_support/dma/include \
9696
-isystem esp-idf/components/esp_hw_support/include \
9797
-isystem esp-idf/components/esp_hw_support/include/soc \
98+
-isystem esp-idf/components/esp_mm/include \
9899
-isystem esp-idf/components/esp_netif/include \
99100
-isystem esp-idf/components/esp_partition/include \
100101
-isystem esp-idf/components/esp_pm/include \
@@ -412,7 +413,9 @@ SRC_C += peripherals/touch.c
412413
endif
413414

414415
ifneq ($(CIRCUITPY_USB_DEVICE),0)
415-
SRC_C += lib/tinyusb/src/portable/espressif/esp32sx/dcd_esp32sx.c
416+
SRC_C += \
417+
lib/tinyusb/src/portable/synopsys/dwc2/dcd_dwc2.c \
418+
lib/tinyusb/src/portable/synopsys/dwc2/dwc2_common.c
416419
endif
417420

418421
ifneq ($(CIRCUITPY_AUDIOBUSIO),0)

ports/espressif/boards/espressif_esp32p4_function_ev/mpconfigboard.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,3 @@
1515

1616
#define DEFAULT_UART_BUS_RX (&pin_GPIO38)
1717
#define DEFAULT_UART_BUS_TX (&pin_GPIO37)
18-
19-
#define CIRCUITPY_CONSOLE_UART_TX DEFAULT_UART_BUS_TX
20-
#define CIRCUITPY_CONSOLE_UART_RX DEFAULT_UART_BUS_RX
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# USB_VID = 0x303A
2-
# USB_PID = 0x7003
3-
# USB_PRODUCT = "ESP32-P4-Function-EV"
4-
# USB_MANUFACTURER = "Espressif"
1+
USB_VID = 0x303A
2+
USB_PID = 0x7013
3+
USB_PRODUCT = "ESP32-P4-Function-EV"
4+
USB_MANUFACTURER = "Espressif"
55

66
IDF_TARGET = esp32p4
77

88
CIRCUITPY_ESP_FLASH_SIZE = 16MB
9-
CIRCUITPY_ESP_FLASH_MODE = opi
9+
CIRCUITPY_ESP_FLASH_MODE = qio
1010
CIRCUITPY_ESP_FLASH_FREQ = 80m
1111

1212
CIRCUITPY_ESP_PSRAM_SIZE = 32MB
13-
CIRCUITPY_ESP_PSRAM_MODE = opi
14-
CIRCUITPY_ESP_PSRAM_FREQ = 80m
13+
CIRCUITPY_ESP_PSRAM_MODE = hpi
14+
CIRCUITPY_ESP_PSRAM_FREQ = 200m
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# USB_VID = 0x303A
2-
# USB_PID = 0x7003
3-
# USB_PRODUCT = "ESP32-P4 Stamp XL"
4-
# USB_MANUFACTURER = "Solder Party"
1+
USB_VID = 0x1209
2+
USB_PID = 0x0001
3+
USB_PRODUCT = "ESP32-P4 Stamp XL"
4+
USB_MANUFACTURER = "Solder Party"
55

66
IDF_TARGET = esp32p4
77

88
CIRCUITPY_ESP_FLASH_SIZE = 16MB
9-
CIRCUITPY_ESP_FLASH_MODE = opi
9+
CIRCUITPY_ESP_FLASH_MODE = qio
1010
CIRCUITPY_ESP_FLASH_FREQ = 80m
1111

1212
CIRCUITPY_ESP_PSRAM_SIZE = 32MB
13-
CIRCUITPY_ESP_PSRAM_MODE = opi
14-
CIRCUITPY_ESP_PSRAM_FREQ = 80m
13+
CIRCUITPY_ESP_PSRAM_MODE = hpi
14+
CIRCUITPY_ESP_PSRAM_FREQ = 200m
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#
2+
# Espressif IoT Development Framework Configuration
3+
#
4+
#
5+
# Component config
6+
#
7+
#
8+
# Bluetooth
9+
#
10+
# CONFIG_BT_ENABLED is not set
11+
# end of Bluetooth
12+
13+
#
14+
# mbedTLS
15+
#
16+
# CONFIG_MBEDTLS_CMAC_C is not set
17+
# end of mbedTLS
18+
19+
# end of Component config
20+
21+
# end of Espressif IoT Development Framework Configuration

ports/espressif/mpconfigport.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
#define CIRCUITPY_DIGITALIO_HAVE_INPUT_ONLY (1)
1919

20+
#define CIRCUITPY_USB_DEVICE_INSTANCE 1
21+
2022
#include "py/circuitpy_mpconfig.h"
2123

2224
#define MICROPY_NLR_SETJMP (1)

ports/espressif/mpconfigport.mk

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,14 @@ CIRCUITPY_SSL = 0
196196
CIRCUITPY_TOUCHIO = 1
197197
CIRCUITPY_TOUCHIO_USE_NATIVE = 0
198198

199-
# TinyUSB doesn't have it upstreamed
200-
# https://github.com/hathach/tinyusb/issues/2791
201-
CIRCUITPY_USB_DEVICE = 0
199+
# Second stage bootloader doesn't work when the factory partition is empty due to
200+
# UF2 missing.
201+
UF2_BOOTLOADER = 0
202+
USB_HIGHSPEED = 1
203+
CIRCUITPY_USB_HID = 0
204+
CIRCUITPY_USB_MIDI = 0
205+
CIRCUITPY_TUSB_MEM_ALIGN = 64
206+
202207
CIRCUITPY_MAX3421E = 0
203208

204209
# Update this for the 40mhz processor.

ports/espressif/supervisor/usb.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,14 @@ void init_usb_hardware(void) {
9494
// Configure USB PHY
9595
usb_phy_config_t phy_conf = {
9696
.controller = USB_PHY_CTRL_OTG,
97+
.target = USB_PHY_TARGET_INT,
98+
9799
.otg_mode = USB_OTG_MODE_DEVICE,
100+
#ifdef CONFIG_IDF_TARGET_ESP32P4
101+
.otg_speed = USB_PHY_SPEED_HIGH,
102+
#else
103+
.otg_speed = USB_PHY_SPEED_FULL,
104+
#endif
98105
};
99106
usb_new_phy(&phy_conf, &phy_hdl);
100107

supervisor/shared/usb/tusb_config.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ extern "C" {
8989
#endif
9090
#endif
9191

92+
// Use DMA with the USB peripheral.
93+
#ifdef CONFIG_IDF_TARGET_ESP32P4
94+
#define CFG_TUD_DWC2_DMA_ENABLE (1)
95+
#define CFG_TUH_DWC2_DMA_ENABLE (1)
96+
#endif
97+
9298
// Vendor name included in Inquiry response, max 8 bytes
9399
#define CFG_TUD_MSC_VENDOR USB_MANUFACTURER_8
94100

0 commit comments

Comments
 (0)