From a4c80583f74a511dee0ca22047d569ba3c89773a Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sat, 25 Jan 2025 21:58:21 +0100 Subject: [PATCH 01/22] keep folder flags --- tools/archive-build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/archive-build.sh b/tools/archive-build.sh index 139d720bf..1a999662e 100755 --- a/tools/archive-build.sh +++ b/tools/archive-build.sh @@ -61,7 +61,7 @@ mv arduino-esp32/ framework-arduinoespressif32/ cd framework-arduinoespressif32/libraries rm -rf **/examples cd ../tools/esp32-arduino-libs -rm -rf **/flags +# rm -rf **/flags cd ../../../ # If the framework is needed as tar.gz uncomment next line # tar --exclude=.* -zcf ../$pio_archive_path framework-arduinoespressif32/ From a0827abeaf24f697fff9041c426e754fc547198c Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 31 Jan 2025 00:18:44 +0100 Subject: [PATCH 02/22] Use 80Mhz for PSRAM too --- configs/defconfig.80m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configs/defconfig.80m b/configs/defconfig.80m index 7014fa954..2cc7bd0ef 100644 --- a/configs/defconfig.80m +++ b/configs/defconfig.80m @@ -1 +1,3 @@ CONFIG_ESPTOOLPY_FLASHFREQ_80M=y +CONFIG_SPIRAM_SPEED_80M=y +CONFIG_SPIRAM_SPEED=80 From 2b3edae92f4e3e7eac19fd83aed7107f9104db9a Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 31 Jan 2025 00:19:24 +0100 Subject: [PATCH 03/22] Use 40Mhz for PSRAM too --- configs/defconfig.40m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configs/defconfig.40m b/configs/defconfig.40m index ffc4b5c1c..f265bd780 100644 --- a/configs/defconfig.40m +++ b/configs/defconfig.40m @@ -1 +1,3 @@ CONFIG_ESPTOOLPY_FLASHFREQ_40M=y +CONFIG_SPIRAM_SPEED_40M=y +CONFIG_SPIRAM_SPEED=40 From f165389adcf3b4f41d5a3cf734f4fe0c8e4ad4ac Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 31 Jan 2025 22:19:05 +0100 Subject: [PATCH 04/22] lib lcd needs to be specific for S3 --- configs/builds.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/configs/builds.json b/configs/builds.json index 5ec2470cc..026c8d23b 100644 --- a/configs/builds.json +++ b/configs/builds.json @@ -36,6 +36,12 @@ "out":"lib/libesp_hw_support.a", "targets":["esp32s3"] }, + { + "file":"libesp_lcd.a", + "src":"build/esp-idf/esp_lcd/libesp_lcd.a", + "out":"lib/libesp_lcd.a", + "targets":["esp32s3"] + }, { "file":"sections.ld", "src":"build/esp-idf/esp_system/ld/sections.ld", From f3f9ffb3b5a376f994f833c59fed9f8986d3286c Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 5 Feb 2025 13:32:07 +0100 Subject: [PATCH 05/22] esp32-p4: Enable optimizations for RGB LCD --- configs/defconfig.esp32p4 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configs/defconfig.esp32p4 b/configs/defconfig.esp32p4 index b7d9a6539..5fcdb5616 100644 --- a/configs/defconfig.esp32p4 +++ b/configs/defconfig.esp32p4 @@ -20,6 +20,10 @@ CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=3120 CONFIG_CACHE_L2_CACHE_256KB=y CONFIG_CACHE_L2_CACHE_LINE_128B=y +# RGB Display Optimizations +CONFIG_LCD_RGB_ISR_IRAM_SAFE=y +CONFIG_LCD_RGB_RESTART_IN_VSYNC=y + CONFIG_SLAVE_IDF_TARGET_ESP32C6=y CONFIG_ESP_SDIO_BUS_WIDTH=4 CONFIG_ESP_SDIO_CLOCK_FREQ_KHZ=40000 From ef8120ed99bdab53d396ff66afacda7396bc57bf Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 12 Feb 2025 11:29:20 +0100 Subject: [PATCH 06/22] Update Kconfig.projbuild --- components/arduino_tinyusb/Kconfig.projbuild | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/arduino_tinyusb/Kconfig.projbuild b/components/arduino_tinyusb/Kconfig.projbuild index 65d9c37be..f0a1b4dc6 100755 --- a/components/arduino_tinyusb/Kconfig.projbuild +++ b/components/arduino_tinyusb/Kconfig.projbuild @@ -42,6 +42,14 @@ menu "Arduino TinyUSB" help CDC FIFO size of TX + config TINYUSB_CDC_MAX_PORTS + int "Maximum enabled CDC ports" + range 1 2 + default 1 + depends on TINYUSB_CDC_ENABLED + help + Maximum enabled CDC ports + endmenu menu "Mass Storage (MSC) driver" From cd049bc0d98d8e63912201672f4a92c14d48f9b0 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 12 Feb 2025 11:30:10 +0100 Subject: [PATCH 07/22] Update tusb_config.h --- components/arduino_tinyusb/include/tusb_config.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/arduino_tinyusb/include/tusb_config.h b/components/arduino_tinyusb/include/tusb_config.h index 458c78cf1..7802bea8f 100755 --- a/components/arduino_tinyusb/include/tusb_config.h +++ b/components/arduino_tinyusb/include/tusb_config.h @@ -115,7 +115,11 @@ extern "C" { #define CFG_TUD_ENDOINT0_SIZE 64 // Enabled Drivers -#define CFG_TUD_CDC CONFIG_TINYUSB_CDC_ENABLED +#ifdef CONFIG_TINYUSB_CDC_MAX_PORTS +#define CFG_TUD_CDC CONFIG_TINYUSB_CDC_MAX_PORTS +#else +#define CFG_TUD_CDC 0 +#endif #define CFG_TUD_MSC CONFIG_TINYUSB_MSC_ENABLED #define CFG_TUD_HID CONFIG_TINYUSB_HID_ENABLED #define CFG_TUD_MIDI CONFIG_TINYUSB_MIDI_ENABLED From 87d59238e06a64b97433e3430460b48a178484f4 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 12 Feb 2025 11:32:39 +0100 Subject: [PATCH 08/22] CONFIG_TINYUSB_CDC_MAX_PORTS=2 --- configs/defconfig.common | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/configs/defconfig.common b/configs/defconfig.common index 20f0627ba..0d5f70511 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -227,6 +227,11 @@ CONFIG_LITTLEFS_MAX_PARTITIONS=2 CONFIG_LITTLEFS_MULTIVERSION=y CONFIG_LITTLEFS_DISK_VERSION_2_0=y +# +# TinyUSB Config +# +CONFIG_TINYUSB_CDC_MAX_PORTS=2 + # # Disable Cameras not used # From 1a1dc51f57836313f19ba258cd678abc9a5dce8d Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 18 Feb 2025 13:33:07 +0100 Subject: [PATCH 09/22] AR_BRANCH="release/v3.1.x" --- tools/config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/config.sh b/tools/config.sh index cac07c340..17b5c13ae 100755 --- a/tools/config.sh +++ b/tools/config.sh @@ -11,7 +11,7 @@ fi # Arduino branch to use if [ -z $AR_BRANCH ]; then - AR_BRANCH="main" + AR_BRANCH="release/v3.1.x" fi if [ -z $IDF_TARGET ]; then From 4676f461b2c962e722343212793b7c1769d9e5b8 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 7 Mar 2025 12:07:27 +0100 Subject: [PATCH 10/22] fix(TinyUSB): USB HUB Subport Added, FIFO sizes(Bias Periodic OUT) --- configs/defconfig.common | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configs/defconfig.common b/configs/defconfig.common index 0d5f70511..21a5cc39a 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -231,6 +231,9 @@ CONFIG_LITTLEFS_DISK_VERSION_2_0=y # TinyUSB Config # CONFIG_TINYUSB_CDC_MAX_PORTS=2 +CONFIG_USB_HOST_HUBS_SUPPORTED=y +CONFIG_USB_HOST_HUB_MULTI_LEVEL=y +CONFIG_USB_HOST_HW_BUFFER_BIAS_PERIODIC_OUT=y # # Disable Cameras not used From c1ad72b34367d9a43db9d38587b8c1328ca441ff Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sat, 15 Mar 2025 15:06:17 +0100 Subject: [PATCH 11/22] Update defconfig.opi_ram --- configs/defconfig.opi_ram | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/defconfig.opi_ram b/configs/defconfig.opi_ram index 7b94edaf9..f1f2238cd 100644 --- a/configs/defconfig.opi_ram +++ b/configs/defconfig.opi_ram @@ -7,5 +7,6 @@ CONFIG_GDMA_CTRL_FUNC_IN_IRAM=y # I2S_ISR_IRAM_SAFE has to be set!! Done in common config CONFIG_GDMA_ISR_IRAM_SAFE=y # Enable the XIP-PSRAM feature, so the ext-mem cache won't be disabled when SPI1 is operating the main flash +CONFIG_SPIRAM_XIP_FROM_PSRAM=y CONFIG_SPIRAM_FETCH_INSTRUCTIONS=y CONFIG_SPIRAM_RODATA=y From 9c0a5bb18bc7bab660c6a7ef4a8e6c4d614e4ead Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sat, 15 Mar 2025 15:45:02 +0100 Subject: [PATCH 12/22] set s3 cache size to 16kb --- configs/defconfig.esp32s3 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configs/defconfig.esp32s3 b/configs/defconfig.esp32s3 index 758a1c9c4..2a42d9317 100644 --- a/configs/defconfig.esp32s3 +++ b/configs/defconfig.esp32s3 @@ -7,6 +7,8 @@ CONFIG_ULP_COPROC_RESERVE_MEM=4096 CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y CONFIG_SPIRAM=y CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y +CONFIG_ESP32S3_INSTRUCTION_CACHE_16KB=y +CONFIG_ESP32S3_DATA_CACHE_16KB=y CONFIG_RTC_CLK_CAL_CYCLES=576 CONFIG_ESP32S3_UNIVERSAL_MAC_ADDRESSES_TWO=y # CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND is not set From 256e6a66414e7802af4e0a28d97c8d080602591b Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 24 Mar 2025 13:27:09 +0100 Subject: [PATCH 13/22] CONFIG_HEAP_POISONING_DISABLED=y --- configs/defconfig.common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/defconfig.common b/configs/defconfig.common index 21a5cc39a..f9f8d05e6 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -78,7 +78,7 @@ CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=2304 CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH=y CONFIG_HAL_ASSERTION_DISABLE=y -CONFIG_HEAP_POISONING_LIGHT=y +CONFIG_HEAP_POISONING_DISABLED=y CONFIG_HTTPD_MAX_REQ_HDR_LEN=1024 CONFIG_HTTPD_WS_SUPPORT=y CONFIG_LOG_DEFAULT_LEVEL_NONE=y From ec717caeb918d9aeacacc4c71f8b7803720d50dc Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 13 Apr 2025 16:36:43 +0200 Subject: [PATCH 14/22] rm "-DNDEBUG" from compile DEFINES --- tools/copy-libs.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/copy-libs.sh b/tools/copy-libs.sh index 9513e862a..573b83076 100755 --- a/tools/copy-libs.sh +++ b/tools/copy-libs.sh @@ -122,7 +122,7 @@ for item in "${@:2:${#@}-5}"; do INCLUDES+="$item " fi elif [ "$prefix" = "-D" ]; then - if [[ "${item:2:7}" != "ARDUINO" ]] && [[ "$item" != "-DESP32=ESP32" ]]; then #skip ARDUINO defines + if [[ "${item:2:7}" != "ARDUINO" ]] && [[ "$item" != "-DESP32=ESP32" ]] && [[ "$item" != "-DNDEBUG" ]]; then #skip ARDUINO defines DEFINES+="$item " fi elif [ "$prefix" = "-O" ]; then @@ -489,7 +489,8 @@ echo "" >> "$AR_PLATFORMIO_PY" echo " CPPDEFINES=[" >> "$AR_PLATFORMIO_PY" set -- $DEFINES for item; do - item="${item:2}" #remove -D + item="${item:2}" #remove -D + item="${item/NDEBUG}" #remove NDEBUG if [[ $item == *"="* ]]; then item=(${item//=/ }) re='^[+-]?[0-9]+([.][0-9]+)?$' From 20999d0552df4348a87b59b1a18f6a3b049ff1d9 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 14 Apr 2025 21:09:18 +0200 Subject: [PATCH 15/22] Update prepare-ci.sh --- tools/prepare-ci.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/prepare-ci.sh b/tools/prepare-ci.sh index 0855e8496..7e5a29f1f 100755 --- a/tools/prepare-ci.sh +++ b/tools/prepare-ci.sh @@ -10,7 +10,7 @@ brew install gsed brew install gawk brew install gperf -brew install ninja +#brew install ninja brew install ccache python -m pip install --upgrade pip pip install wheel future pyelftools From ff70dadc1c06e309c730e75af2caa267c75fa9b0 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 15 Apr 2025 18:59:50 +0200 Subject: [PATCH 16/22] Update dcd_dwc2.c --- components/arduino_tinyusb/src/dcd_dwc2.c | 106 +++++++++++----------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/components/arduino_tinyusb/src/dcd_dwc2.c b/components/arduino_tinyusb/src/dcd_dwc2.c index d6796641a..ea931ab90 100644 --- a/components/arduino_tinyusb/src/dcd_dwc2.c +++ b/components/arduino_tinyusb/src/dcd_dwc2.c @@ -41,12 +41,6 @@ #include "device/dcd.h" #include "dwc2_common.h" -#if TU_CHECK_MCU(OPT_MCU_GD32VF103) - #define DWC2_EP_COUNT(_dwc2) DWC2_EP_MAX -#else - #define DWC2_EP_COUNT(_dwc2) ((_dwc2)->ghwcfg2_bm.num_dev_ep + 1) -#endif - //--------------------------------------------------------------------+ // MACRO TYPEDEF CONSTANT ENUM //--------------------------------------------------------------------+ @@ -79,6 +73,16 @@ CFG_TUD_MEM_SECTION static struct { TUD_EPBUF_DEF(setup_packet, 8); } _dcd_usbbuf; +TU_ATTR_ALWAYS_INLINE static inline uint8_t dwc2_ep_count(const dwc2_regs_t* dwc2) { + #if TU_CHECK_MCU(OPT_MCU_GD32VF103) + return DWC2_EP_MAX; + #else + const dwc2_ghwcfg2_t ghwcfg2 = {.value = dwc2->ghwcfg2}; + return ghwcfg2.num_dev_ep + 1; + #endif +} + + //-------------------------------------------------------------------- // DMA //-------------------------------------------------------------------- @@ -102,7 +106,8 @@ bool dcd_dcache_clean_invalidate(const void* addr, uint32_t data_size) { TU_ATTR_ALWAYS_INLINE static inline bool dma_device_enabled(const dwc2_regs_t* dwc2) { (void) dwc2; // Internal DMA only - return CFG_TUD_DWC2_DMA_ENABLE && dwc2->ghwcfg2_bm.arch == GHWCFG2_ARCH_INTERNAL_DMA; + const dwc2_ghwcfg2_t ghwcfg2 = {.value = dwc2->ghwcfg2}; + return CFG_TUD_DWC2_DMA_ENABLE && ghwcfg2.arch == GHWCFG2_ARCH_INTERNAL_DMA; } static void dma_setup_prepare(uint8_t rhport) { @@ -261,20 +266,15 @@ static void edpt_activate(uint8_t rhport, const tusb_desc_endpoint_t* p_endpoint xfer->interval = p_endpoint_desc->bInterval; // Endpoint control - union { - uint32_t value; - dwc2_depctl_t bm; - } depctl; - depctl.value = 0; - - depctl.bm.mps = xfer->max_size; - depctl.bm.active = 1; - depctl.bm.type = p_endpoint_desc->bmAttributes.xfer; + dwc2_depctl_t depctl = {.value = 0}; + depctl.mps = xfer->max_size; + depctl.active = 1; + depctl.type = p_endpoint_desc->bmAttributes.xfer; if (p_endpoint_desc->bmAttributes.xfer != TUSB_XFER_ISOCHRONOUS) { - depctl.bm.set_data0_iso_even = 1; + depctl.set_data0_iso_even = 1; } if (dir == TUSB_DIR_IN) { - //depctl.bm.tx_fifo_num = epnum; + //depctl.tx_fifo_num = epnum; uint8_t fifo_num = epnum; #if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3) // Special Case for EP5, which is used by CDC but not actually called by the driver @@ -285,7 +285,7 @@ static void edpt_activate(uint8_t rhport, const tusb_desc_endpoint_t* p_endpoint fifo_num = get_free_fifo(); } #endif - depctl.bm.tx_fifo_num = fifo_num; + depctl.tx_fifo_num = fifo_num; } dwc2_dep_t* dep = &dwc2->ep[dir == TUSB_DIR_IN ? 0 : 1][epnum]; @@ -365,31 +365,22 @@ static void edpt_schedule_packets(uint8_t rhport, const uint8_t epnum, const uin } // transfer size: A full OUT transfer (multiple packets, possibly) triggers XFRC. - union { - uint32_t value; - dwc2_ep_tsize_t bm; - } deptsiz; - deptsiz.value = 0; - deptsiz.bm.xfer_size = total_bytes; - deptsiz.bm.packet_count = num_packets; - + dwc2_ep_tsize_t deptsiz = {.value = 0}; + deptsiz.xfer_size = total_bytes; + deptsiz.packet_count = num_packets; dep->tsiz = deptsiz.value; // control - union { - dwc2_depctl_t bm; - uint32_t value; - } depctl; - depctl.value = dep->ctl; - - depctl.bm.clear_nak = 1; - depctl.bm.enable = 1; - if (depctl.bm.type == DEPCTL_EPTYPE_ISOCHRONOUS && xfer->interval == 1) { - const uint32_t odd_now = (dwc2->dsts_bm.frame_number & 1u); + dwc2_depctl_t depctl = {.value = dep->ctl}; + depctl.clear_nak = 1; + depctl.enable = 1; + if (depctl.type == DEPCTL_EPTYPE_ISOCHRONOUS && xfer->interval == 1) { + const dwc2_dsts_t dsts = {.value = dwc2->dsts}; + const uint32_t odd_now = dsts.frame_number & 1u; if (odd_now) { - depctl.bm.set_data0_iso_even = 1; + depctl.set_data0_iso_even = 1; } else { - depctl.bm.set_data1_iso_odd = 1; + depctl.set_data1_iso_odd = 1; } } @@ -432,7 +423,8 @@ bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) { // XCVRDLY: transceiver delay between xcvr_sel and txvalid during device chirp is required // when using with some PHYs such as USB334x (USB3341, USB3343, USB3346, USB3347) - if (dwc2->ghwcfg2_bm.hs_phy_type == GHWCFG2_HSPHY_ULPI) { + const dwc2_ghwcfg2_t ghwcfg2 = {.value = dwc2->ghwcfg2}; + if (ghwcfg2.hs_phy_type == GHWCFG2_HSPHY_ULPI) { dcfg |= DCFG_XCVRDLY; } } else { @@ -667,7 +659,7 @@ void dcd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr) { // 7.4.1 Initialization on USB Reset static void handle_bus_reset(uint8_t rhport) { dwc2_regs_t *dwc2 = DWC2_REG(rhport); - const uint8_t ep_count = DWC2_EP_COUNT(dwc2); + const uint8_t ep_count = dwc2_ep_count(dwc2); tu_memclr(xfer_status, sizeof(xfer_status)); @@ -697,7 +689,9 @@ static void handle_bus_reset(uint8_t rhport) { dfifo_device_init(rhport); // 5. Reset device address - dwc2->dcfg_bm.address = 0; + dwc2_dcfg_t dcfg = {.value = dwc2->dcfg}; + dcfg.address = 0; + dwc2->dcfg = dcfg.value; // Fixed both control EP0 size to 64 bytes dwc2->epin[0].ctl &= ~(0x03 << DIEPCTL_MPSIZ_Pos); @@ -717,8 +711,9 @@ static void handle_bus_reset(uint8_t rhport) { static void handle_enum_done(uint8_t rhport) { dwc2_regs_t *dwc2 = DWC2_REG(rhport); + const dwc2_dsts_t dsts = {.value = dwc2->dsts}; tusb_speed_t speed; - switch (dwc2->dsts_bm.enum_speed) { + switch (dsts.enum_speed) { case DCFG_SPEED_HIGH: speed = TUSB_SPEED_HIGH; break; @@ -763,12 +758,12 @@ static void handle_rxflvl_irq(uint8_t rhport) { const volatile uint32_t* rx_fifo = dwc2->fifo[0]; // Pop control word off FIFO - const dwc2_grxstsp_t grxstsp_bm = dwc2->grxstsp_bm; - const uint8_t epnum = grxstsp_bm.ep_ch_num; + const dwc2_grxstsp_t grxstsp = {.value = dwc2->grxstsp}; + const uint8_t epnum = grxstsp.ep_ch_num; dwc2_dep_t* epout = &dwc2->epout[epnum]; - switch (grxstsp_bm.packet_status) { + switch (grxstsp.packet_status) { case GRXSTS_PKTSTS_GLOBAL_OUT_NAK: // Global OUT NAK: do nothing break; @@ -790,7 +785,7 @@ static void handle_rxflvl_irq(uint8_t rhport) { case GRXSTS_PKTSTS_RX_DATA: { // Out packet received - const uint16_t byte_count = grxstsp_bm.byte_count; + const uint16_t byte_count = grxstsp.byte_count; xfer_ctl_t* xfer = XFER_CTL_BASE(epnum, TUSB_DIR_OUT); if (byte_count) { @@ -804,7 +799,8 @@ static void handle_rxflvl_irq(uint8_t rhport) { // short packet, minus remaining bytes (xfer_size) if (byte_count < xfer->max_size) { - xfer->total_len -= epout->tsiz_bm.xfer_size; + const dwc2_ep_tsize_t tsiz = {.value = epout->tsiz}; + xfer->total_len -= tsiz.xfer_size; if (epnum == 0) { xfer->total_len -= _dcd_data.ep0_pending[TUSB_DIR_OUT]; _dcd_data.ep0_pending[TUSB_DIR_OUT] = 0; @@ -866,11 +862,13 @@ static void handle_epin_slave(uint8_t rhport, uint8_t epnum, dwc2_diepint_t diep // - 64 bytes or // - Half/Empty of TX FIFO size (configured by GAHBCFG.TXFELVL) if (diepint_bm.txfifo_empty && (dwc2->diepempmsk & (1 << epnum))) { - const uint16_t remain_packets = epin->tsiz_bm.packet_count; + dwc2_ep_tsize_t tsiz = {.value = epin->tsiz}; + const uint16_t remain_packets = tsiz.packet_count; // Process every single packet (only whole packets can be written to fifo) for (uint16_t i = 0; i < remain_packets; i++) { - const uint16_t remain_bytes = (uint16_t) epin->tsiz_bm.xfer_size; + tsiz.value = epin->tsiz; + const uint16_t remain_bytes = (uint16_t) tsiz.xfer_size; const uint16_t xact_bytes = tu_min16(remain_bytes, xfer->max_size); // Check if dtxfsts has enough space available @@ -889,7 +887,8 @@ static void handle_epin_slave(uint8_t rhport, uint8_t epnum, dwc2_diepint_t diep } // Turn off TXFE if all bytes are written. - if (epin->tsiz_bm.xfer_size == 0) { + tsiz.value = epin->tsiz; + if (tsiz.xfer_size == 0) { dwc2->diepempmsk &= ~(1 << epnum); } } @@ -920,7 +919,8 @@ static void handle_epout_dma(uint8_t rhport, uint8_t epnum, dwc2_doepint_t doepi xfer_ctl_t* xfer = XFER_CTL_BASE(epnum, TUSB_DIR_OUT); // determine actual received bytes - const uint16_t remain = epout->tsiz_bm.xfer_size; + const dwc2_ep_tsize_t tsiz = {.value = epout->tsiz}; + const uint16_t remain = tsiz.xfer_size; xfer->total_len -= remain; // this is ZLP, so prepare EP0 for next setup @@ -956,7 +956,7 @@ static void handle_epin_dma(uint8_t rhport, uint8_t epnum, dwc2_diepint_t diepin static void handle_ep_irq(uint8_t rhport, uint8_t dir) { dwc2_regs_t* dwc2 = DWC2_REG(rhport); const bool is_dma = dma_device_enabled(dwc2); - const uint8_t ep_count = DWC2_EP_COUNT(dwc2); + const uint8_t ep_count = dwc2_ep_count(dwc2); const uint8_t daint_offset = (dir == TUSB_DIR_IN) ? DAINT_IEPINT_Pos : DAINT_OEPINT_Pos; dwc2_dep_t* ep_base = &dwc2->ep[dir == TUSB_DIR_IN ? 0 : 1][0]; From 8afd7916b705caa6dd540b8980717b028672e0f2 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Tue, 15 Apr 2025 19:02:58 +0200 Subject: [PATCH 17/22] Update dcd_dwc2.patch --- components/arduino_tinyusb/patches/dcd_dwc2.patch | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/arduino_tinyusb/patches/dcd_dwc2.patch b/components/arduino_tinyusb/patches/dcd_dwc2.patch index 11c1c05c0..14e6975f0 100755 --- a/components/arduino_tinyusb/patches/dcd_dwc2.patch +++ b/components/arduino_tinyusb/patches/dcd_dwc2.patch @@ -19,11 +19,11 @@ dwc2_regs_t* dwc2 = DWC2_REG(rhport); const uint8_t epnum = tu_edpt_number(p_endpoint_desc->bEndpointAddress); @@ -266,7 +277,18 @@ - depctl.bm.set_data0_iso_even = 1; + depctl.set_data0_iso_even = 1; } if (dir == TUSB_DIR_IN) { -- depctl.bm.tx_fifo_num = epnum; -+ //depctl.bm.tx_fifo_num = epnum; +- depctl.tx_fifo_num = epnum; ++ //depctl.tx_fifo_num = epnum; + uint8_t fifo_num = epnum; +#if TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3) + // Special Case for EP5, which is used by CDC but not actually called by the driver @@ -34,7 +34,7 @@ + fifo_num = get_free_fifo(); + } +#endif -+ depctl.bm.tx_fifo_num = fifo_num; ++ depctl.tx_fifo_num = fifo_num; } dwc2_dep_t* dep = &dwc2->ep[dir == TUSB_DIR_IN ? 0 : 1][epnum]; From 3decbdef0198d02aa3fa03cdab30de661250a9b6 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 28 Apr 2025 16:21:44 +0200 Subject: [PATCH 18/22] remove duplicate entry --- configs/defconfig.esp32 | 1 - 1 file changed, 1 deletion(-) diff --git a/configs/defconfig.esp32 b/configs/defconfig.esp32 index 92f4dbe4e..22d811b0e 100644 --- a/configs/defconfig.esp32 +++ b/configs/defconfig.esp32 @@ -33,7 +33,6 @@ CONFIG_ETH_USE_SPI_ETHERNET=y CONFIG_SPIRAM=y CONFIG_SPIRAM_OCCUPY_HSPI_HOST=y -CONFIG_ULP_COPROC_ENABLED=y # CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1 is not set # CONFIG_UNITY_ENABLE_FLOAT is not set # CONFIG_UNITY_ENABLE_DOUBLE is not set From d9c48c1eff41630b736ab4cb662df88005a2b384 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 4 May 2025 18:57:29 +0200 Subject: [PATCH 19/22] CONFIG_MBEDTLS_SHA1_C=y --- configs/defconfig.common | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/defconfig.common b/configs/defconfig.common index f9f8d05e6..fe0ff7736 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -178,6 +178,7 @@ CONFIG_MBEDTLS_ECP_C=y CONFIG_MBEDTLS_ECDH_C=y CONFIG_MBEDTLS_ECDSA_C=y CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y +CONFIG_MBEDTLS_SHA1_C=y # CONFIG_MBEDTLS_DHM_C is not set # CONFIG_MBEDTLS_ECJPAKE_C is not set # CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS is not set From bcb0b54383a97a603a4e31510ed70134ecf63f8b Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 4 May 2025 22:45:32 +0200 Subject: [PATCH 20/22] Fix compile error sha1 --- configs/defconfig.common | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/configs/defconfig.common b/configs/defconfig.common index fe0ff7736..ae30e71f4 100644 --- a/configs/defconfig.common +++ b/configs/defconfig.common @@ -158,7 +158,7 @@ CONFIG_MBEDTLS_ROM_MD5=y CONFIG_MBEDTLS_HARDWARE_ECC=y CONFIG_MBEDTLS_HARDWARE_AES=y CONFIG_MBEDTLS_HARDWARE_MPI=y -CONFIG_MBEDTLS_HARDWARE_SHA=y +# CONFIG_MBEDTLS_HARDWARE_SHA is not set # CONFIG_MBEDTLS_ECC_OTHER_CURVES_SOFT_FALLBACK is not set # CONFIG_MBEDTLS_HAVE_TIME is not set # CONFIG_MBEDTLS_ECDSA_DETERMINISTIC is not set @@ -178,7 +178,8 @@ CONFIG_MBEDTLS_ECP_C=y CONFIG_MBEDTLS_ECDH_C=y CONFIG_MBEDTLS_ECDSA_C=y CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y -CONFIG_MBEDTLS_SHA1_C=y +# CONFIG_MBEDTLS_SHA1_C is not set +# CONFIG_MBEDTLS_SHA1_ALT is not set # CONFIG_MBEDTLS_DHM_C is not set # CONFIG_MBEDTLS_ECJPAKE_C is not set # CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS is not set From 960d4c43ce841a64497380577ac6c7adfaf67670 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 12 May 2025 12:27:09 +0200 Subject: [PATCH 21/22] better IDF commit checkout handling --- tools/install-esp-idf.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/install-esp-idf.sh b/tools/install-esp-idf.sh index f79f5c7f9..5db354e62 100755 --- a/tools/install-esp-idf.sh +++ b/tools/install-esp-idf.sh @@ -52,7 +52,14 @@ if [ "$IDF_TAG" ]; then git -C "$IDF_PATH" checkout "tags/$IDF_TAG" idf_was_installed="1" elif [ "$IDF_COMMIT" ]; then + cd $IDF_PATH git -C "$IDF_PATH" checkout "$IDF_COMMIT" + git reset --hard $IDF_COMMIT + git submodule update --recursive + git rm -r $IDF_PATH/components/wifi_provisioning + git rm -r $IDF_PATH/components/spiffs + git commit -m "delete components SPIFFS and wifi-provisioning" + cd - commit_predefined="1" fi From 7ef5f9ca03315e705d54f4dbcbdc2f3005c874ec Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Mon, 12 May 2025 12:36:39 +0200 Subject: [PATCH 22/22] Update install-esp-idf.sh --- tools/install-esp-idf.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/install-esp-idf.sh b/tools/install-esp-idf.sh index 5db354e62..16b827060 100755 --- a/tools/install-esp-idf.sh +++ b/tools/install-esp-idf.sh @@ -49,7 +49,14 @@ else fi if [ "$IDF_TAG" ]; then + cd $IDF_PATH git -C "$IDF_PATH" checkout "tags/$IDF_TAG" + git reset --hard "tags/$IDF_TAG" + git submodule update --recursive + git rm -r $IDF_PATH/components/wifi_provisioning + git rm -r $IDF_PATH/components/spiffs + git commit -m "delete components SPIFFS and wifi-provisioning" + cd - idf_was_installed="1" elif [ "$IDF_COMMIT" ]; then cd $IDF_PATH