Skip to content

Commit 0348f97

Browse files
committed
Fix ESP builds
1 parent 4640859 commit 0348f97

File tree

1 file changed

+10
-31
lines changed
  • ports/espressif/supervisor

1 file changed

+10
-31
lines changed

ports/espressif/supervisor/usb.c

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include "shared/readline/readline.h"
1414

1515
#include "hal/gpio_ll.h"
16-
#include "hal/usb_serial_jtag_ll.h"
1716

1817
#include "esp_err.h"
1918
#include "esp_private/usb_phy.h"
@@ -29,6 +28,10 @@
2928

3029
#include "tusb.h"
3130

31+
#ifdef CONFIG_IDF_TARGET_ESP32P4
32+
#include "hal/usb_serial_jtag_ll.h"
33+
#endif
34+
3235
#if CIRCUITPY_USB_DEVICE
3336
#ifdef CFG_TUSB_DEBUG
3437
#define USBD_STACK_SIZE (3 * configMINIMAL_STACK_SIZE)
@@ -66,11 +69,11 @@ void init_usb_hardware(void) {
6669
.target = USB_PHY_TARGET_INT,
6770
.otg_mode = USB_OTG_MODE_DEVICE,
6871
#if defined(CONFIG_IDF_TARGET_ESP32P4) && CIRCUITPY_USB_DEVICE_INSTANCE == 0
69-
.otg_speed = USB_PHY_SPEED_FULL,
72+
.otg_speed = USB_PHY_SPEED_FULL,
7073
#else
7174
// https://github.com/hathach/tinyusb/issues/2943#issuecomment-2601888322
7275
// Set speed to undefined (auto-detect) to avoid timing/race issue with S3 with host such as macOS
73-
.otg_speed = USB_PHY_SPEED_UNDEFINED,
76+
.otg_speed = USB_PHY_SPEED_UNDEFINED,
7477
#endif
7578
};
7679
usb_new_phy(&phy_conf, &device_phy_hdl);
@@ -81,9 +84,11 @@ void init_usb_hardware(void) {
8184
#endif
8285
// Switch the USB PHY
8386
const usb_serial_jtag_pull_override_vals_t override_disable_usb = {
84-
.dm_pd = true, .dm_pu = false, .dp_pd = true, .dp_pu = false};
87+
.dm_pd = true, .dm_pu = false, .dp_pd = true, .dp_pu = false
88+
};
8589
const usb_serial_jtag_pull_override_vals_t override_enable_usb = {
86-
.dm_pd = false, .dm_pu = false, .dp_pd = false, .dp_pu = true};
90+
.dm_pd = false, .dm_pu = false, .dp_pd = false, .dp_pu = true
91+
};
8792

8893
// Drop off the bus by removing the pull-up on USB DP
8994
usb_serial_jtag_ll_phy_enable_pull_override(&override_disable_usb);
@@ -97,32 +102,6 @@ void init_usb_hardware(void) {
97102
usb_serial_jtag_ll_phy_disable_pull_override();
98103
#endif
99104

100-
// Pin the USB task to the same core as CircuitPython. This way we leave
101-
// the other core for networking.
102-
(void)xTaskCreateStaticPinnedToCore(usb_device_task,
103-
"usbd",
104-
USBD_STACK_SIZE,
105-
NULL,
106-
5,
107-
usb_device_stack,
108-
&usb_device_taskdef,
109-
xPortGetCoreID());
110-
#endif
111-
// Configure USB PHY
112-
usb_phy_config_t phy_conf = {
113-
.controller = USB_PHY_CTRL_OTG,
114-
.target = USB_PHY_TARGET_INT,
115-
.otg_mode = USB_OTG_MODE_DEVICE,
116-
#if defined(CONFIG_IDF_TARGET_ESP32P4) && CIRCUITPY_USB_DEVICE_INSTANCE == 0
117-
.otg_speed = USB_PHY_SPEED_FULL,
118-
#else
119-
// https://github.com/hathach/tinyusb/issues/2943#issuecomment-2601888322
120-
// Set speed to undefined (auto-detect) to avoid timing/race issue with S3 with host such as macOS
121-
.otg_speed = USB_PHY_SPEED_UNDEFINED,
122-
#endif
123-
};
124-
usb_new_phy(&phy_conf, &device_phy_hdl);
125-
126105
// Pin the USB task to the same core as CircuitPython. This way we leave
127106
// the other core for networking.
128107
(void)xTaskCreateStaticPinnedToCore(usb_device_task,

0 commit comments

Comments
 (0)