diff --git a/.gitignore b/.gitignore index 5c9f408a1cb968..4c17bb63a84a8c 100644 --- a/.gitignore +++ b/.gitignore @@ -74,3 +74,9 @@ examples/thermostat/ameba/build # Downloaded zap without a pigweed root (via zap_download.py) .zap + +# When building esp-idf application, if any component is fetched using idf-component-manager then they are stored in +# managed_component directory. Along with that dependencies.lock file is generated. +# https://github.com/espressif/idf-component-manager#using-with-a-project +examples/*/esp32/managed_components +examples/*/esp32/dependencies.lock diff --git a/examples/all-clusters-app/esp32/CMakeLists.txt b/examples/all-clusters-app/esp32/CMakeLists.txt index 0a8752ca6bcc27..e1eb655da1c9e9 100644 --- a/examples/all-clusters-app/esp32/CMakeLists.txt +++ b/examples/all-clusters-app/esp32/CMakeLists.txt @@ -27,7 +27,6 @@ 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" - "${IDF_PATH}/examples/common_components/led_strip" ) if(${IDF_TARGET} STREQUAL "esp32") list(APPEND EXTRA_COMPONENT_DIRS "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common/m5stack-tft/repo/components/tft" diff --git a/examples/all-clusters-app/esp32/main/AppTask.cpp b/examples/all-clusters-app/esp32/main/AppTask.cpp index 9a04b23c689d4c..836e4d8b2b7f02 100644 --- a/examples/all-clusters-app/esp32/main/AppTask.cpp +++ b/examples/all-clusters-app/esp32/main/AppTask.cpp @@ -23,12 +23,19 @@ #include "LEDWidget.h" #include "ScreenManager.h" #include "driver/gpio.h" +#include "esp_idf_version.h" #include "esp_log.h" -#include "esp_spi_flash.h" #include "freertos/FreeRTOS.h" #include #include +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) +#include "esp_spi_flash.h" +#else +#include "esp_chip_info.h" +#include "esp_flash.h" +#endif + #define FACTORY_RESET_CANCEL_WINDOW_TIMEOUT 3000 #define APP_TASK_NAME "APP" #define APP_EVENT_QUEUE_SIZE 10 @@ -173,10 +180,20 @@ CHIP_ERROR AppTask::Init() /* Print chip information */ esp_chip_info_t chip_info; esp_chip_info(&chip_info); + uint32_t flash_size = 0; + +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) + flash_size = spi_flash_get_chip_size(); +#else + if (esp_flash_get_size(NULL, &flash_size) != ESP_OK) + { + ESP_LOGW(TAG, "Failed to get flash size"); + } +#endif 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), + ESP_LOGI(TAG, "%" PRIu32 " MB %s flash\n", flash_size / (1024 * 1024), (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external"); // Create FreeRTOS sw timer for Function Selection diff --git a/examples/all-clusters-app/esp32/main/CMakeLists.txt b/examples/all-clusters-app/esp32/main/CMakeLists.txt index e642a04553d7c0..bf2c65dd1570f6 100644 --- a/examples/all-clusters-app/esp32/main/CMakeLists.txt +++ b/examples/all-clusters-app/esp32/main/CMakeLists.txt @@ -109,7 +109,7 @@ set(SRC_DIRS_LIST "${SRC_DIRS_LIST}" ) endif (CONFIG_ENABLE_PW_RPC) -if(("${CONFIG_DEVICE_TYPE_ESP32_DEVKITC}" STREQUAL "y") OR ("${CONFIG_DEVICE_TYPE_ESP32_C3_DEVKITM}" STREQUAL "y")) +if(("${CONFIG_DEVICE_TYPE_ESP32_DEVKITC}" STREQUAL "y") OR ("${CONFIG_DEVICE_TYPE_ESP32_C3_DEVKITM}" STREQUAL "y") OR ("${CONFIG_DEVICE_TYPE_ESP32_C2_DEVKITM}" STREQUAL "y")) list(APPEND PRIV_INCLUDE_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/screen-framework/include") set(PRIV_REQUIRES_LIST chip QRCode bt) diff --git a/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp b/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp index 61983e84953c0f..cb9a532961198d 100644 --- a/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp @@ -93,8 +93,7 @@ void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Clus uint8_t type, uint16_t size, uint8_t * value) { ESP_LOGI(TAG, - "PostAttributeChangeCallback - Cluster ID: '0x%04x', EndPoint ID: " - "'0x%02x', Attribute ID: '0x%04x'", + "PostAttributeChangeCallback - Cluster ID: '0x%04" PRIx32 "', EndPoint ID: '0x%02x' , Attribute ID: '0x%04" PRIx32 "'", clusterId, endpointId, attributeId); switch (clusterId) @@ -115,7 +114,7 @@ void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Clus OnIdentifyPostAttributeChangeCallback(endpointId, attributeId, size, value); break; default: - ESP_LOGI(TAG, "Unhandled cluster ID: %d", clusterId); + ESP_LOGI(TAG, "Unhandled cluster ID: %" PRIu32, clusterId); break; } @@ -126,7 +125,7 @@ void AppDeviceCallbacks::OnOnOffPostAttributeChangeCallback(EndpointId endpointI { using namespace app::Clusters::OnOff::Attributes; - VerifyOrExit(attributeId == OnOff::Id, ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04x", attributeId)); + VerifyOrExit(attributeId == OnOff::Id, ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04" PRIx32 "'", attributeId)); VerifyOrExit(endpointId == 1 || endpointId == 2, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); // At this point we can assume that value points to a bool value. @@ -144,7 +143,7 @@ void AppDeviceCallbacks::OnLevelControlAttributeChangeCallback(EndpointId endpoi bool onOffState = mEndpointOnOffState[endpointId - 1]; uint8_t brightness = onOffState ? *value : 0; - VerifyOrExit(attributeId == CurrentLevel::Id, ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04x", attributeId)); + VerifyOrExit(attributeId == CurrentLevel::Id, ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04" PRIx32 "'", attributeId)); VerifyOrExit(endpointId == 1 || endpointId == 2, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); // At this point we can assume that value points to a bool value. @@ -162,7 +161,7 @@ void AppDeviceCallbacks::OnColorControlAttributeChangeCallback(EndpointId endpoi using namespace app::Clusters::ColorControl::Attributes; VerifyOrExit(attributeId == CurrentHue::Id || attributeId == CurrentSaturation::Id, - ESP_LOGI(TAG, "Unhandled AttributeId ID: '0x%04x", attributeId)); + ESP_LOGI(TAG, "Unhandled AttributeId ID: '0x%04" PRIx32 "'", attributeId)); VerifyOrExit(endpointId == 1 || endpointId == 2, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); if (endpointId == 1) { diff --git a/examples/all-clusters-app/esp32/main/Kconfig.projbuild b/examples/all-clusters-app/esp32/main/Kconfig.projbuild index 43fcf6c47219ea..4f9e071eb8a5dd 100644 --- a/examples/all-clusters-app/esp32/main/Kconfig.projbuild +++ b/examples/all-clusters-app/esp32/main/Kconfig.projbuild @@ -24,6 +24,7 @@ menu "Demo" prompt "Device Type" default DEVICE_TYPE_ESP32_DEVKITC if IDF_TARGET_ESP32 default DEVICE_TYPE_ESP32_C3_DEVKITM if IDF_TARGET_ESP32C3 + default DEVICE_TYPE_ESP32_C2_DEVKITM if IDF_TARGET_ESP32C2 help Specifies the type of ESP32 device. @@ -46,6 +47,9 @@ menu "Demo" bool "ESP32-Ethernet-Kit_A_V1.0" select ENABLE_ETHERNET_TELEMETRY depends on IDF_TARGET_ESP32 + config DEVICE_TYPE_ESP32_C2_DEVKITM + bool "ESP32C2-DevKitM" + depends on IDF_TARGET_ESP32C2 endchoice choice @@ -77,7 +81,7 @@ menu "Demo" int range 0 5 default 0 if DEVICE_TYPE_ESP32_DEVKITC - default 0 if DEVICE_TYPE_ESP32_C3_DEVKITM + default 0 if DEVICE_TYPE_ESP32_C3_DEVKITM || DEVICE_TYPE_ESP32_C2_DEVKITM default 3 if DEVICE_TYPE_M5STACK default 4 if DEVICE_TYPE_ESP32_WROVER_KIT @@ -102,7 +106,7 @@ menu "Demo" range 0 40 default 2 if DEVICE_TYPE_ESP32_DEVKITC #Use LED1 (blue LED) as status LED on DevKitC default 2 if DEVICE_TYPE_ESP32_ETHERNET_KIT - default 8 if DEVICE_TYPE_ESP32_C3_DEVKITM + default 8 if DEVICE_TYPE_ESP32_C3_DEVKITM || DEVICE_TYPE_ESP32_C2_DEVKITM default 26 if DEVICE_TYPE_ESP32_WROVER_KIT default 40 if DEVICE_TYPE_M5STACK help diff --git a/examples/all-clusters-app/esp32/main/idf_component.yml b/examples/all-clusters-app/esp32/main/idf_component.yml new file mode 100644 index 00000000000000..1c539b8eb57668 --- /dev/null +++ b/examples/all-clusters-app/esp32/main/idf_component.yml @@ -0,0 +1,2 @@ +dependencies: + espressif/led_strip: "^1.0.0-alpha" diff --git a/examples/all-clusters-app/esp32/main/main.cpp b/examples/all-clusters-app/esp32/main/main.cpp index 62563025279cbf..507fb3349a960d 100644 --- a/examples/all-clusters-app/esp32/main/main.cpp +++ b/examples/all-clusters-app/esp32/main/main.cpp @@ -162,7 +162,7 @@ extern "C" void app_main() DeviceCallbacksDelegate::Instance().SetAppDelegate(&sAppDeviceCallbacksDelegate); if (error != CHIP_NO_ERROR) { - ESP_LOGE(TAG, "device.Init() failed: %s", ErrorStr(error)); + ESP_LOGE(TAG, "device.Init() failed: %" CHIP_ERROR_FORMAT, error.Format()); return; } @@ -180,7 +180,7 @@ extern "C" void app_main() error = GetAppTask().StartAppTask(); if (error != CHIP_NO_ERROR) { - ESP_LOGE(TAG, "GetAppTask().StartAppTask() failed : %s", ErrorStr(error)); + ESP_LOGE(TAG, "GetAppTask().StartAppTask() failed : %" CHIP_ERROR_FORMAT, error.Format()); } chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, reinterpret_cast(nullptr)); diff --git a/examples/all-clusters-app/esp32/sdkconfig.defaults b/examples/all-clusters-app/esp32/sdkconfig.defaults index 5fe66f692b842d..42d30f4d170b8d 100644 --- a/examples/all-clusters-app/esp32/sdkconfig.defaults +++ b/examples/all-clusters-app/esp32/sdkconfig.defaults @@ -59,3 +59,7 @@ CONFIG_ESPTOOLPY_FLASHSIZE="4MB" # Disable softap support by default CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n + +# 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 diff --git a/examples/all-clusters-app/esp32/sdkconfig.defaults.esp32c2 b/examples/all-clusters-app/esp32/sdkconfig.defaults.esp32c2 new file mode 100644 index 00000000000000..6cb90db4f55b9d --- /dev/null +++ b/examples/all-clusters-app/esp32/sdkconfig.defaults.esp32c2 @@ -0,0 +1,19 @@ +# Disable chip shell +CONFIG_ENABLE_CHIP_SHELL=n + +# CONFIG_ESP32_WIFI_IRAM_OPT is not set +# CONFIG_ESP32_WIFI_RX_IRAM_OPT is not set +CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y +CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH=y + +CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE=y + +CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=16 +CONFIG_LWIP_TCP_RECVMBOX_SIZE=8 + +CONFIG_BT_NIMBLE_ROLE_CENTRAL=n +CONFIG_BT_NIMBLE_ROLE_OBSERVER=n + +CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=4 +CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=8 +CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=16 diff --git a/examples/all-clusters-minimal-app/esp32/CMakeLists.txt b/examples/all-clusters-minimal-app/esp32/CMakeLists.txt index c53fd3c05c92af..0d6aa7b68931f6 100644 --- a/examples/all-clusters-minimal-app/esp32/CMakeLists.txt +++ b/examples/all-clusters-minimal-app/esp32/CMakeLists.txt @@ -27,7 +27,6 @@ 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" - "${IDF_PATH}/examples/common_components/led_strip" ) if(${IDF_TARGET} STREQUAL "esp32") list(APPEND EXTRA_COMPONENT_DIRS "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common/m5stack-tft/repo/components/tft" diff --git a/examples/all-clusters-minimal-app/esp32/main/AppTask.cpp b/examples/all-clusters-minimal-app/esp32/main/AppTask.cpp index 6db8c63b3c14ec..82a8f9757b590d 100644 --- a/examples/all-clusters-minimal-app/esp32/main/AppTask.cpp +++ b/examples/all-clusters-minimal-app/esp32/main/AppTask.cpp @@ -23,11 +23,18 @@ #include "LEDWidget.h" #include "ScreenManager.h" #include "driver/gpio.h" +#include "esp_idf_version.h" #include "esp_log.h" -#include "esp_spi_flash.h" #include "freertos/FreeRTOS.h" #include +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) +#include "esp_spi_flash.h" +#else +#include "esp_chip_info.h" +#include "esp_flash.h" +#endif + #define APP_TASK_NAME "APP" #define APP_EVENT_QUEUE_SIZE 10 #define APP_TASK_STACK_SIZE (3072) @@ -63,10 +70,20 @@ CHIP_ERROR AppTask::Init() /* Print chip information */ esp_chip_info_t chip_info; esp_chip_info(&chip_info); + uint32_t flash_size = 0; + +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) + flash_size = spi_flash_get_chip_size(); +#else + if (esp_flash_get_size(NULL, &flash_size) != ESP_OK) + { + ESP_LOGW(TAG, "Failed to get flash size"); + } +#endif 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), + ESP_LOGI(TAG, "%" PRIu32 " MB %s flash\n", flash_size / (1024 * 1024), (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external"); CHIP_ERROR err = CHIP_NO_ERROR; diff --git a/examples/all-clusters-minimal-app/esp32/main/CMakeLists.txt b/examples/all-clusters-minimal-app/esp32/main/CMakeLists.txt index b6528fb48e36e5..65132df36e2983 100644 --- a/examples/all-clusters-minimal-app/esp32/main/CMakeLists.txt +++ b/examples/all-clusters-minimal-app/esp32/main/CMakeLists.txt @@ -106,7 +106,7 @@ set(SRC_DIRS_LIST "${SRC_DIRS_LIST}" ) endif (CONFIG_ENABLE_PW_RPC) -if(("${CONFIG_DEVICE_TYPE_ESP32_DEVKITC}" STREQUAL "y") OR ("${CONFIG_DEVICE_TYPE_ESP32_C3_DEVKITM}" STREQUAL "y")) +if(("${CONFIG_DEVICE_TYPE_ESP32_DEVKITC}" STREQUAL "y") OR ("${CONFIG_DEVICE_TYPE_ESP32_C3_DEVKITM}" STREQUAL "y") OR ("${CONFIG_DEVICE_TYPE_ESP32_C2_DEVKITM}" STREQUAL "y")) list(APPEND PRIV_INCLUDE_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/screen-framework/include") set(PRIV_REQUIRES_LIST chip QRCode bt) diff --git a/examples/all-clusters-minimal-app/esp32/main/DeviceCallbacks.cpp b/examples/all-clusters-minimal-app/esp32/main/DeviceCallbacks.cpp index 4358780cf6bc22..9acee43d2c2790 100644 --- a/examples/all-clusters-minimal-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/all-clusters-minimal-app/esp32/main/DeviceCallbacks.cpp @@ -92,8 +92,7 @@ void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Clus uint8_t type, uint16_t size, uint8_t * value) { ESP_LOGI(TAG, - "PostAttributeChangeCallback - Cluster ID: '0x%04x', EndPoint ID: " - "'0x%02x', Attribute ID: '0x%04x'", + "PostAttributeChangeCallback - Cluster ID: '0x%04" PRIx32 "', EndPoint ID: '0x%02x' , Attribute ID: '0x%04" PRIx32 "'", clusterId, endpointId, attributeId); switch (clusterId) @@ -114,7 +113,7 @@ void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Clus OnIdentifyPostAttributeChangeCallback(endpointId, attributeId, size, value); break; default: - ESP_LOGI(TAG, "Unhandled cluster ID: %d", clusterId); + ESP_LOGI(TAG, "Unhandled cluster ID: %" PRIu32, clusterId); break; } @@ -124,7 +123,7 @@ void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Clus void AppDeviceCallbacks::OnOnOffPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { VerifyOrExit(attributeId == Clusters::OnOff::Attributes::OnOff::Id, - ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04x", attributeId)); + ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04" PRIx32 "'", attributeId)); VerifyOrExit(endpointId == 1 || endpointId == 2, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); // At this point we can assume that value points to a bool value. @@ -141,7 +140,7 @@ void AppDeviceCallbacks::OnLevelControlAttributeChangeCallback(EndpointId endpoi uint8_t brightness = onOffState ? *value : 0; VerifyOrExit(attributeId == Clusters::LevelControl::Attributes::CurrentLevel::Id, - ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04x", attributeId)); + ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04" PRIx32 "'", attributeId)); VerifyOrExit(endpointId == 1 || endpointId == 2, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); // At this point we can assume that value points to a bool value. @@ -159,7 +158,7 @@ void AppDeviceCallbacks::OnColorControlAttributeChangeCallback(EndpointId endpoi using namespace Clusters::ColorControl::Attributes; VerifyOrExit(attributeId == CurrentHue::Id || attributeId == CurrentSaturation::Id, - ESP_LOGI(TAG, "Unhandled AttributeId ID: '0x%04x", attributeId)); + ESP_LOGI(TAG, "Unhandled AttributeId ID: '0x%04" PRIx32 "'", attributeId)); VerifyOrExit(endpointId == 1 || endpointId == 2, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); if (endpointId == 1) { diff --git a/examples/all-clusters-minimal-app/esp32/main/Kconfig.projbuild b/examples/all-clusters-minimal-app/esp32/main/Kconfig.projbuild index dbf11ecaab5a57..9b5bff48d90a1e 100644 --- a/examples/all-clusters-minimal-app/esp32/main/Kconfig.projbuild +++ b/examples/all-clusters-minimal-app/esp32/main/Kconfig.projbuild @@ -24,6 +24,7 @@ menu "Demo" prompt "Device Type" default DEVICE_TYPE_ESP32_DEVKITC if IDF_TARGET_ESP32 default DEVICE_TYPE_ESP32_C3_DEVKITM if IDF_TARGET_ESP32C3 + default DEVICE_TYPE_ESP32_C2_DEVKITM if IDF_TARGET_ESP32C2 help Specifies the type of ESP32 device. @@ -42,6 +43,9 @@ menu "Demo" config DEVICE_TYPE_ESP32_C3_DEVKITM bool "ESP32C3-DevKitM" depends on IDF_TARGET_ESP32C3 + config DEVICE_TYPE_ESP32_C2_DEVKITM + bool "ESP32C2-DevKitM" + depends on IDF_TARGET_ESP32C2 endchoice choice @@ -73,7 +77,7 @@ menu "Demo" int range 0 5 default 0 if DEVICE_TYPE_ESP32_DEVKITC - default 0 if DEVICE_TYPE_ESP32_C3_DEVKITM + default 0 if DEVICE_TYPE_ESP32_C3_DEVKITM || DEVICE_TYPE_ESP32_C2_DEVKITM default 3 if DEVICE_TYPE_M5STACK default 4 if DEVICE_TYPE_ESP32_WROVER_KIT @@ -97,7 +101,7 @@ menu "Demo" int range 0 40 default 2 if DEVICE_TYPE_ESP32_DEVKITC #Use LED1 (blue LED) as status LED on DevKitC - default 8 if DEVICE_TYPE_ESP32_C3_DEVKITM + default 8 if DEVICE_TYPE_ESP32_C3_DEVKITM || DEVICE_TYPE_ESP32_C2_DEVKITM default 26 if DEVICE_TYPE_ESP32_WROVER_KIT default 40 if DEVICE_TYPE_M5STACK help diff --git a/examples/all-clusters-minimal-app/esp32/main/idf_component.yml b/examples/all-clusters-minimal-app/esp32/main/idf_component.yml new file mode 100644 index 00000000000000..1c539b8eb57668 --- /dev/null +++ b/examples/all-clusters-minimal-app/esp32/main/idf_component.yml @@ -0,0 +1,2 @@ +dependencies: + espressif/led_strip: "^1.0.0-alpha" diff --git a/examples/all-clusters-minimal-app/esp32/main/main.cpp b/examples/all-clusters-minimal-app/esp32/main/main.cpp index a5de104f33bb9f..69bb15ee91d326 100644 --- a/examples/all-clusters-minimal-app/esp32/main/main.cpp +++ b/examples/all-clusters-minimal-app/esp32/main/main.cpp @@ -156,7 +156,7 @@ extern "C" void app_main() DeviceCallbacksDelegate::Instance().SetAppDelegate(&sAppDeviceCallbacksDelegate); if (error != CHIP_NO_ERROR) { - ESP_LOGE(TAG, "device.Init() failed: %s", ErrorStr(error)); + ESP_LOGE(TAG, "device.Init() failed: %" CHIP_ERROR_FORMAT, error.Format()); return; } @@ -174,7 +174,7 @@ extern "C" void app_main() error = GetAppTask().StartAppTask(); if (error != CHIP_NO_ERROR) { - ESP_LOGE(TAG, "GetAppTask().StartAppTask() failed : %s", ErrorStr(error)); + ESP_LOGE(TAG, "GetAppTask().StartAppTask() failed : %" CHIP_ERROR_FORMAT, error.Format()); } chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, reinterpret_cast(nullptr)); diff --git a/examples/all-clusters-minimal-app/esp32/sdkconfig.defaults b/examples/all-clusters-minimal-app/esp32/sdkconfig.defaults index 5fe66f692b842d..42d30f4d170b8d 100644 --- a/examples/all-clusters-minimal-app/esp32/sdkconfig.defaults +++ b/examples/all-clusters-minimal-app/esp32/sdkconfig.defaults @@ -59,3 +59,7 @@ CONFIG_ESPTOOLPY_FLASHSIZE="4MB" # Disable softap support by default CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n + +# 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 diff --git a/examples/all-clusters-minimal-app/esp32/sdkconfig.defaults.esp32c2 b/examples/all-clusters-minimal-app/esp32/sdkconfig.defaults.esp32c2 new file mode 100644 index 00000000000000..6cb90db4f55b9d --- /dev/null +++ b/examples/all-clusters-minimal-app/esp32/sdkconfig.defaults.esp32c2 @@ -0,0 +1,19 @@ +# Disable chip shell +CONFIG_ENABLE_CHIP_SHELL=n + +# CONFIG_ESP32_WIFI_IRAM_OPT is not set +# CONFIG_ESP32_WIFI_RX_IRAM_OPT is not set +CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y +CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH=y + +CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE=y + +CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=16 +CONFIG_LWIP_TCP_RECVMBOX_SIZE=8 + +CONFIG_BT_NIMBLE_ROLE_CENTRAL=n +CONFIG_BT_NIMBLE_ROLE_OBSERVER=n + +CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=4 +CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=8 +CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=16 diff --git a/examples/bridge-app/esp32/main/CMakeLists.txt b/examples/bridge-app/esp32/main/CMakeLists.txt index 407037a0066d5c..f79d86d2ac9e40 100644 --- a/examples/bridge-app/esp32/main/CMakeLists.txt +++ b/examples/bridge-app/esp32/main/CMakeLists.txt @@ -50,7 +50,7 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/general-commissioning-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/common" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/providers" - PRIV_REQUIRES chip QRCode bt) + PRIV_REQUIRES chip QRCode bt nvs_flash) get_filename_component(CHIP_ROOT ${CMAKE_SOURCE_DIR}/third_party/connectedhomeip REALPATH) diff --git a/examples/bridge-app/esp32/main/DeviceCallbacks.cpp b/examples/bridge-app/esp32/main/DeviceCallbacks.cpp index b7e5a2bffc99fa..fa51be072f38ee 100644 --- a/examples/bridge-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/bridge-app/esp32/main/DeviceCallbacks.cpp @@ -39,8 +39,9 @@ using namespace ::chip::System; void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, ClusterId clusterId, AttributeId attributeId, uint8_t type, uint16_t size, uint8_t * value) { - ESP_LOGI(TAG, "PostAttributeChangeCallback - Cluster ID: '0x%04x', EndPoint ID: '0x%02x', Attribute ID: '0x%04x'", clusterId, - endpointId, attributeId); + ESP_LOGI(TAG, + "PostAttributeChangeCallback - Cluster ID: '0x%04" PRIx32 "', EndPoint ID: '0x%02x', Attribute ID: '0x%04" PRIx32 "'", + clusterId, endpointId, attributeId); ESP_LOGI(TAG, "Current free heap: %d\n", heap_caps_get_free_size(MALLOC_CAP_8BIT)); } diff --git a/examples/bridge-app/esp32/main/main.cpp b/examples/bridge-app/esp32/main/main.cpp index 525a717464df69..5a90a98b9f4055 100644 --- a/examples/bridge-app/esp32/main/main.cpp +++ b/examples/bridge-app/esp32/main/main.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include #include @@ -217,8 +216,8 @@ EmberAfStatus HandleReadBridgedDeviceBasicAttribute(Device * dev, chip::Attribut uint16_t maxReadLength) { using namespace BridgedDeviceBasicInformation::Attributes; - - ChipLogProgress(DeviceLayer, "HandleReadBridgedDeviceBasicAttribute: attrId=%d, maxReadLength=%d", attributeId, maxReadLength); + ChipLogProgress(DeviceLayer, "HandleReadBridgedDeviceBasicAttribute: attrId=%" PRIu32 ", maxReadLength=%u", attributeId, + maxReadLength); if ((attributeId == Reachable::Id) && (maxReadLength == 1)) { @@ -243,7 +242,7 @@ EmberAfStatus HandleReadBridgedDeviceBasicAttribute(Device * dev, chip::Attribut EmberAfStatus HandleReadOnOffAttribute(Device * dev, chip::AttributeId attributeId, uint8_t * buffer, uint16_t maxReadLength) { - ChipLogProgress(DeviceLayer, "HandleReadOnOffAttribute: attrId=%d, maxReadLength=%d", attributeId, maxReadLength); + ChipLogProgress(DeviceLayer, "HandleReadOnOffAttribute: attrId=%" PRIu32 ", maxReadLength=%u", attributeId, maxReadLength); if ((attributeId == OnOff::Attributes::OnOff::Id) && (maxReadLength == 1)) { @@ -263,7 +262,7 @@ EmberAfStatus HandleReadOnOffAttribute(Device * dev, chip::AttributeId attribute EmberAfStatus HandleWriteOnOffAttribute(Device * dev, chip::AttributeId attributeId, uint8_t * buffer) { - ChipLogProgress(DeviceLayer, "HandleWriteOnOffAttribute: attrId=%d", attributeId); + ChipLogProgress(DeviceLayer, "HandleWriteOnOffAttribute: attrId=%" PRIu32, attributeId); ReturnErrorCodeIf((attributeId != OnOff::Attributes::OnOff::Id) || (!dev->IsReachable()), EMBER_ZCL_STATUS_FAILURE); dev->SetOnOff(*buffer == 1); @@ -430,7 +429,7 @@ extern "C" void app_main() chip_err = deviceMgr.Init(&AppCallback); if (chip_err != CHIP_NO_ERROR) { - ESP_LOGE(TAG, "device.Init() failed: %s", ErrorStr(chip_err)); + ESP_LOGE(TAG, "device.Init() failed: %" CHIP_ERROR_FORMAT, chip_err.Format()); return; } diff --git a/examples/common/m5stack-tft/repo b/examples/common/m5stack-tft/repo index a1ece2c500cf17..3344a8105f8dfe 160000 --- a/examples/common/m5stack-tft/repo +++ b/examples/common/m5stack-tft/repo @@ -1 +1 @@ -Subproject commit a1ece2c500cf179db8f0c7dbc7bb8f3ace562142 +Subproject commit 3344a8105f8dfecb95832f369733cf6f863a1662 diff --git a/examples/common/screen-framework/CMakeLists.txt b/examples/common/screen-framework/CMakeLists.txt index e7d6e37512ecbd..5b5739e12c2df5 100644 --- a/examples/common/screen-framework/CMakeLists.txt +++ b/examples/common/screen-framework/CMakeLists.txt @@ -3,4 +3,4 @@ idf_component_register(SRCS "Display.cpp" "Screen.cpp" "ListScreen.cpp" INCLUDE_DIRS "include" - PRIV_REQUIRES tft chip) + PRIV_REQUIRES tft chip driver) diff --git a/examples/light-switch-app/esp32/main/Button.cpp b/examples/light-switch-app/esp32/main/Button.cpp index 5ee8d6886c079f..0f14b694c39093 100644 --- a/examples/light-switch-app/esp32/main/Button.cpp +++ b/examples/light-switch-app/esp32/main/Button.cpp @@ -26,7 +26,7 @@ static const char * TAG = "Button"; static Button::ButtonPressCallback button_press_handler = nullptr; -static void IRAM_ATTR gpio_isr_handler(void * arg) +static void gpio_isr_handler(void * arg) { if (button_press_handler != nullptr) { diff --git a/examples/light-switch-app/esp32/main/CMakeLists.txt b/examples/light-switch-app/esp32/main/CMakeLists.txt index 8a5bd77d21c740..960d2c14d4da9b 100644 --- a/examples/light-switch-app/esp32/main/CMakeLists.txt +++ b/examples/light-switch-app/esp32/main/CMakeLists.txt @@ -58,7 +58,7 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ota-requestor" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/groups-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/group-key-mgmt-server" - PRIV_REQUIRES chip QRCode bt app_update) + PRIV_REQUIRES chip QRCode bt app_update driver nvs_flash spi_flash) get_filename_component(CHIP_ROOT ${CMAKE_SOURCE_DIR}/third_party/connectedhomeip REALPATH) include("${CHIP_ROOT}/build/chip/esp32/esp32_codegen.cmake") diff --git a/examples/light-switch-app/esp32/main/DeviceCallbacks.cpp b/examples/light-switch-app/esp32/main/DeviceCallbacks.cpp index 4e4c62e2fd45c9..c99c0fe1e42f23 100644 --- a/examples/light-switch-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/light-switch-app/esp32/main/DeviceCallbacks.cpp @@ -36,8 +36,9 @@ using namespace chip::app::Clusters; void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, ClusterId clusterId, AttributeId attributeId, uint8_t mask, uint8_t type, uint16_t size, uint8_t * value) { - ESP_LOGI(TAG, "PostAttributeChangeCallback - Cluster ID: '0x%04x', EndPoint ID: '0x%02x', Attribute ID: '0x%04x'", clusterId, - endpointId, attributeId); + ESP_LOGI(TAG, + "PostAttributeChangeCallback - Cluster ID: '0x%04" PRIx32 "', EndPoint ID: '0x%02x', Attribute ID: '0x%04" PRIx32 "'", + clusterId, endpointId, attributeId); switch (clusterId) { @@ -45,7 +46,7 @@ void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Clus OnOffSwitchConfigurationAttributeChangeCallback(endpointId, attributeId, type, value, size); break; default: - ESP_LOGI(TAG, "Unhandled cluster ID: %d", clusterId); + ESP_LOGI(TAG, "Unhandled cluster ID: %" PRIu32, clusterId); break; } diff --git a/examples/light-switch-app/esp32/main/main.cpp b/examples/light-switch-app/esp32/main/main.cpp index af37ae2bad6d5b..9383817e3c095d 100644 --- a/examples/light-switch-app/esp32/main/main.cpp +++ b/examples/light-switch-app/esp32/main/main.cpp @@ -22,8 +22,8 @@ #include "AppTask.h" #include "BindingHandler.h" +#include "esp_idf_version.h" #include "esp_log.h" -#include "esp_spi_flash.h" #include "esp_system.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" @@ -44,6 +44,13 @@ #include #endif // CONFIG_ENABLE_ESP32_DEVICE_INFO_PROVIDER +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) +#include "esp_spi_flash.h" +#else +#include "esp_chip_info.h" +#include "esp_flash.h" +#endif + using namespace ::chip; using namespace ::chip::Credentials; using namespace ::chip::DeviceManager; @@ -98,7 +105,7 @@ extern "C" void app_main() CHIP_ERROR error = deviceMgr.Init(&EchoCallbacks); if (error != CHIP_NO_ERROR) { - ESP_LOGE(TAG, "device.Init() failed: %s", ErrorStr(error)); + ESP_LOGE(TAG, "device.Init() failed: %" CHIP_ERROR_FORMAT, error.Format()); return; } @@ -130,6 +137,6 @@ extern "C" void app_main() error = GetAppTask().StartAppTask(); if (error != CHIP_NO_ERROR) { - ESP_LOGE(TAG, "GetAppTask().StartAppTask() failed : %s", ErrorStr(error)); + ESP_LOGE(TAG, "GetAppTask().StartAppTask() failed : %" CHIP_ERROR_FORMAT, error.Format()); } }