Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32 Arduino v3.0 libs from ESP-IDF v5.1 #230

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,4 @@ add_custom_command(
)
add_custom_target(mem-variant DEPENDS "mem_variant")

##################
### ESP Matter ###
##################
idf_build_set_property(CXX_COMPILE_OPTIONS "-std=gnu++17;-DCHIP_HAVE_CONFIG_H" APPEND)
idf_build_set_property(COMPILE_DEFINITIONS "-DESP32_ARDUINO_LIB_BUILDER" APPEND)
3 changes: 2 additions & 1 deletion components/arduino_tinyusb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ if(CONFIG_TINYUSB_ENABLED)
# espressif:
"${COMPONENT_DIR}/src/dcd_dwc2.c"
# tusb:
#"{COMPONENT_DIR}/tinyusb/src/portable/synopsys/dwc2/dcd_dwc2.c"
#"${COMPONENT_DIR}/tinyusb/src/portable/synopsys/dwc2/dcd_dwc2.c"
"${COMPONENT_DIR}/tinyusb/src/portable/synopsys/dwc2/dwc2_common.c"
"${COMPONENT_DIR}/tinyusb/src/class/cdc/cdc_device.c"
"${COMPONENT_DIR}/tinyusb/src/class/hid/hid_device.c"
"${COMPONENT_DIR}/tinyusb/src/class/midi/midi_device.c"
Expand Down
43 changes: 22 additions & 21 deletions components/arduino_tinyusb/patches/dcd_dwc2.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- a/components/arduino_tinyusb/src/dcd_dwc2.c 2024-10-02 12:17:40.000000000 +0300
+++ b/components/arduino_tinyusb/src/dcd_dwc2.c 2024-10-02 12:19:48.000000000 +0300
@@ -316,6 +316,16 @@
@@ -243,6 +243,17 @@
//--------------------------------------------------------------------
// Endpoint
//--------------------------------------------------------------------
Expand All @@ -14,14 +14,16 @@
+ return 0;
+}
+#endif
static void edpt_activate(uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc) {
+
static void edpt_activate(uint8_t rhport, const tusb_desc_endpoint_t* p_endpoint_desc) {
dwc2_regs_t* dwc2 = DWC2_REG(rhport);
@@ -336,7 +346,18 @@
dwc2->epout[epnum].doepctl = dxepctl;
dwc2->daintmsk |= TU_BIT(DAINTMSK_OEPM_Pos + epnum);
} else {
- dwc2->epin[epnum].diepctl = dxepctl | (epnum << DIEPCTL_TXFNUM_Pos);
const uint8_t epnum = tu_edpt_number(p_endpoint_desc->bEndpointAddress);
@@ -266,7 +277,18 @@
depctl.bm.set_data0_iso_even = 1;
}
if (dir == TUSB_DIR_IN) {
- depctl.bm.tx_fifo_num = epnum;
+ //depctl.bm.tx_fifo_num = epnum;
+ uint8_t fifo_num = epnum;
+#if defined(TUP_USBIP_DWC2_ESP32)
+ // Special Case for EP5, which is used by CDC but not actually called by the driver
Expand All @@ -31,14 +33,13 @@
+ } else {
+ fifo_num = get_free_fifo();
+ }
+ //TU_ASSERT(fifo_num != 0);
+#endif
+ dwc2->epin[epnum].diepctl = dxepctl | (fifo_num << DIEPCTL_TXFNUM_Pos);
dwc2->daintmsk |= TU_BIT(DAINTMSK_IEPM_Pos + epnum);
+ depctl.bm.tx_fifo_num = fifo_num;
}
}
@@ -850,6 +871,10 @@
xfer_status[n][TUSB_DIR_IN].max_size = 0;

dwc2_dep_t* dep = &dwc2->ep[dir == TUSB_DIR_IN ? 0 : 1][epnum];
@@ -557,6 +579,10 @@
}
}

+#if defined(TUP_USBIP_DWC2_ESP32)
Expand All @@ -48,19 +49,19 @@
dfifo_flush_tx(dwc2, 0x10); // all tx fifo
dfifo_flush_rx(dwc2);

@@ -1204,6 +1229,9 @@
if (int_status & GINTSTS_USBRST) {
@@ -997,6 +1023,9 @@
if (gintsts & GINTSTS_USBRST) {
// USBRST is start of reset.
dwc2->gintsts = GINTSTS_USBRST;
+#if defined(TUP_USBIP_DWC2_ESP32)
+ _allocated_fifos = 1;
+#endif
bus_reset(rhport);
handle_bus_reset(rhport);
}

@@ -1235,7 +1263,11 @@
@@ -1008,7 +1037,11 @@

if (int_status & GINTSTS_USBSUSP) {
if (gintsts & GINTSTS_USBSUSP) {
dwc2->gintsts = GINTSTS_USBSUSP;
- dcd_event_bus_signal(rhport, DCD_EVENT_SUSPEND, true);
+ //dcd_event_bus_signal(rhport, DCD_EVENT_SUSPEND, true);
Expand All @@ -70,8 +71,8 @@
+#endif
}

if (int_status & GINTSTS_WKUINT) {
@@ -1252,6 +1284,9 @@
if (gintsts & GINTSTS_WKUINT) {
@@ -1025,6 +1058,9 @@

if (otg_int & GOTGINT_SEDET) {
dcd_event_bus_signal(rhport, DCD_EVENT_UNPLUGGED, true);
Expand Down
Loading