From 973cd4bc4563f1a7136461f3b66abe9cfbabdf94 Mon Sep 17 00:00:00 2001 From: eightycc Date: Wed, 16 Apr 2025 15:35:48 -0700 Subject: [PATCH 01/16] Upgrade ESP-IDF v5.3.2 to v5.4.1. --- .gitmodules | 4 ++-- ports/espressif/Makefile | 3 +++ ports/espressif/esp-idf | 2 +- ports/espressif/mphalport.c | 20 +------------------- ports/espressif/supervisor/usb.c | 10 +--------- 5 files changed, 8 insertions(+), 31 deletions(-) diff --git a/.gitmodules b/.gitmodules index f52ca8e7fa756..f297dae584738 100644 --- a/.gitmodules +++ b/.gitmodules @@ -142,8 +142,8 @@ url = https://github.com/adafruit/Adafruit_CircuitPython_RFM69.git [submodule "ports/espressif/esp-idf"] path = ports/espressif/esp-idf - url = https://github.com/adafruit/esp-idf.git - branch = circuitpython-v5.3.2 + url = https://github.com/eightycc/esp-idf.git + branch = circuitpython-v5.4.1 [submodule "ports/espressif/esp-protocols"] path = ports/espressif/esp-protocols url = https://github.com/adafruit/esp-protocols.git diff --git a/ports/espressif/Makefile b/ports/espressif/Makefile index ea6b91fdf4ca6..def6ab10dcff8 100644 --- a/ports/espressif/Makefile +++ b/ports/espressif/Makefile @@ -83,6 +83,8 @@ INC += \ -isystem esp-idf/components/esp_psram/include \ -isystem esp-idf/components/esp_ringbuf/include \ -isystem esp-idf/components/esp_rom/include \ + -isystem esp-idf/components/esp_rom/$(IDF_TARGET)/include \ + -isystem esp-idf/components/esp_rom/$(IDF_TARGET)/include/$(IDF_TARGET) \ -isystem esp-idf/components/esp_system/include \ -isystem esp-idf/components/esp_timer/include \ -isystem esp-idf/components/esp_wifi/include \ @@ -115,6 +117,7 @@ INC += \ -isystem esp-idf/components/sdmmc/include \ -isystem esp-idf/components/soc/include \ -isystem esp-idf/components/soc/$(IDF_TARGET)/include \ + -isystem esp-idf/components/soc/$(IDF_TARGET)/register \ -isystem esp-idf/components/spi_flash/include \ -isystem esp-idf/components/usb/include \ -isystem esp-idf/components/ulp/ulp_fsm/include \ diff --git a/ports/espressif/esp-idf b/ports/espressif/esp-idf index f388200aba738..4c2820d377d13 160000 --- a/ports/espressif/esp-idf +++ b/ports/espressif/esp-idf @@ -1 +1 @@ -Subproject commit f388200aba73826b9039be6f4fb5385c6b7136c6 +Subproject commit 4c2820d377d1375e787bcef612f0c32c1427d183 diff --git a/ports/espressif/mphalport.c b/ports/espressif/mphalport.c index 87b16ac3e4ca1..d6a7ef1bfce41 100644 --- a/ports/espressif/mphalport.c +++ b/ports/espressif/mphalport.c @@ -8,25 +8,7 @@ #include "py/mphal.h" #include "supervisor/cpu.h" -#if defined(CONFIG_IDF_TARGET_ESP32) -#include "components/esp_rom/include/esp32/rom/ets_sys.h" -#elif defined(CONFIG_IDF_TARGET_ESP32C2) -#include "components/esp_rom/include/esp32c2/rom/ets_sys.h" -#elif defined(CONFIG_IDF_TARGET_ESP32P4) -#include "components/esp_rom/include/esp32p4/rom/ets_sys.h" -#elif defined(CONFIG_IDF_TARGET_ESP32C3) -#include "components/esp_rom/include/esp32c3/rom/ets_sys.h" -#elif defined(CONFIG_IDF_TARGET_ESP32C6) -#include "components/esp_rom/include/esp32c6/rom/ets_sys.h" -#elif defined(CONFIG_IDF_TARGET_ESP32H2) -#include "components/esp_rom/include/esp32h2/rom/ets_sys.h" -#elif defined(CONFIG_IDF_TARGET_ESP32S2) -#include "components/esp_rom/include/esp32s2/rom/ets_sys.h" -#elif defined(CONFIG_IDF_TARGET_ESP32S3) -#include "components/esp_rom/include/esp32s3/rom/ets_sys.h" -#else -#error Unknown CONFIG_IDF_TARGET_xxx -#endif +#include "rom/ets_sys.h" #include "esp_attr.h" diff --git a/ports/espressif/supervisor/usb.c b/ports/espressif/supervisor/usb.c index c2bf90b21b1f4..612abaa808ae2 100644 --- a/ports/espressif/supervisor/usb.c +++ b/ports/espressif/supervisor/usb.c @@ -20,15 +20,7 @@ #include "driver/gpio.h" #include "esp_private/periph_ctrl.h" -#if defined(CONFIG_IDF_TARGET_ESP32C3) -#include "components/esp_rom/include/esp32c3/rom/gpio.h" -#elif defined(CONFIG_IDF_TARGET_ESP32C6) -#include "components/esp_rom/include/esp32c6/rom/gpio.h" -#elif defined(CONFIG_IDF_TARGET_ESP32S2) -#include "components/esp_rom/include/esp32s2/rom/gpio.h" -#elif defined(CONFIG_IDF_TARGET_ESP32S3) -#include "components/esp_rom/include/esp32s3/rom/gpio.h" -#endif +#include "rom/gpio.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" From 94f1ec6523e0e87287f21877c4ac414a3b0821e1 Mon Sep 17 00:00:00 2001 From: eightycc Date: Wed, 16 Apr 2025 15:44:03 -0700 Subject: [PATCH 02/16] Get updated ESP-IDF branch circuitpython-v5.4.1. --- ports/espressif/esp-idf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/espressif/esp-idf b/ports/espressif/esp-idf index 4c2820d377d13..8a8c214ea69e7 160000 --- a/ports/espressif/esp-idf +++ b/ports/espressif/esp-idf @@ -1 +1 @@ -Subproject commit 4c2820d377d1375e787bcef612f0c32c1427d183 +Subproject commit 8a8c214ea69e72ea5a5e6152ffbf66afb2affcae From 45b8f76fe3d88b553648130ec945e63802572dd2 Mon Sep 17 00:00:00 2001 From: eightycc Date: Thu, 17 Apr 2025 07:02:46 -0700 Subject: [PATCH 03/16] ESP-IDF 5.4.1 update: Add esp_security component, fixup flash spi clock speed settings. --- ports/espressif/Makefile | 3 ++- ports/espressif/esp-idf | 2 +- .../esp-idf-config/sdkconfig-flash-120m.defaults | 13 ------------- .../esp-idf-config/sdkconfig-flash-40m.defaults | 13 ------------- .../esp-idf-config/sdkconfig-flash-48m.defaults | 13 ------------- .../esp-idf-config/sdkconfig-flash-60m.defaults | 13 ------------- .../esp-idf-config/sdkconfig-flash-80m.defaults | 13 ------------- 7 files changed, 3 insertions(+), 67 deletions(-) diff --git a/ports/espressif/Makefile b/ports/espressif/Makefile index def6ab10dcff8..927906d5a0f2d 100644 --- a/ports/espressif/Makefile +++ b/ports/espressif/Makefile @@ -85,6 +85,7 @@ INC += \ -isystem esp-idf/components/esp_rom/include \ -isystem esp-idf/components/esp_rom/$(IDF_TARGET)/include \ -isystem esp-idf/components/esp_rom/$(IDF_TARGET)/include/$(IDF_TARGET) \ + -isystem esp-idf/components/esp_security/include \ -isystem esp-idf/components/esp_system/include \ -isystem esp-idf/components/esp_timer/include \ -isystem esp-idf/components/esp_wifi/include \ @@ -597,7 +598,7 @@ endif ESP_IDF_COMPONENTS_LINK = $(IDF_TARGET_ARCH) $(CHIP_COMPONENTS) app_update bootloader_support driver esp_driver_gpio esp_driver_gptimer esp_driver_i2c esp_driver_ledc esp_driver_spi esp_driver_uart efuse esp_adc esp_app_format esp_common esp_event esp_hw_support esp_mm esp_partition esp_pm esp_ringbuf esp_rom esp_system esp_timer freertos hal heap log newlib nvs_flash pthread soc spi_flash vfs esp_vfs_console ifneq ($(CIRCUITPY_WIFI),0) - ESP_IDF_COMPONENTS_LINK += esp_coex esp_netif esp-tls esp_wifi lwip mbedtls mdns wpa_supplicant esp_phy + ESP_IDF_COMPONENTS_LINK += esp_coex esp_netif esp_security esp-tls esp_wifi lwip mbedtls mdns wpa_supplicant esp_phy endif ifneq ($(CIRCUITPY_BLEIO_NATIVE),0) BLE_IMPL_esp32 := esp32 diff --git a/ports/espressif/esp-idf b/ports/espressif/esp-idf index 8a8c214ea69e7..e6c5c73c5b6ca 160000 --- a/ports/espressif/esp-idf +++ b/ports/espressif/esp-idf @@ -1 +1 @@ -Subproject commit 8a8c214ea69e72ea5a5e6152ffbf66afb2affcae +Subproject commit e6c5c73c5b6caa552c56e724facb3faa596e3022 diff --git a/ports/espressif/esp-idf-config/sdkconfig-flash-120m.defaults b/ports/espressif/esp-idf-config/sdkconfig-flash-120m.defaults index fadf55d8d7966..6a2285a2936aa 100644 --- a/ports/espressif/esp-idf-config/sdkconfig-flash-120m.defaults +++ b/ports/espressif/esp-idf-config/sdkconfig-flash-120m.defaults @@ -1,15 +1,2 @@ CONFIG_ESPTOOLPY_FLASHFREQ_120M=y -# CONFIG_ESPTOOLPY_FLASHFREQ_80M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_64M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_60M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_48M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_40M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_32M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_30M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_26M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_24M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_20M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_16M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_15M is not set -CONFIG_ESPTOOLPY_FLASHFREQ_80M_DEFAULT=y CONFIG_SPI_FLASH_UNDER_HIGH_FREQ=y diff --git a/ports/espressif/esp-idf-config/sdkconfig-flash-40m.defaults b/ports/espressif/esp-idf-config/sdkconfig-flash-40m.defaults index 235a62a57ee0a..ffc4b5c1cb8fe 100644 --- a/ports/espressif/esp-idf-config/sdkconfig-flash-40m.defaults +++ b/ports/espressif/esp-idf-config/sdkconfig-flash-40m.defaults @@ -1,14 +1 @@ -# CONFIG_ESPTOOLPY_FLASHFREQ_120M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_80M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_64M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_60M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_48M is not set CONFIG_ESPTOOLPY_FLASHFREQ_40M=y -# CONFIG_ESPTOOLPY_FLASHFREQ_32M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_30M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_26M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_24M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_20M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_16M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_15M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_80M_DEFAULT is not set diff --git a/ports/espressif/esp-idf-config/sdkconfig-flash-48m.defaults b/ports/espressif/esp-idf-config/sdkconfig-flash-48m.defaults index b710fd22554e1..f6838e88703b7 100644 --- a/ports/espressif/esp-idf-config/sdkconfig-flash-48m.defaults +++ b/ports/espressif/esp-idf-config/sdkconfig-flash-48m.defaults @@ -1,14 +1 @@ -# CONFIG_ESPTOOLPY_FLASHFREQ_120M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_80M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_64M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_60M is not set CONFIG_ESPTOOLPY_FLASHFREQ_48M=y -# CONFIG_ESPTOOLPY_FLASHFREQ_40M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_32M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_30M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_26M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_24M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_20M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_16M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_15M is not set -CONFIG_ESPTOOLPY_FLASHFREQ_48M_DEFAULT=y diff --git a/ports/espressif/esp-idf-config/sdkconfig-flash-60m.defaults b/ports/espressif/esp-idf-config/sdkconfig-flash-60m.defaults index 7068d0ce74082..797665f527fb9 100644 --- a/ports/espressif/esp-idf-config/sdkconfig-flash-60m.defaults +++ b/ports/espressif/esp-idf-config/sdkconfig-flash-60m.defaults @@ -1,14 +1 @@ -# CONFIG_ESPTOOLPY_FLASHFREQ_120M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_80M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_64M is not set CONFIG_ESPTOOLPY_FLASHFREQ_60M=y -# CONFIG_ESPTOOLPY_FLASHFREQ_48M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_40M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_32M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_30M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_26M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_24M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_20M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_16M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_15M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_80M_DEFAULT is not set diff --git a/ports/espressif/esp-idf-config/sdkconfig-flash-80m.defaults b/ports/espressif/esp-idf-config/sdkconfig-flash-80m.defaults index 2ea4419003797..7014fa95495b2 100644 --- a/ports/espressif/esp-idf-config/sdkconfig-flash-80m.defaults +++ b/ports/espressif/esp-idf-config/sdkconfig-flash-80m.defaults @@ -1,14 +1 @@ -# CONFIG_ESPTOOLPY_FLASHFREQ_120M is not set CONFIG_ESPTOOLPY_FLASHFREQ_80M=y -# CONFIG_ESPTOOLPY_FLASHFREQ_64M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_60M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_48M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_40M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_32M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_30M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_26M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_24M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_20M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_16M is not set -# CONFIG_ESPTOOLPY_FLASHFREQ_15M is not set -CONFIG_ESPTOOLPY_FLASHFREQ_80M_DEFAULT=y From 521fb5ac117798bdf4665193b61e0b5277ba7634 Mon Sep 17 00:00:00 2001 From: eightycc Date: Thu, 17 Apr 2025 11:38:39 -0700 Subject: [PATCH 04/16] Workaround ESP-IDF issue #15035. --- .github/actions/deps/ports/espressif/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/deps/ports/espressif/action.yml b/.github/actions/deps/ports/espressif/action.yml index 122940bb95a1e..25965eb7ef040 100644 --- a/.github/actions/deps/ports/espressif/action.yml +++ b/.github/actions/deps/ports/espressif/action.yml @@ -7,6 +7,7 @@ runs: run: | echo >> $GITHUB_ENV "IDF_PATH=$GITHUB_WORKSPACE/ports/espressif/esp-idf" echo >> $GITHUB_ENV "IDF_TOOLS_PATH=$GITHUB_WORKSPACE/.idf_tools" + echo >> $GITHUB_ENV "ESP_ROM_ELF_DIR=$GITHUB_WORKSPACE/.idf_tools" shell: bash - name: Get IDF commit From f834b771af20d8b59784caa6f5a7aa04dbd1d48b Mon Sep 17 00:00:00 2001 From: eightycc Date: Thu, 17 Apr 2025 12:55:21 -0700 Subject: [PATCH 05/16] Update ESP32 MSPI IOMUX pin names. --- ports/espressif/supervisor/port.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/espressif/supervisor/port.c b/ports/espressif/supervisor/port.c index b84b2c49a3182..2217cf503dc8a 100644 --- a/ports/espressif/supervisor/port.c +++ b/ports/espressif/supervisor/port.c @@ -190,8 +190,8 @@ static void _never_reset_spi_ram_flash(void) { const uint32_t spiconfig = esp_rom_efuse_get_flash_gpio_info(); if (spiconfig == ESP_ROM_EFUSE_FLASH_DEFAULT_SPI) { - never_reset_pin_number(SPI_IOMUX_PIN_NUM_CLK); - never_reset_pin_number(SPI_IOMUX_PIN_NUM_CS); + never_reset_pin_number(MSPI_IOMUX_PIN_NUM_CLK); + never_reset_pin_number(MSPI_IOMUX_PIN_NUM_CS0); never_reset_pin_number(PSRAM_SPIQ_SD0_IO); never_reset_pin_number(PSRAM_SPID_SD1_IO); never_reset_pin_number(PSRAM_SPIWP_SD3_IO); From 010b8a2b5a15f8430f28d568443fc98f922edab4 Mon Sep 17 00:00:00 2001 From: eightycc Date: Fri, 18 Apr 2025 06:45:58 -0700 Subject: [PATCH 06/16] Update esp-idf with cherry-picked commit 793e394 to resolve missing __atomic_test_and_set. --- ports/espressif/esp-idf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/espressif/esp-idf b/ports/espressif/esp-idf index e6c5c73c5b6ca..f50ec8ecdb31f 160000 --- a/ports/espressif/esp-idf +++ b/ports/espressif/esp-idf @@ -1 +1 @@ -Subproject commit e6c5c73c5b6caa552c56e724facb3faa596e3022 +Subproject commit f50ec8ecdb31f681e6a778f145de95f849c1089d From c127f661a2dbec775ca247bf9961c0943dcd151e Mon Sep 17 00:00:00 2001 From: eightycc Date: Fri, 18 Apr 2025 07:21:22 -0700 Subject: [PATCH 07/16] Add ESP-IDF component esp_security for BLE-only parts. --- ports/espressif/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/espressif/Makefile b/ports/espressif/Makefile index 927906d5a0f2d..6c320f648efb1 100644 --- a/ports/espressif/Makefile +++ b/ports/espressif/Makefile @@ -609,7 +609,7 @@ ifneq ($(CIRCUITPY_BLEIO_NATIVE),0) BLE_IMPL_esp32h2 := libble BLE_IMPL = $(BLE_IMPL_$(IDF_TARGET)) - ESP_IDF_COMPONENTS_LINK += bt esp_phy + ESP_IDF_COMPONENTS_LINK += bt esp_phy esp_security ifeq ($(BLE_IMPL),esp32) # BLE will hang the ESP32 and trigger an interrupt watchdog without this undefined symbol at # link because a weak version of the interrupt that BLE uses will be linked incorrectly. From 7cc3f10f1e209b1738f2377d3735639b8d0803db Mon Sep 17 00:00:00 2001 From: eightycc Date: Fri, 18 Apr 2025 09:43:36 -0700 Subject: [PATCH 08/16] Remove CIRCUITPY_ESPCAMERA from ESP32-S2 to free up DRAM. --- ports/espressif/mpconfigport.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ports/espressif/mpconfigport.mk b/ports/espressif/mpconfigport.mk index 31522795a165a..a2a2ec7894d3f 100644 --- a/ports/espressif/mpconfigport.mk +++ b/ports/espressif/mpconfigport.mk @@ -250,6 +250,9 @@ CIRCUITPY_AUDIOIO = 1 # No BLE in hw CIRCUITPY_BLEIO_NATIVE = 0 +# Not enough DRAM for this with ESP-IDF 5.4.1 +CIRCUITPY_ESPCAMERA = 0 + # No SDMMC CIRCUITPY_SDIOIO = 0 From bdbd4af809191f2a2c5d2871adeb9dc97e81aeeb Mon Sep 17 00:00:00 2001 From: eightycc Date: Fri, 18 Apr 2025 10:24:29 -0700 Subject: [PATCH 09/16] Add ESP-IDF component esp_security to ESP32-P4. --- ports/espressif/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ports/espressif/Makefile b/ports/espressif/Makefile index 6c320f648efb1..3a07cc5438e2e 100644 --- a/ports/espressif/Makefile +++ b/ports/espressif/Makefile @@ -631,6 +631,9 @@ ifneq ($(CIRCUITPY_BLEIO_NATIVE),0) endif endif endif +ifeq ($(IDF_TARGET),esp32p4) + ESP_IDF_COMPONENTS_LINK += esp_security +endif ifneq ($(CIRCUITPY_ESPULP),0) ESP_IDF_COMPONENTS_LINK += ulp endif From 06d9ff4ec9853ca608dfc3ff0226a755d931cafb Mon Sep 17 00:00:00 2001 From: eightycc Date: Fri, 18 Apr 2025 11:24:46 -0700 Subject: [PATCH 10/16] Temporarily remove ULAB from ESP32-C6 to avoid flash overflow. --- ports/espressif/mpconfigport.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ports/espressif/mpconfigport.mk b/ports/espressif/mpconfigport.mk index a2a2ec7894d3f..549bf8698808a 100644 --- a/ports/espressif/mpconfigport.mk +++ b/ports/espressif/mpconfigport.mk @@ -184,6 +184,9 @@ CIRCUITPY_TOUCHIO_USE_NATIVE = 0 CIRCUITPY_USB_DEVICE = 0 CIRCUITPY_ESP_USB_SERIAL_JTAG ?= 1 +# Remove temporarily until 10265 is merged +CIRCUITPY_ULAB = 0 + else ifeq ($(IDF_TARGET),esp32h2) # Modules CIRCUITPY_ESPCAMERA = 0 From 22519d88b8e88f28a0cd3cf8d808ed4867332407 Mon Sep 17 00:00:00 2001 From: eightycc Date: Sat, 19 Apr 2025 09:13:00 -0700 Subject: [PATCH 11/16] Restore ESP_CAMERA to ESP32-S2, resolve dram overflow by specifying CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH. --- ports/espressif/esp-idf-config/sdkconfig-esp32s2.defaults | 6 ++++++ ports/espressif/mpconfigport.mk | 3 --- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ports/espressif/esp-idf-config/sdkconfig-esp32s2.defaults b/ports/espressif/esp-idf-config/sdkconfig-esp32s2.defaults index 66e06667a1a81..5c748bd0e6f02 100644 --- a/ports/espressif/esp-idf-config/sdkconfig-esp32s2.defaults +++ b/ports/espressif/esp-idf-config/sdkconfig-esp32s2.defaults @@ -58,6 +58,12 @@ CONFIG_ULP_COPROC_TYPE_RISCV=y # Note: enabling both ULPs simultaneously only w CONFIG_ULP_COPROC_RESERVE_MEM=8176 # end of Ultra Low Power (ULP) Co-processor +# +# FreeRTOS +# +CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y +# end of FreeRTOS + # end of Component config # end of Espressif IoT Development Framework Configuration diff --git a/ports/espressif/mpconfigport.mk b/ports/espressif/mpconfigport.mk index 549bf8698808a..d7037fa5217ef 100644 --- a/ports/espressif/mpconfigport.mk +++ b/ports/espressif/mpconfigport.mk @@ -253,9 +253,6 @@ CIRCUITPY_AUDIOIO = 1 # No BLE in hw CIRCUITPY_BLEIO_NATIVE = 0 -# Not enough DRAM for this with ESP-IDF 5.4.1 -CIRCUITPY_ESPCAMERA = 0 - # No SDMMC CIRCUITPY_SDIOIO = 0 From aeb5bacc566ead1da1b3df76cca9101e1a704b74 Mon Sep 17 00:00:00 2001 From: eightycc Date: Thu, 24 Apr 2025 09:25:07 -0700 Subject: [PATCH 12/16] Remove *.rom.newlib-time.ld from link of esp32, esp32c3, and esp32s2 to resolve newlib stat struct mismatch. --- ports/espressif/Makefile | 3 --- 1 file changed, 3 deletions(-) diff --git a/ports/espressif/Makefile b/ports/espressif/Makefile index 3a07cc5438e2e..7806e6be28275 100644 --- a/ports/espressif/Makefile +++ b/ports/espressif/Makefile @@ -242,7 +242,6 @@ ifeq ($(IDF_TARGET),esp32) LDFLAGS += \ -Tesp32.rom.newlib-data.ld \ -Tesp32.rom.newlib-funcs.ld \ - -Tesp32.rom.newlib-time.ld \ -Tesp32.rom.spiflash_legacy.ld CHIP_COMPONENTS = \ @@ -265,7 +264,6 @@ CHIP_COMPONENTS = \ else ifeq ($(IDF_TARGET),esp32c3) LDFLAGS += \ -Tesp32c3.rom.newlib.ld \ - -Tesp32c3.rom.newlib-time.ld \ -Tesp32c3.rom.version.ld \ -Tesp32c3.rom.eco3.ld \ -Tesp32c3.rom.bt_funcs.ld @@ -312,7 +310,6 @@ else ifeq ($(IDF_TARGET),esp32s2) LDFLAGS += \ -Tesp32s2.rom.newlib-data.ld \ -Tesp32s2.rom.newlib-funcs.ld \ - -Tesp32s2.rom.newlib-time.ld \ -Tesp32s2.rom.spiflash_legacy.ld CHIP_COMPONENTS = \ From 1942d5ebd7641ee7e809f657b6eb6406feb326c4 Mon Sep 17 00:00:00 2001 From: eightycc Date: Thu, 24 Apr 2025 10:17:25 -0700 Subject: [PATCH 13/16] Temporarily disable CIRCUITPY_CANIO for mixgo_ce_udisk board to work around flash overflow for ru translation. --- ports/espressif/boards/mixgo_ce_udisk/mpconfigboard.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/espressif/boards/mixgo_ce_udisk/mpconfigboard.mk b/ports/espressif/boards/mixgo_ce_udisk/mpconfigboard.mk index 691da625e0358..a6a8cd7fa00eb 100644 --- a/ports/espressif/boards/mixgo_ce_udisk/mpconfigboard.mk +++ b/ports/espressif/boards/mixgo_ce_udisk/mpconfigboard.mk @@ -10,6 +10,7 @@ CIRCUITPY_ESP_FLASH_FREQ = 80m CIRCUITPY_ESP_FLASH_SIZE = 4MB CIRCUITPY_AESIO = 0 +CIRCUITPY_CANIO = 0 CIRCUITPY_CODEOP = 0 CIRCUITPY_ESPCAMERA = 0 From 62d16ce61fdd1ec8cfb0d70a6240ad877c12df21 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 25 Apr 2025 15:14:20 -0400 Subject: [PATCH 14/16] Fix TLS for v5.4.1 update Cert bundle code in lib/mbedtls_config was being used, and assumed the older ESP-IDF internal bundle format, which was changed in ESP-IDF v5.4. Added a wrapper around the ESP-IDF bundle routines, and stopped using the shared bundle code. Also fixed extraneous blank lines in mbedtls logging and removed an extraneous, unused, damaged .h. --- lib/mbedtls_config/mbedtls_config_port.h | 67 --------------------- ports/espressif/Makefile | 14 ++--- ports/espressif/common-hal/ssl/crt_bundle.c | 37 ++++++++++++ shared-module/ssl/SSLSocket.c | 2 +- 4 files changed, 45 insertions(+), 75 deletions(-) delete mode 100644 lib/mbedtls_config/mbedtls_config_port.h create mode 100644 ports/espressif/common-hal/ssl/crt_bundle.c diff --git a/lib/mbedtls_config/mbedtls_config_port.h b/lib/mbedtls_config/mbedtls_config_port.h deleted file mode 100644 index 1752d946529f2..0000000000000 --- a/lib/mbedtls_config/mbedtls_config_port.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2018-2019 Damien P. George - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#ifndef MICROPY_INCLUDED_MBEDTLS_CONFIG_H -#define MICROPY_INCLUDED_MBEDTLS_CONFIG_H - -// If you want to debug MBEDTLS uncomment the following and -// Pass 3 to mbedtls_debug_set_threshold in socket_new -// #define MBEDTLS_DEBUG_C - -// Set mbedtls configuration -#define MBEDTLS_PLATFORM_C -#define MBEDTLS_PLATFORM_MEMORY -#define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS -#define MBEDTLS_DEPRECATED_REMOVED -#define MBEDTLS_ENTROPY_HARDWARE_ALT - -// Enable mbedtls modules -#define MBEDTLS_MD_C -#define MBEDTLS_MD5_C -#define MBEDTLS_SHA1_C -#define MBEDTLS_SHA256_C -#define MBEDTLS_SHA512_C -#undef MBEDTLS_HAVE_TIME_DATE - -<<<<<<<< HEAD:lib/mbedtls_config/mbedtls_config_hashlib.h -// Memory allocation hooks -#include -#include -void *m_tracked_calloc(size_t nmemb, size_t size); -void m_tracked_free(void *ptr); -#define MBEDTLS_PLATFORM_STD_CALLOC m_tracked_calloc -#define MBEDTLS_PLATFORM_STD_FREE m_tracked_free -#define MBEDTLS_PLATFORM_SNPRINTF_MACRO snprintf -======== -// Time hook -#include -time_t rp2_rtctime_seconds(time_t *timer); -#define MBEDTLS_PLATFORM_TIME_MACRO rp2_rtctime_seconds -#define MBEDTLS_PLATFORM_MS_TIME_ALT mbedtls_ms_time ->>>>>>>> v1.23.0:lib/mbedtls_config/mbedtls_config_port.h - -#include "mbedtls/check_config.h" - -#endif /* MICROPY_INCLUDED_MBEDTLS_CONFIG_H */ diff --git a/ports/espressif/Makefile b/ports/espressif/Makefile index 7806e6be28275..09fa76e79fbea 100644 --- a/ports/espressif/Makefile +++ b/ports/espressif/Makefile @@ -175,12 +175,12 @@ ifeq ($(DEBUG), 1) OPTIMIZATION_FLAGS ?= -Og CFLAGS += -DDEBUG endif - # You may want to enable these flags to make setting breakpoints easier. - # CFLAGS += -fno-inline -fno-ipa-sra +# You may want to enable these flags to make setting breakpoints easier. +# CFLAGS += -fno-inline -fno-ipa-sra else CFLAGS += -DNDEBUG - # RISC-V is larger than xtensa - # Use -Os for RISC-V when it overflows +# RISC-V is larger than xtensa +# Use -Os for RISC-V when it overflows ifeq ($(IDF_TARGET_ARCH),riscv) OPTIMIZATION_FLAGS ?= -Os else @@ -384,7 +384,7 @@ SRC_C += \ peripherals/$(IDF_TARGET)/pins.c ifeq ($(CIRCUITPY_SSL),1) -SRC_C += lib/mbedtls_config/crt_bundle.c +SRC_C += common-hal/ssl/crt_bundle.c endif SRC_C += $(wildcard common-hal/espidf/*.c) @@ -608,8 +608,8 @@ ifneq ($(CIRCUITPY_BLEIO_NATIVE),0) ESP_IDF_COMPONENTS_LINK += bt esp_phy esp_security ifeq ($(BLE_IMPL),esp32) - # BLE will hang the ESP32 and trigger an interrupt watchdog without this undefined symbol at - # link because a weak version of the interrupt that BLE uses will be linked incorrectly. +# BLE will hang the ESP32 and trigger an interrupt watchdog without this undefined symbol at +# link because a weak version of the interrupt that BLE uses will be linked incorrectly. REGISTRATION_FUNCTIONS += -u ld_include_hli_vectors_bt BINARY_BLOBS += esp-idf/components/bt/controller/lib_esp32/$(IDF_TARGET)/libbtdm_app.a endif diff --git a/ports/espressif/common-hal/ssl/crt_bundle.c b/ports/espressif/common-hal/ssl/crt_bundle.c new file mode 100644 index 0000000000000..5fce7a42051a0 --- /dev/null +++ b/ports/espressif/common-hal/ssl/crt_bundle.c @@ -0,0 +1,37 @@ +// This file is part of the CircuitPython project: https://circuitpython.org +// +// SPDX-FileCopyrightText: Copyright (c) 2025 Dan Halbert for Adafruit Industries +// +// SPDX-License-Identifier: MIT + +// In ESP-IDF v5.4, Espressif changed the format of the in-flash cert bundle, which +// made lib/mbedtls_config/crt_bundle.c no longer work. Rather than update that, +// just wrap those functions and use the ESP-IDF versions. + +#include "py/mperrno.h" +#include "mbedtls/x509_crt.h" +#include "lib/mbedtls_config/crt_bundle.h" +#include "esp_crt_bundle.h" + +static int convert_esp_err(esp_err_t ret) { + switch (ret) { + case ESP_OK: + return 0; + default: + // Right now esp_crt_bundle.c doesn't return very specific errors. + case ESP_ERR_INVALID_ARG: + return -MP_EINVAL; + } +} + +int crt_bundle_attach(mbedtls_ssl_config *ssl_conf) { + return convert_esp_err(esp_crt_bundle_attach(ssl_conf)); +} + +void crt_bundle_detach(mbedtls_ssl_config *conf) { + esp_crt_bundle_detach(conf); +} + +int crt_bundle_set(const uint8_t *x509_bundle, size_t bundle_size) { + return convert_esp_err(esp_crt_bundle_set(x509_bundle, bundle_size)); +} diff --git a/shared-module/ssl/SSLSocket.c b/shared-module/ssl/SSLSocket.c index 129a48d00d6ee..d04ca3c4603b6 100644 --- a/shared-module/ssl/SSLSocket.c +++ b/shared-module/ssl/SSLSocket.c @@ -37,7 +37,7 @@ static void mbedtls_debug(void *ctx, int level, const char *file, int line, const char *str) { (void)ctx; (void)level; - mp_printf(&mp_plat_print, "DBG:%s:%04d: %s\n", file, line, str); + mp_printf(&mp_plat_print, "DBG:%s:%04d: %s", file, line, str); } #define DEBUG_PRINT(fmt, ...) mp_printf(&mp_plat_print, "DBG:%s:%04d: " fmt "\n", __FILE__, __LINE__,##__VA_ARGS__) #else From d5f89a176009c5087b85056f3e56d9dc6ae97416 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 25 Apr 2025 16:19:48 -0400 Subject: [PATCH 15/16] pre-commit format fix --- ports/espressif/common-hal/ssl/crt_bundle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/espressif/common-hal/ssl/crt_bundle.c b/ports/espressif/common-hal/ssl/crt_bundle.c index 5fce7a42051a0..53a07f4db1b2c 100644 --- a/ports/espressif/common-hal/ssl/crt_bundle.c +++ b/ports/espressif/common-hal/ssl/crt_bundle.c @@ -18,7 +18,7 @@ static int convert_esp_err(esp_err_t ret) { case ESP_OK: return 0; default: - // Right now esp_crt_bundle.c doesn't return very specific errors. + // Right now esp_crt_bundle.c doesn't return very specific errors. case ESP_ERR_INVALID_ARG: return -MP_EINVAL; } From a3ccaf9c683502eb452d40d2e754b6195d654060 Mon Sep 17 00:00:00 2001 From: eightycc Date: Tue, 29 Apr 2025 08:32:58 -0700 Subject: [PATCH 16/16] Switch to Adafruit ESP-IDF repo branch circuitpython-v5.4.1. --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index f297dae584738..315c74241693f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -142,7 +142,7 @@ url = https://github.com/adafruit/Adafruit_CircuitPython_RFM69.git [submodule "ports/espressif/esp-idf"] path = ports/espressif/esp-idf - url = https://github.com/eightycc/esp-idf.git + url = https://github.com/adafruit/esp-idf.git branch = circuitpython-v5.4.1 [submodule "ports/espressif/esp-protocols"] path = ports/espressif/esp-protocols pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy