From 113969922302fa02ed037e54438236739b57efb7 Mon Sep 17 00:00:00 2001 From: Shubham Patil Date: Tue, 1 Aug 2023 19:04:33 +0530 Subject: [PATCH] [ESP32] Update esp-idf to v5.1 release (#28326) * [ESP32] Update esp-idf to v5.1 release * Fix the requirements for v5.1 * Fix the pyparsing version and explaining comment * Update the container image to use the latest one * remove gdbgui from few more places * fixup constraints for pyparsing * Fix kconfig module * Fix the esp32 qemu * Fix freertos path * Fix format specifier in esp32 pigweed logger * Restyled by clang-format * Fix the shell app * Move freertos function from IRAM to flash for chef app * Fixes for building all-clusters-app with Target m5stack. Also, IRAM usage shot up so moved the freertos functions to flash * Changes to fix all-clusters-minimal app * Remove gdbgui references * Changes in lighting-app * Examples supporting display must build for non esp32 targets * Pull in few dram optimizations from temperature app * Reduce the critical logging buffer --------- Co-authored-by: Restyled.io --- .github/workflows/chef.yaml | 4 +- .github/workflows/examples-esp32.yaml | 10 +---- .github/workflows/qemu.yaml | 5 +-- .github/workflows/release_artifacts.yaml | 2 +- config/esp32/components/chip/CMakeLists.txt | 25 +++-------- docs/guides/esp32/setup_idf_chip.md | 42 ++++--------------- .../all-clusters-app/esp32/CMakeLists.txt | 7 ++-- .../esp32/main/CMakeLists.txt | 15 +++++-- .../all-clusters-app/esp32/sdkconfig.defaults | 3 ++ .../esp32/sdkconfig_c3devkit.defaults | 3 ++ .../esp32/sdkconfig_m5stack.defaults | 3 ++ .../esp32/sdkconfig_m5stack_rpc.defaults | 6 +++ .../esp32/CMakeLists.txt | 7 ++-- .../esp32/main/CMakeLists.txt | 13 ++++-- .../esp32/partitions.csv | 4 +- .../esp32/sdkconfig.defaults | 3 ++ .../esp32/sdkconfig_c3devkit.defaults | 3 ++ .../esp32/sdkconfig_m5stack.defaults | 3 ++ .../esp32/sdkconfig_m5stack_rpc.defaults | 6 +++ examples/chef/esp32/sdkconfig.defaults | 3 ++ examples/chef/esp32/sdkconfig_rpc.defaults | 3 ++ examples/common/m5stack-tft/repo | 2 +- .../common/screen-framework/CMakeLists.txt | 8 +++- examples/lighting-app/esp32/CMakeLists.txt | 7 ++-- .../lighting-app/esp32/main/CMakeLists.txt | 16 ++++--- examples/lock-app/esp32/main/CMakeLists.txt | 9 +++- .../esp32/main/CMakeLists.txt | 8 +++- .../pigweed-app/esp32/main/CMakeLists.txt | 8 +++- examples/platform/esp32/PigweedLogger.cpp | 2 +- examples/shell/esp32/main/CMakeLists.txt | 2 +- .../esp32/main/CMakeLists.txt | 8 +++- scripts/setup/constraints.txt | 2 +- scripts/setup/requirements.esp32.txt | 13 +++--- src/test_driver/esp32/main/main_app.cpp | 13 +----- 34 files changed, 143 insertions(+), 125 deletions(-) diff --git a/.github/workflows/chef.yaml b/.github/workflows/chef.yaml index 35d62da349d4f0..76bbb9cf6da05c 100644 --- a/.github/workflows/chef.yaml +++ b/.github/workflows/chef.yaml @@ -54,7 +54,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: ghcr.io/project-chip/chip-build-esp32:1 + image: ghcr.io/project-chip/chip-build-esp32:2 options: --user root steps: @@ -64,8 +64,6 @@ jobs: uses: ./.github/actions/checkout-submodules-and-bootstrap with: platform: esp32 - - name: Fixup GdbGui requirement - run: perl -i -pe 's/^gdbgui==/# gdbgui==/' /opt/espressif/esp-idf/requirements.txt - name: CI Examples ESP32 shell: bash run: | diff --git a/.github/workflows/examples-esp32.yaml b/.github/workflows/examples-esp32.yaml index 99c74c80eb7f27..3757d952b29fda 100644 --- a/.github/workflows/examples-esp32.yaml +++ b/.github/workflows/examples-esp32.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: ghcr.io/project-chip/chip-build-esp32:1 + image: ghcr.io/project-chip/chip-build-esp32:2 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" @@ -46,9 +46,6 @@ jobs: with: platform: esp32 - - name: Fixup GdbGui requirement - run: perl -i -pe 's/^gdbgui==/# gdbgui==/' /opt/espressif/esp-idf/requirements.txt - - name: Set up environment for size reports uses: ./.github/actions/setup-size-reports if: ${{ !env.ACT }} @@ -130,7 +127,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: ghcr.io/project-chip/chip-build-esp32:1 + image: ghcr.io/project-chip/chip-build-esp32:2 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" @@ -142,9 +139,6 @@ jobs: with: platform: esp32 - - name: Fixup GdbGui requirement - run: perl -i -pe 's/^gdbgui==/# gdbgui==/' /opt/espressif/esp-idf/requirements.txt - - name: Build example Bridge App run: scripts/examples/esp_example.sh bridge-app diff --git a/.github/workflows/qemu.yaml b/.github/workflows/qemu.yaml index 078b4dd960c679..13badfcf8340b6 100644 --- a/.github/workflows/qemu.yaml +++ b/.github/workflows/qemu.yaml @@ -38,7 +38,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: ghcr.io/project-chip/chip-build-esp32-qemu:1 + image: ghcr.io/project-chip/chip-build-esp32-qemu:2 volumes: - "/tmp/log_output:/tmp/test_logs" @@ -50,9 +50,6 @@ jobs: with: platform: esp32 - - name: Fixup GdbGui requirement - run: perl -i -pe 's/^gdbgui==/# gdbgui==/' /opt/espressif/esp-idf/requirements.txt - - name: Build ESP32 QEMU test images run: | scripts/run_in_build_env.sh " \ diff --git a/.github/workflows/release_artifacts.yaml b/.github/workflows/release_artifacts.yaml index a6c14d8401a5c2..5cbcc9b53308b9 100644 --- a/.github/workflows/release_artifacts.yaml +++ b/.github/workflows/release_artifacts.yaml @@ -32,7 +32,7 @@ jobs: runs-on: ubuntu-latest container: - image: ghcr.io/project-chip/chip-build-esp32:1 + image: ghcr.io/project-chip/chip-build-esp32:2 steps: - name: Checkout diff --git a/config/esp32/components/chip/CMakeLists.txt b/config/esp32/components/chip/CMakeLists.txt index d35791cf1ed3c0..dfda6287ccb60e 100644 --- a/config/esp32/components/chip/CMakeLists.txt +++ b/config/esp32/components/chip/CMakeLists.txt @@ -462,26 +462,11 @@ foreach(phy_blob ${phy_blobs}) list(APPEND chip_libraries "${esp_phy_dir}/lib/${target_name}/lib${phy_blob}.a") endforeach() -idf_component_get_property(esp_event_lib esp_event COMPONENT_LIB) -list(APPEND chip_libraries $) - -idf_component_get_property(hal_lib hal COMPONENT_LIB) -list(APPEND chip_libraries $) - -idf_component_get_property(esp_system_lib esp_system COMPONENT_LIB) -list(APPEND chip_libraries $) - -idf_component_get_property(soc_lib soc COMPONENT_LIB) -list(APPEND chip_libraries $) - -idf_component_get_property(efuse_lib efuse COMPONENT_LIB) -list(APPEND chip_libraries $) - -idf_component_get_property(vfs_lib vfs COMPONENT_LIB) -list(APPEND chip_libraries $) - -idf_component_get_property(driver_lib driver COMPONENT_LIB) -list(APPEND chip_libraries $) +set(components_to_link esp_event hal esp_system soc efuse vfs driver esp_coex freertos) +foreach(component ${components_to_link}) + idf_component_get_property(lib_name ${component} COMPONENT_LIB) + list(APPEND chip_libraries $) +endforeach() target_link_libraries(${COMPONENT_LIB} INTERFACE -Wl,--start-group ${chip_libraries} diff --git a/docs/guides/esp32/setup_idf_chip.md b/docs/guides/esp32/setup_idf_chip.md index ff5ee40c60aed8..ef57e61ca3c3ac 100644 --- a/docs/guides/esp32/setup_idf_chip.md +++ b/docs/guides/esp32/setup_idf_chip.md @@ -13,42 +13,32 @@ step. ### Install Prerequisites -- [Linux](https://docs.espressif.com/projects/esp-idf/en/v4.4.4/esp32/get-started/linux-setup.html) -- [macOS](https://docs.espressif.com/projects/esp-idf/en/v4.4.4/esp32/get-started/macos-setup.html) +- [Linux](https://docs.espressif.com/projects/esp-idf/en/v5.1/esp32/get-started/linux-macos-setup.html#for-linux-users) +- [macOS](https://docs.espressif.com/projects/esp-idf/en/v5.1/esp32/get-started/linux-macos-setup.html#for-macos-users) -### Get IDF v4.4.4 +### Get IDF v5.1 - Clone ESP-IDF - [v4.4.4 release](https://github.com/espressif/esp-idf/releases/tag/v4.4.4) + [v5.1 release](https://github.com/espressif/esp-idf/releases/tag/v5.1) ``` - $ git clone -b v4.4.4 --recursive https://github.com/espressif/esp-idf.git + $ git clone -b v5.1 --recursive --depth 1 --shallow-submodule https://github.com/espressif/esp-idf.git $ cd esp-idf $ ./install.sh ``` -- To update an existing esp-idf toolchain to v4.4.4: +- To update an existing esp-idf toolchain to v5.1: ``` $ cd path/to/esp-idf $ git fetch origin - $ git checkout v4.4.4 - $ git reset --hard origin/v4.4.4 + $ git checkout v5.1 + $ git reset --hard origin/v5.1 $ git submodule update --recursive --init $ git clean -fdx $ ./install.sh ``` -- For ESP32C6 & ESP32H2, please use commit - [ea5e0ff](https://github.com/espressif/esp-idf/tree/ea5e0ff). - - ``` - $ cd esp-idf - $ git checkout ea5e0ff - $ git submodule update --init - $ ./install.sh - ``` - ## Setup Matter environment ### Install Prerequisites @@ -80,22 +70,6 @@ below: python3 -m pip install esptool ``` -For MacOS, `gdbgui` python package will not be installed using `bootstrap.sh` -script as it is restricted only for x64 Linux platforms. It is restricted -because, building wheels for `gevent` (dependency of `gdbgui`) fails on MacOS. - -For ARM-based Mac, no further installation steps are necessary if Python3 -version is greater than or equal to 3.11. - -If Python3 version is less than 3.11 or you are using x86(Intel-based) Mac then -please run the below commands after every bootstrapping to install gdbgui wheels -as binary - -``` -python3 -m pip install -c scripts/setup/constraints.txt --no-cache --prefer-binary gdbgui==0.13.2.0 -deactivate -``` - --- Once IDF and Matter environment is set up, head over to diff --git a/examples/all-clusters-app/esp32/CMakeLists.txt b/examples/all-clusters-app/esp32/CMakeLists.txt index dc92f0c65b2e19..d5508c4197d790 100644 --- a/examples/all-clusters-app/esp32/CMakeLists.txt +++ b/examples/all-clusters-app/esp32/CMakeLists.txt @@ -26,12 +26,11 @@ include(${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common/cm set(EXTRA_COMPONENT_DIRS "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/config/esp32/components" - "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common/QRCode" + "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common" ) + if(${IDF_TARGET} STREQUAL "esp32") - list(APPEND EXTRA_COMPONENT_DIRS "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common/m5stack-tft/repo/components/tft" - "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common/m5stack-tft/repo/components/spidriver" - "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common/screen-framework") + list(APPEND EXTRA_COMPONENT_DIRS "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common/m5stack-tft/repo/components") endif() project(chip-all-clusters-app) diff --git a/examples/all-clusters-app/esp32/main/CMakeLists.txt b/examples/all-clusters-app/esp32/main/CMakeLists.txt index 14015338230788..1b4b6ff21e6296 100644 --- a/examples/all-clusters-app/esp32/main/CMakeLists.txt +++ b/examples/all-clusters-app/esp32/main/CMakeLists.txt @@ -110,8 +110,14 @@ set(PRIV_INCLUDE_DIRS_LIST "${PRIV_INCLUDE_DIRS_LIST}" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/pigweed" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/pigweed/esp32" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/lib/support" - "${IDF_PATH}/components/freertos/include/freertos" ) + +if (${IDF_VERSION_MAJOR} LESS 5) + list(APPEND PRIV_INCLUDE_DIRS_LIST "${IDF_PATH}/components/freertos/include/freertos") +else() + list(APPEND PRIV_INCLUDE_DIRS_LIST "${IDF_PATH}/components/freertos/FreeRTOS-Kernel/include/freertos") +endif() + set(SRC_DIRS_LIST "${SRC_DIRS_LIST}" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/pigweed" @@ -119,9 +125,10 @@ set(SRC_DIRS_LIST "${SRC_DIRS_LIST}" ) endif (CONFIG_ENABLE_PW_RPC) -set(PRIV_REQUIRES_LIST chip QRCode bt driver app_update nvs_flash spi_flash openthread) -if(CONFIG_HAVE_DISPLAY) - list(APPEND PRIV_REQUIRES_LIST tft spidrier screen-framework) +set(PRIV_REQUIRES_LIST chip QRCode bt app_update nvs_flash spi_flash openthread) + +if(${IDF_TARGET} STREQUAL "esp32") + list(APPEND PRIV_REQUIRES_LIST spidriver screen-framework) endif() if(CONFIG_DEVICE_TYPE_ESP32_C3_DEVKITM) diff --git a/examples/all-clusters-app/esp32/sdkconfig.defaults b/examples/all-clusters-app/esp32/sdkconfig.defaults index d824c990600f65..c3b10929d4120d 100644 --- a/examples/all-clusters-app/esp32/sdkconfig.defaults +++ b/examples/all-clusters-app/esp32/sdkconfig.defaults @@ -66,3 +66,6 @@ CONFIG_MBEDTLS_HKDF_C=y # This example uses the older version of RMT driver to work with both # idf-v4.4.3 and idf-v5.0, so supressing the warnings by setting below option CONFIG_RMT_SUPPRESS_DEPRECATE_WARN=y + +# Move functions from IRAM to flash +CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y diff --git a/examples/all-clusters-app/esp32/sdkconfig_c3devkit.defaults b/examples/all-clusters-app/esp32/sdkconfig_c3devkit.defaults index 24d4fe754ebdc8..8d7455d0d7610f 100644 --- a/examples/all-clusters-app/esp32/sdkconfig_c3devkit.defaults +++ b/examples/all-clusters-app/esp32/sdkconfig_c3devkit.defaults @@ -50,3 +50,6 @@ CONFIG_ESPTOOLPY_FLASHSIZE="4MB" # Enable HKDF in mbedtls CONFIG_MBEDTLS_HKDF_C=y + +# Move functions from IRAM to flash +CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y diff --git a/examples/all-clusters-app/esp32/sdkconfig_m5stack.defaults b/examples/all-clusters-app/esp32/sdkconfig_m5stack.defaults index a7d058bc7fe30a..287262d17e57cc 100644 --- a/examples/all-clusters-app/esp32/sdkconfig_m5stack.defaults +++ b/examples/all-clusters-app/esp32/sdkconfig_m5stack.defaults @@ -70,3 +70,6 @@ CONFIG_MBEDTLS_HKDF_C=y # Build chip tests CONFIG_BUILD_CHIP_TESTS=y + +# Move functions from IRAM to flash +CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y diff --git a/examples/all-clusters-app/esp32/sdkconfig_m5stack_rpc.defaults b/examples/all-clusters-app/esp32/sdkconfig_m5stack_rpc.defaults index e0cf1a0f22a874..213d44fe9c616e 100644 --- a/examples/all-clusters-app/esp32/sdkconfig_m5stack_rpc.defaults +++ b/examples/all-clusters-app/esp32/sdkconfig_m5stack_rpc.defaults @@ -74,3 +74,9 @@ CONFIG_MBEDTLS_HKDF_C=y # Build chip tests CONFIG_BUILD_CHIP_TESTS=y + +# Move functions from IRAM to flash +CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y + +# to avoid dram overflow, reduce the critical loggin buffer to 1K +CONFIG_EVENT_LOGGING_CRIT_BUFFER_SIZE=1024 diff --git a/examples/all-clusters-minimal-app/esp32/CMakeLists.txt b/examples/all-clusters-minimal-app/esp32/CMakeLists.txt index 0d6aa7b68931f6..0af660ce2990e2 100644 --- a/examples/all-clusters-minimal-app/esp32/CMakeLists.txt +++ b/examples/all-clusters-minimal-app/esp32/CMakeLists.txt @@ -26,12 +26,11 @@ include(${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common/cm set(EXTRA_COMPONENT_DIRS "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/config/esp32/components" - "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common/QRCode" + "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common" ) + if(${IDF_TARGET} STREQUAL "esp32") - list(APPEND EXTRA_COMPONENT_DIRS "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common/m5stack-tft/repo/components/tft" - "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common/m5stack-tft/repo/components/spidriver" - "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common/screen-framework") + list(APPEND EXTRA_COMPONENT_DIRS "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common/m5stack-tft/repo/components") endif() project(chip-all-clusters-minimal-app) diff --git a/examples/all-clusters-minimal-app/esp32/main/CMakeLists.txt b/examples/all-clusters-minimal-app/esp32/main/CMakeLists.txt index c445c54d32e370..33582927c19d26 100644 --- a/examples/all-clusters-minimal-app/esp32/main/CMakeLists.txt +++ b/examples/all-clusters-minimal-app/esp32/main/CMakeLists.txt @@ -100,8 +100,14 @@ set(PRIV_INCLUDE_DIRS_LIST "${PRIV_INCLUDE_DIRS_LIST}" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/pigweed" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/pigweed/esp32" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/lib/support" - "${IDF_PATH}/components/freertos/include/freertos" ) + +if (${IDF_VERSION_MAJOR} LESS 5) + list(APPEND PRIV_INCLUDE_DIRS_LIST "${IDF_PATH}/components/freertos/include/freertos") +else() + list(APPEND PRIV_INCLUDE_DIRS_LIST "${IDF_PATH}/components/freertos/FreeRTOS-Kernel/include/freertos") +endif() + set(SRC_DIRS_LIST "${SRC_DIRS_LIST}" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/pigweed" @@ -110,8 +116,9 @@ set(SRC_DIRS_LIST "${SRC_DIRS_LIST}" endif (CONFIG_ENABLE_PW_RPC) set(PRIV_REQUIRES_LIST chip QRCode bt driver app_update nvs_flash spi_flash openthread) -if(CONFIG_HAVE_DISPLAY) - list(APPEND PRIV_REQUIRES_LIST tft spidrier screen-framework) + +if(${IDF_TARGET} STREQUAL "esp32") + list(APPEND PRIV_REQUIRES_LIST spidriver screen-framework) endif() if(CONFIG_DEVICE_TYPE_ESP32_C3_DEVKITM) diff --git a/examples/all-clusters-minimal-app/esp32/partitions.csv b/examples/all-clusters-minimal-app/esp32/partitions.csv index 7d399d0f5dd48e..47172e25774ebb 100644 --- a/examples/all-clusters-minimal-app/esp32/partitions.csv +++ b/examples/all-clusters-minimal-app/esp32/partitions.csv @@ -3,6 +3,6 @@ nvs, data, nvs, , 0xC000, otadata, data, ota, , 0x2000, phy_init, data, phy, , 0x1000, -ota_0, app, ota_0, , 1500K, -ota_1, app, ota_1, , 1500K, +ota_0, app, ota_0, , 1900K, +ota_1, app, ota_1, , 1900K, ot_storage, data, 0x3a, , 0x2000, diff --git a/examples/all-clusters-minimal-app/esp32/sdkconfig.defaults b/examples/all-clusters-minimal-app/esp32/sdkconfig.defaults index dcceac3858cd3e..fda02fbf7c9bae 100644 --- a/examples/all-clusters-minimal-app/esp32/sdkconfig.defaults +++ b/examples/all-clusters-minimal-app/esp32/sdkconfig.defaults @@ -66,3 +66,6 @@ CONFIG_RMT_SUPPRESS_DEPRECATE_WARN=y # Enable HKDF in mbedtls CONFIG_MBEDTLS_HKDF_C=y + +# Move functions from IRAM to flash +CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y diff --git a/examples/all-clusters-minimal-app/esp32/sdkconfig_c3devkit.defaults b/examples/all-clusters-minimal-app/esp32/sdkconfig_c3devkit.defaults index 24d4fe754ebdc8..8d7455d0d7610f 100644 --- a/examples/all-clusters-minimal-app/esp32/sdkconfig_c3devkit.defaults +++ b/examples/all-clusters-minimal-app/esp32/sdkconfig_c3devkit.defaults @@ -50,3 +50,6 @@ CONFIG_ESPTOOLPY_FLASHSIZE="4MB" # Enable HKDF in mbedtls CONFIG_MBEDTLS_HKDF_C=y + +# Move functions from IRAM to flash +CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y diff --git a/examples/all-clusters-minimal-app/esp32/sdkconfig_m5stack.defaults b/examples/all-clusters-minimal-app/esp32/sdkconfig_m5stack.defaults index a7d058bc7fe30a..287262d17e57cc 100644 --- a/examples/all-clusters-minimal-app/esp32/sdkconfig_m5stack.defaults +++ b/examples/all-clusters-minimal-app/esp32/sdkconfig_m5stack.defaults @@ -70,3 +70,6 @@ CONFIG_MBEDTLS_HKDF_C=y # Build chip tests CONFIG_BUILD_CHIP_TESTS=y + +# Move functions from IRAM to flash +CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y diff --git a/examples/all-clusters-minimal-app/esp32/sdkconfig_m5stack_rpc.defaults b/examples/all-clusters-minimal-app/esp32/sdkconfig_m5stack_rpc.defaults index e0cf1a0f22a874..213d44fe9c616e 100644 --- a/examples/all-clusters-minimal-app/esp32/sdkconfig_m5stack_rpc.defaults +++ b/examples/all-clusters-minimal-app/esp32/sdkconfig_m5stack_rpc.defaults @@ -74,3 +74,9 @@ CONFIG_MBEDTLS_HKDF_C=y # Build chip tests CONFIG_BUILD_CHIP_TESTS=y + +# Move functions from IRAM to flash +CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y + +# to avoid dram overflow, reduce the critical loggin buffer to 1K +CONFIG_EVENT_LOGGING_CRIT_BUFFER_SIZE=1024 diff --git a/examples/chef/esp32/sdkconfig.defaults b/examples/chef/esp32/sdkconfig.defaults index ca2cd09fcd1541..bd714ab0202833 100644 --- a/examples/chef/esp32/sdkconfig.defaults +++ b/examples/chef/esp32/sdkconfig.defaults @@ -59,3 +59,6 @@ CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n # Enable HKDF in mbedtls CONFIG_MBEDTLS_HKDF_C=y + +# IRAM optimizations +CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y diff --git a/examples/chef/esp32/sdkconfig_rpc.defaults b/examples/chef/esp32/sdkconfig_rpc.defaults index caac0212b3b17a..a1506dd52891bc 100644 --- a/examples/chef/esp32/sdkconfig_rpc.defaults +++ b/examples/chef/esp32/sdkconfig_rpc.defaults @@ -58,3 +58,6 @@ CONFIG_ESPTOOLPY_FLASHSIZE="4MB" # Enable HKDF in mbedtls CONFIG_MBEDTLS_HKDF_C=y + +# IRAM optimizations +CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y diff --git a/examples/common/m5stack-tft/repo b/examples/common/m5stack-tft/repo index 3344a8105f8dfe..a6299b6c7c0b2e 160000 --- a/examples/common/m5stack-tft/repo +++ b/examples/common/m5stack-tft/repo @@ -1 +1 @@ -Subproject commit 3344a8105f8dfecb95832f369733cf6f863a1662 +Subproject commit a6299b6c7c0b2e3eb62fa08ee4bf7155c39bad1f diff --git a/examples/common/screen-framework/CMakeLists.txt b/examples/common/screen-framework/CMakeLists.txt index 5b5739e12c2df5..af304459ea69e3 100644 --- a/examples/common/screen-framework/CMakeLists.txt +++ b/examples/common/screen-framework/CMakeLists.txt @@ -1,6 +1,12 @@ +set(require_list chip driver) + +if(${IDF_TARGET} STREQUAL "esp32") + list(APPEND require_list tft) +endif() + idf_component_register(SRCS "Display.cpp" "ScreenManager.cpp" "Screen.cpp" "ListScreen.cpp" INCLUDE_DIRS "include" - PRIV_REQUIRES tft chip driver) + REQUIRES ${require_list}) diff --git a/examples/lighting-app/esp32/CMakeLists.txt b/examples/lighting-app/esp32/CMakeLists.txt index b37c8154a45208..356a3cd14d6b64 100644 --- a/examples/lighting-app/esp32/CMakeLists.txt +++ b/examples/lighting-app/esp32/CMakeLists.txt @@ -26,15 +26,14 @@ include(${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common/cm set(EXTRA_COMPONENT_DIRS "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/config/esp32/components" - "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common/QRCode" + "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common" ) if(${IDF_TARGET} STREQUAL "esp32") - list(APPEND EXTRA_COMPONENT_DIRS "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common/m5stack-tft/repo/components/tft" - "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common/m5stack-tft/repo/components/spidriver" - "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common/screen-framework") + list(APPEND EXTRA_COMPONENT_DIRS "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common/m5stack-tft/repo/components") endif() + project(chip-lighting-app) # WARNING: This is just an example for using key for decrypting the encrypted OTA image diff --git a/examples/lighting-app/esp32/main/CMakeLists.txt b/examples/lighting-app/esp32/main/CMakeLists.txt index b6e29691bacd23..fcb0121d9f6d78 100644 --- a/examples/lighting-app/esp32/main/CMakeLists.txt +++ b/examples/lighting-app/esp32/main/CMakeLists.txt @@ -69,6 +69,10 @@ set(SRC_DIRS_LIST set(PRIV_REQUIRES_LIST chip QRCode bt led_strip app_update openthread driver nvs_flash spi_flash) +if(${IDF_TARGET} STREQUAL "esp32") + list(APPEND PRIV_REQUIRES_LIST spidriver screen-framework) +endif() + if (CONFIG_ENABLE_PW_RPC) # Append additional directories for RPC build set(PRIV_INCLUDE_DIRS_LIST "${PRIV_INCLUDE_DIRS_LIST}" @@ -77,8 +81,14 @@ set(PRIV_INCLUDE_DIRS_LIST "${PRIV_INCLUDE_DIRS_LIST}" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/pigweed" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/pigweed/esp32" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/lib/support" - "${IDF_PATH}/components/freertos/include/freertos" ) + +if (${IDF_VERSION_MAJOR} LESS 5) + list(APPEND PRIV_INCLUDE_DIRS_LIST "${IDF_PATH}/components/freertos/include/freertos") +else() + list(APPEND PRIV_INCLUDE_DIRS_LIST "${IDF_PATH}/components/freertos/FreeRTOS-Kernel/include/freertos") +endif() + set(SRC_DIRS_LIST "${SRC_DIRS_LIST}" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/pigweed" @@ -86,10 +96,6 @@ set(SRC_DIRS_LIST "${SRC_DIRS_LIST}" ) endif (CONFIG_ENABLE_PW_RPC) -if (CONFIG_HAVE_DISPLAY) - list(APPEND PRIV_REQUIRES_LIST tft screen-framework) -endif() - idf_component_register(PRIV_INCLUDE_DIRS ${PRIV_INCLUDE_DIRS_LIST} SRC_DIRS ${SRC_DIRS_LIST} PRIV_REQUIRES ${PRIV_REQUIRES_LIST}) diff --git a/examples/lock-app/esp32/main/CMakeLists.txt b/examples/lock-app/esp32/main/CMakeLists.txt index bf9edad36d7f7e..dc5fa500b03434 100644 --- a/examples/lock-app/esp32/main/CMakeLists.txt +++ b/examples/lock-app/esp32/main/CMakeLists.txt @@ -19,6 +19,13 @@ get_filename_component(CHIP_ROOT ${CMAKE_SOURCE_DIR}/third_party/connectedhomeip REALPATH) if (CONFIG_ENABLE_PW_RPC) + +if (${IDF_VERSION_MAJOR} LESS 5) + set(freertos_include_path "${IDF_PATH}/components/freertos/include/freertos") +else() + set(freertos_include_path "${IDF_PATH}/components/freertos/FreeRTOS-Kernel/include/freertos") +endif() + idf_component_register(INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/pw_sys_io/public" @@ -30,7 +37,7 @@ idf_component_register(INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/pigweed/esp32" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/lib/support" "${CMAKE_CURRENT_LIST_DIR}/include" - "${IDF_PATH}/components/freertos/include/freertos" + "${freertos_include_path}" SRC_DIRS "${CMAKE_CURRENT_LIST_DIR}" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/providers" diff --git a/examples/ota-requestor-app/esp32/main/CMakeLists.txt b/examples/ota-requestor-app/esp32/main/CMakeLists.txt index 6a3633f442ac64..10c61e162900f2 100644 --- a/examples/ota-requestor-app/esp32/main/CMakeLists.txt +++ b/examples/ota-requestor-app/esp32/main/CMakeLists.txt @@ -72,8 +72,14 @@ set(PRIV_INCLUDE_DIRS_LIST "${PRIV_INCLUDE_DIRS_LIST}" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/pigweed" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/pigweed/esp32" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/lib/support" - "${IDF_PATH}/components/freertos/include/freertos" ) + +if (${IDF_VERSION_MAJOR} LESS 5) + list(APPEND PRIV_INCLUDE_DIRS_LIST "${IDF_PATH}/components/freertos/include/freertos") +else() + list(APPEND PRIV_INCLUDE_DIRS_LIST "${IDF_PATH}/components/freertos/FreeRTOS-Kernel/include/freertos") +endif() + set(SRC_DIRS_LIST "${SRC_DIRS_LIST}" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/pigweed" diff --git a/examples/pigweed-app/esp32/main/CMakeLists.txt b/examples/pigweed-app/esp32/main/CMakeLists.txt index 005f587b70b50c..e06bb5a5296a14 100644 --- a/examples/pigweed-app/esp32/main/CMakeLists.txt +++ b/examples/pigweed-app/esp32/main/CMakeLists.txt @@ -14,6 +14,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +if (${IDF_VERSION_MAJOR} LESS 5) + set(freertos_include_path "${IDF_PATH}/components/freertos/include/freertos") +else() + set(freertos_include_path "${IDF_PATH}/components/freertos/FreeRTOS-Kernel/include/freertos") +endif() + idf_component_register(INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/pw_sys_io/public" @@ -21,7 +27,7 @@ idf_component_register(INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/pigweed" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/pigweed/esp32" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/lib/support" - "${IDF_PATH}/components/freertos/include/freertos" + "${freertos_include_path}" SRC_DIRS "${CMAKE_CURRENT_LIST_DIR}" diff --git a/examples/platform/esp32/PigweedLogger.cpp b/examples/platform/esp32/PigweedLogger.cpp index e7bb260f9da034..d10b89bcd9f69f 100644 --- a/examples/platform/esp32/PigweedLogger.cpp +++ b/examples/platform/esp32/PigweedLogger.cpp @@ -138,7 +138,7 @@ extern "C" void __wrap_esp_log_writev(esp_log_level_t level, const char * tag, c PigweedLogger::putString(logColor, strlen(logColor)); char formattedMsg[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE]; - size_t len = snprintf(formattedMsg, sizeof formattedMsg, " (%u) %s: ", esp_log_timestamp(), tag); + size_t len = snprintf(formattedMsg, sizeof formattedMsg, " (%" PRIu32 ") %s: ", esp_log_timestamp(), tag); PigweedLogger::putString(formattedMsg, len); memset(formattedMsg, 0, sizeof formattedMsg); diff --git a/examples/shell/esp32/main/CMakeLists.txt b/examples/shell/esp32/main/CMakeLists.txt index 8fac15167812f5..5a565edb90a6d5 100644 --- a/examples/shell/esp32/main/CMakeLists.txt +++ b/examples/shell/esp32/main/CMakeLists.txt @@ -23,4 +23,4 @@ idf_component_register(SRCS main.cpp "${CHIP_SHELL_DIR}/shell_common/globals.cpp" PRIV_INCLUDE_DIRS "${CHIP_SHELL_DIR}/shell_common/include" - PRIV_REQUIRES chip nvs_flash bt console) + PRIV_REQUIRES chip nvs_flash bt) diff --git a/examples/temperature-measurement-app/esp32/main/CMakeLists.txt b/examples/temperature-measurement-app/esp32/main/CMakeLists.txt index 6136d1583709bb..06b274e8d4bade 100644 --- a/examples/temperature-measurement-app/esp32/main/CMakeLists.txt +++ b/examples/temperature-measurement-app/esp32/main/CMakeLists.txt @@ -64,8 +64,14 @@ set(PRIV_INCLUDE_DIRS_LIST "${PRIV_INCLUDE_DIRS_LIST}" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/pigweed" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/pigweed/esp32" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/lib/support" - "${IDF_PATH}/components/freertos/include/freertos" ) + +if (${IDF_VERSION_MAJOR} LESS 5) + list(APPEND PRIV_INCLUDE_DIRS_LIST "${IDF_PATH}/components/freertos/include/freertos") +else() + list(APPEND PRIV_INCLUDE_DIRS_LIST "${IDF_PATH}/components/freertos/FreeRTOS-Kernel/include/freertos") +endif() + set(SRC_DIRS_LIST "${SRC_DIRS_LIST}" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/pigweed" diff --git a/scripts/setup/constraints.txt b/scripts/setup/constraints.txt index 5573d0bc48221f..fa15e9d94ab800 100644 --- a/scripts/setup/constraints.txt +++ b/scripts/setup/constraints.txt @@ -248,7 +248,7 @@ pykwalify==1.8.0 # via west pylink-square==0.5.0 # via bflb-iot-tool -pyparsing==2.3.1 +pyparsing==3.0.9 # via -r requirements.esp32.txt pypng==0.0.21 # via -r requirements.telink.txt diff --git a/scripts/setup/requirements.esp32.txt b/scripts/setup/requirements.esp32.txt index f688b17b1a521b..d0d6d924ff8ddb 100644 --- a/scripts/setup/requirements.esp32.txt +++ b/scripts/setup/requirements.esp32.txt @@ -1,18 +1,15 @@ click>=7.0 future>=0.15.2 -pyparsing>=2.0.3,<2.4.0 +# pyparsing: Min version was set based on https://github.com/pyparsing/pyparsing/issues/319 +# pyparsing: Max version was set to avoid breaking changes +pyparsing>=3.0.3,<3.1 idf-component-manager pygdbmi<=0.9.0.2 reedsolo>=1.5.3,<=1.5.4 bitstring>=3.1.6,<4 ecdsa>=0.16.0 -kconfiglib==13.7.1 construct==2.10.54 python-socketio<5 itsdangerous<2.1 ; python_version < "3.11" -# -# gdbgui pulls in gevent which fails to compile due to cython updates. -# Could not find a good way to fix this dependency, so commenting it -# out here. -# -# gdbgui==0.13.2.0 ; python_version < "3.11" and platform_machine != 'aarch64' and sys_platform == 'linux' +esp_idf_monitor==1.1.1 +esp-idf-kconfig==1.2.0 diff --git a/src/test_driver/esp32/main/main_app.cpp b/src/test_driver/esp32/main/main_app.cpp index 1eef2ae345439a..0ff3ce4690d6b8 100644 --- a/src/test_driver/esp32/main/main_app.cpp +++ b/src/test_driver/esp32/main/main_app.cpp @@ -19,12 +19,12 @@ #include "esp_heap_caps_init.h" #include "esp_log.h" #include "esp_netif.h" -#include "esp_spi_flash.h" #include "esp_system.h" #include "esp_wifi.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "nvs_flash.h" +#include "spi_flash_mmap.h" #include @@ -48,17 +48,6 @@ static void tester_task(void * pvParameters) extern "C" void app_main() { - esp_chip_info_t chip_info; - esp_chip_info(&chip_info); - - ESP_LOGI(TAG, "This is ESP32 chip with %d CPU cores, WiFi%s%s, ", chip_info.cores, - (chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "", (chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : ""); - - ESP_LOGI(TAG, "silicon revision %d, ", chip_info.revision); - - ESP_LOGI(TAG, "%dMB %s flash\n", spi_flash_get_chip_size() / (1024 * 1024), - (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external"); - // Initialize the ESP NVS layer. esp_err_t err = nvs_flash_init(); if (err != ESP_OK)