From 41697953cceb5b6fa006995b2096ba9e8e1db797 Mon Sep 17 00:00:00 2001 From: Shubham Patil Date: Wed, 25 Jan 2023 20:41:15 +0530 Subject: [PATCH] [ESP32] Changes to support esp-idf v5.0 in lighting-app (#24589) * [ESP32] Add spi_flash dependency and fixed a typo In idf v4.4.3 spi_flash is pulled in through nvs_flash but in v5.0 is is not, so need to add it explicitly. Also, v4.4.3 have mdns component present in repository but in v5.0 it is moved out to idf component registry and needs to be pulled in using idf component manager * [ESP32] Changes in lighting-app for esp-idf v5.0 support Using the older version of led_strip, v1.0.0-alpha, which is present in idf v4.4.3 to avoid putting in more ifdefs in the code. Fixed few format specifiers in the logs * Fixed format specifiers in logs in common code * [ESP32] esp-idf v5.0 support changes, fixed format specifiers and fixed the error codes where it would have been uninitialized * Fix linter errors * restyled --- config/esp32/components/chip/CMakeLists.txt | 6 +-- config/esp32/components/chip/Kconfig | 2 +- .../esp32/components/chip/idf_component.yml | 6 +++ examples/lighting-app/esp32/CMakeLists.txt | 1 - .../lighting-app/esp32/main/CMakeLists.txt | 2 +- .../esp32/main/DeviceCallbacks.cpp | 14 +++--- .../lighting-app/esp32/main/Kconfig.projbuild | 6 ++- .../lighting-app/esp32/main/LEDWidget.cpp | 16 +------ .../lighting-app/esp32/main/idf_component.yml | 2 + .../esp32/main/include/LEDWidget.h | 4 -- .../lighting-app/esp32/sdkconfig.defaults | 3 ++ .../esp32/sdkconfig.defaults.esp32c2 | 19 ++++++++ .../platform/esp32/lock/BoltLockManager.cpp | 2 +- .../fault-injection-server.cpp | 4 +- src/app/util/mock/attribute-storage.cpp | 2 +- .../tests/TestReliableMessageProtocol.cpp | 8 ++-- .../ESP32/ConfigurationManagerImpl.cpp | 48 ++++++++++++------- src/platform/ESP32/ESP32Config.cpp | 2 +- src/platform/ESP32/OTAImageProcessorImpl.cpp | 4 +- src/platform/ESP32/SystemTimeSupport.cpp | 5 +- .../ESP32/route_hook/ESP32RouteHook.c | 4 +- 21 files changed, 97 insertions(+), 63 deletions(-) create mode 100644 config/esp32/components/chip/idf_component.yml create mode 100644 examples/lighting-app/esp32/main/idf_component.yml create mode 100644 examples/lighting-app/esp32/sdkconfig.defaults.esp32c2 diff --git a/config/esp32/components/chip/CMakeLists.txt b/config/esp32/components/chip/CMakeLists.txt index d7cb69a6a8fa34..fcd62b8757a36c 100644 --- a/config/esp32/components/chip/CMakeLists.txt +++ b/config/esp32/components/chip/CMakeLists.txt @@ -31,10 +31,10 @@ endif() include(${CMAKE_CURRENT_LIST_DIR}/ota-image.cmake) -set(CHIP_REQURIE_COMPONENTS freertos lwip bt mbedtls fatfs app_update console openthread nvs_flash) +set(CHIP_REQUIRE_COMPONENTS freertos lwip bt mbedtls fatfs app_update console openthread nvs_flash spi_flash) if((NOT "${IDF_TARGET}" STREQUAL "esp32h2") AND (NOT "${IDF_TARGET}" STREQUAL "esp32c2")) - list(APPEND CHIP_REQURIE_COMPONENTS mdns) + list(APPEND CHIP_REQUIRE_COMPONENTS mdns) endif() if (NOT CMAKE_BUILD_EARLY_EXPANSION) @@ -49,7 +49,7 @@ if (NOT CMAKE_BUILD_EARLY_EXPANSION) endif() idf_component_register(SRCS chip.c chip.cpp - PRIV_REQUIRES ${CHIP_REQURIE_COMPONENTS}) + PRIV_REQUIRES ${CHIP_REQUIRE_COMPONENTS}) # Prepare initial args file (lacking compile flags) # This will be saved as args.gn.in diff --git a/config/esp32/components/chip/Kconfig b/config/esp32/components/chip/Kconfig index dea6109649232f..34b2e0fb043345 100644 --- a/config/esp32/components/chip/Kconfig +++ b/config/esp32/components/chip/Kconfig @@ -673,7 +673,7 @@ menu "CHIP Device Layer" config ENABLE_ESP32_LOCATIONCAPABILITY depends on ENABLE_ESP32_FACTORY_DATA_PROVIDER - bool "Enable ESP32 Device LocationCapability " + bool "Enable ESP32 Device LocationCapability" default n help Enable ESP32 Device LocationCapability diff --git a/config/esp32/components/chip/idf_component.yml b/config/esp32/components/chip/idf_component.yml new file mode 100644 index 00000000000000..e47917975ce13d --- /dev/null +++ b/config/esp32/components/chip/idf_component.yml @@ -0,0 +1,6 @@ +## IDF Component Manager Manifest File +dependencies: + espressif/mdns: + version: "^1.0.3" + rules: + - if: "idf_version >=5.0" diff --git a/examples/lighting-app/esp32/CMakeLists.txt b/examples/lighting-app/esp32/CMakeLists.txt index 746f70379ef1c1..92f2a10fec2f0b 100644 --- a/examples/lighting-app/esp32/CMakeLists.txt +++ b/examples/lighting-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" ) project(chip-lighting-app) diff --git a/examples/lighting-app/esp32/main/CMakeLists.txt b/examples/lighting-app/esp32/main/CMakeLists.txt index e7ea6b0498bce4..8b7a6e916f38a5 100644 --- a/examples/lighting-app/esp32/main/CMakeLists.txt +++ b/examples/lighting-app/esp32/main/CMakeLists.txt @@ -67,7 +67,7 @@ set(SRC_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/group-key-mgmt-server" ) -set(PRIV_REQUIRES_LIST chip QRCode bt led_strip app_update openthread driver nvs_flash) +set(PRIV_REQUIRES_LIST chip QRCode bt led_strip app_update openthread driver nvs_flash spi_flash) if (CONFIG_ENABLE_PW_RPC) # Append additional directories for RPC build diff --git a/examples/lighting-app/esp32/main/DeviceCallbacks.cpp b/examples/lighting-app/esp32/main/DeviceCallbacks.cpp index bc1174f4676358..c61c3d3d5054b5 100644 --- a/examples/lighting-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/lighting-app/esp32/main/DeviceCallbacks.cpp @@ -47,8 +47,9 @@ using namespace chip::app::Clusters; 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); switch (clusterId) { @@ -67,7 +68,7 @@ void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Clus #endif default: - ESP_LOGI(TAG, "Unhandled cluster ID: %d", clusterId); + ESP_LOGI(TAG, "Unhandled cluster ID: %" PRIu32, clusterId); break; } @@ -76,7 +77,8 @@ void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Clus void AppDeviceCallbacks::OnOnOffPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { - VerifyOrExit(attributeId == OnOff::Attributes::OnOff::Id, ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04x", attributeId)); + VerifyOrExit(attributeId == OnOff::Attributes::OnOff::Id, + ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04" PRIx32 "'", attributeId)); VerifyOrExit(endpointId == 1, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); AppLED.Set(*value); @@ -88,7 +90,7 @@ void AppDeviceCallbacks::OnOnOffPostAttributeChangeCallback(EndpointId endpointI void AppDeviceCallbacks::OnLevelControlAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { VerifyOrExit(attributeId == 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, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); AppLED.SetBrightness(*value); @@ -105,7 +107,7 @@ void AppDeviceCallbacks::OnColorControlAttributeChangeCallback(EndpointId endpoi VerifyOrExit(attributeId == ColorControl::Attributes::CurrentHue::Id || attributeId == ColorControl::Attributes::CurrentSaturation::Id, - ESP_LOGI(TAG, "Unhandled AttributeId ID: '0x%04x", attributeId)); + ESP_LOGI(TAG, "Unhandled AttributeId ID: '0x%04" PRIx32 "'", attributeId)); VerifyOrExit(endpointId == 1, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); if (attributeId == ColorControl::Attributes::CurrentHue::Id) diff --git a/examples/lighting-app/esp32/main/Kconfig.projbuild b/examples/lighting-app/esp32/main/Kconfig.projbuild index 43d7d9f0e75381..b41b4ef0e4fb81 100644 --- a/examples/lighting-app/esp32/main/Kconfig.projbuild +++ b/examples/lighting-app/esp32/main/Kconfig.projbuild @@ -25,6 +25,7 @@ menu "Demo" default DEVICE_TYPE_ESP32_DEVKITC if IDF_TARGET_ESP32 default DEVICE_TYPE_ESP32_C3_DEVKITM if IDF_TARGET_ESP32C3 default DEVICE_TYPE_ESP32_S3_DEVKITM if IDF_TARGET_ESP32S3 + default DEVICE_TYPE_ESP32_C2_DEVKITM if IDF_TARGET_ESP32C2 help Specifies the type of ESP32 device. @@ -46,6 +47,9 @@ menu "Demo" config DEVICE_TYPE_ESP32H2_DEVKITC bool "ESP32H2-DevKitC" depends on IDF_TARGET_ESP32H2 + config DEVICE_TYPE_ESP32_C2_DEVKITM + bool "ESP32C2-DevKitM" + depends on IDF_TARGET_ESP32C2 endchoice choice LED_TYPE @@ -76,7 +80,7 @@ menu "Demo" int "LED GPIO number" range 0 48 default 26 if DEVICE_TYPE_ESP32_WROVER_KIT - default 8 if DEVICE_TYPE_ESP32_C3_DEVKITM || DEVICE_TYPE_ESP32H2_DEVKITC + default 8 if DEVICE_TYPE_ESP32_C3_DEVKITM || DEVICE_TYPE_ESP32H2_DEVKITC || DEVICE_TYPE_ESP32_C2_DEVKITM default 48 if DEVICE_TYPE_ESP32_S3_DEVKITM default 5 help diff --git a/examples/lighting-app/esp32/main/LEDWidget.cpp b/examples/lighting-app/esp32/main/LEDWidget.cpp index bf2221b26446c9..6e65bec7c0c1e5 100644 --- a/examples/lighting-app/esp32/main/LEDWidget.cpp +++ b/examples/lighting-app/esp32/main/LEDWidget.cpp @@ -27,14 +27,6 @@ void LEDWidget::Init(void) mBrightness = UINT8_MAX; #if CONFIG_LED_TYPE_RMT -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) - led_strip_config_t strip_config = { - .strip_gpio_num = CONFIG_LED_GPIO, - .max_leds = 1, - }; - - led_strip_new_rmt_device(&strip_config, &mStrip); -#else rmt_config_t config = RMT_DEFAULT_CONFIG_TX((gpio_num_t) CONFIG_LED_GPIO, (rmt_channel_t) CONFIG_LED_RMT_CHANNEL); led_strip_config_t strip_config = LED_STRIP_DEFAULT_CONFIG(1, (led_strip_dev_t) config.channel); @@ -42,8 +34,7 @@ void LEDWidget::Init(void) rmt_config(&config); rmt_driver_install(config.channel, 0, 0); - mStrip = led_strip_new_rmt_ws2812(&strip_config); -#endif + mStrip = led_strip_new_rmt_ws2812(&strip_config); mHue = 0; mSaturation = 0; #else @@ -131,13 +122,8 @@ void LEDWidget::DoSet(void) { HsvColor_t hsv = { mHue, mSaturation, brightness }; RgbColor_t rgb = HsvToRgb(hsv); -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) - led_strip_set_pixel(mStrip, 0, rgb.r, rgb.g, rgb.b); - led_strip_refresh(mStrip); -#else mStrip->set_pixel(mStrip, 0, rgb.r, rgb.g, rgb.b); mStrip->refresh(mStrip, 100); -#endif } #else ESP_LOGI(TAG, "DoSet to GPIO number %d", mGPIONum); diff --git a/examples/lighting-app/esp32/main/idf_component.yml b/examples/lighting-app/esp32/main/idf_component.yml new file mode 100644 index 00000000000000..1c539b8eb57668 --- /dev/null +++ b/examples/lighting-app/esp32/main/idf_component.yml @@ -0,0 +1,2 @@ +dependencies: + espressif/led_strip: "^1.0.0-alpha" diff --git a/examples/lighting-app/esp32/main/include/LEDWidget.h b/examples/lighting-app/esp32/main/include/LEDWidget.h index f9d00a2b6882a9..c390d63ac1024f 100644 --- a/examples/lighting-app/esp32/main/include/LEDWidget.h +++ b/examples/lighting-app/esp32/main/include/LEDWidget.h @@ -50,11 +50,7 @@ class LEDWidget #if CONFIG_LED_TYPE_RMT uint8_t mHue; uint8_t mSaturation; -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) - led_strip_handle_t mStrip; -#else led_strip_t * mStrip; -#endif #else gpio_num_t mGPIONum; #endif diff --git a/examples/lighting-app/esp32/sdkconfig.defaults b/examples/lighting-app/esp32/sdkconfig.defaults index 64623b292bfdd3..bb74fc99f423d7 100644 --- a/examples/lighting-app/esp32/sdkconfig.defaults +++ b/examples/lighting-app/esp32/sdkconfig.defaults @@ -52,3 +52,6 @@ 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/lighting-app/esp32/sdkconfig.defaults.esp32c2 b/examples/lighting-app/esp32/sdkconfig.defaults.esp32c2 new file mode 100644 index 00000000000000..6cb90db4f55b9d --- /dev/null +++ b/examples/lighting-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/platform/esp32/lock/BoltLockManager.cpp b/examples/platform/esp32/lock/BoltLockManager.cpp index 6115c15b1bf75d..ad4e7ba2b96831 100644 --- a/examples/platform/esp32/lock/BoltLockManager.cpp +++ b/examples/platform/esp32/lock/BoltLockManager.cpp @@ -330,7 +330,7 @@ void BoltLockManager::ActuatorMovementTimerEventHandler(AppEvent * aEvent) lock->mAutoLockTimerArmed = true; - ESP_LOGI(TAG, "Auto Re-lock enabled. Will be triggered in %u seconds", lock->mAutoLockDuration); + ESP_LOGI(TAG, "Auto Re-lock enabled. Will be triggered in %" PRIu32 " seconds", lock->mAutoLockDuration); } } } diff --git a/src/app/clusters/fault-injection-server/fault-injection-server.cpp b/src/app/clusters/fault-injection-server/fault-injection-server.cpp index 925640c8ce8d00..0b37ca757f20b2 100644 --- a/src/app/clusters/fault-injection-server/fault-injection-server.cpp +++ b/src/app/clusters/fault-injection-server/fault-injection-server.cpp @@ -80,7 +80,7 @@ bool emberAfFaultInjectionClusterFailAtFaultCallback(CommandHandler * commandObj if (faultInjectionMgr != nullptr) { - ChipLogProgress(Zcl, "FaultInjection: Configure a fault of type: %d and Id: %d to be triggered deterministically", + ChipLogProgress(Zcl, "FaultInjection: Configure a fault of type: %u and Id: %" PRIu32 " to be triggered deterministically", static_cast(commandData.type), commandData.id); int32_t err = faultInjectionMgr->FailAtFault(commandData.id, commandData.numCallsToSkip, commandData.numCallsToFail, commandData.takeMutex); @@ -126,7 +126,7 @@ bool emberAfFaultInjectionClusterFailRandomlyAtFaultCallback(CommandHandler * co if (faultInjectionMgr != nullptr) { - ChipLogProgress(Zcl, "FaultInjection: Configure a fault of type: %d and Id: %d to be triggered randomly", + ChipLogProgress(Zcl, "FaultInjection: Configure a fault of type: %u and Id: %" PRIu32 " to be triggered randomly", static_cast(commandData.type), commandData.id); int32_t err = faultInjectionMgr->FailRandomlyAtFault(commandData.id, commandData.percentage); diff --git a/src/app/util/mock/attribute-storage.cpp b/src/app/util/mock/attribute-storage.cpp index 47a3afb296c0d9..d03f7b51161902 100644 --- a/src/app/util/mock/attribute-storage.cpp +++ b/src/app/util/mock/attribute-storage.cpp @@ -278,7 +278,7 @@ CHIP_ERROR ReadSingleMockClusterData(FabricIndex aAccessingFabricIndex, const Co bool dataExists = (emberAfGetServerAttributeIndexByAttributeId(aPath.mEndpointId, aPath.mClusterId, aPath.mAttributeId) != UINT16_MAX); - ChipLogDetail(DataManagement, "Reading Mock Endpoint %" PRIx32 "Mock Cluster %" PRIx32 ", Field %" PRIx32 " is dirty", + ChipLogDetail(DataManagement, "Reading Mock Endpoint %x Mock Cluster %" PRIx32 ", Field %" PRIx32 " is dirty", aPath.mEndpointId, aPath.mClusterId, aPath.mAttributeId); if (!dataExists) diff --git a/src/messaging/tests/TestReliableMessageProtocol.cpp b/src/messaging/tests/TestReliableMessageProtocol.cpp index eb8661550376df..d6fe53c17d572f 100644 --- a/src/messaging/tests/TestReliableMessageProtocol.cpp +++ b/src/messaging/tests/TestReliableMessageProtocol.cpp @@ -366,7 +366,7 @@ void CheckResendApplicationMessage(nlTestSuite * inSuite, void * inContext) ctx.GetIOContext().DriveIOUntil(1000_ms32, [&] { return loopback.mSentMessageCount >= 2; }); now = System::SystemClock().GetMonotonicTimestamp(); timeoutTime = now - startTime; - ChipLogProgress(Test, "Attempt #1 Timeout : %d ms", timeoutTime.count()); + ChipLogProgress(Test, "Attempt #1 Timeout : %" PRIu32 "ms", timeoutTime.count()); expectedBackoff = &theBackoffComplianceTestVector[0]; NL_TEST_ASSERT(inSuite, timeoutTime >= expectedBackoff->backoffMin - margin); @@ -383,7 +383,7 @@ void CheckResendApplicationMessage(nlTestSuite * inSuite, void * inContext) ctx.GetIOContext().DriveIOUntil(1000_ms32, [&] { return loopback.mSentMessageCount >= 3; }); now = System::SystemClock().GetMonotonicTimestamp(); timeoutTime = now - startTime; - ChipLogProgress(Test, "Attempt #2 Timeout : %d ms", timeoutTime.count()); + ChipLogProgress(Test, "Attempt #2 Timeout : %" PRIu32 "ms", timeoutTime.count()); expectedBackoff = &theBackoffComplianceTestVector[1]; NL_TEST_ASSERT(inSuite, timeoutTime >= expectedBackoff->backoffMin - margin); @@ -400,7 +400,7 @@ void CheckResendApplicationMessage(nlTestSuite * inSuite, void * inContext) ctx.GetIOContext().DriveIOUntil(1000_ms32, [&] { return loopback.mSentMessageCount >= 4; }); now = System::SystemClock().GetMonotonicTimestamp(); timeoutTime = now - startTime; - ChipLogProgress(Test, "Attempt #3 Timeout : %d ms", timeoutTime.count()); + ChipLogProgress(Test, "Attempt #3 Timeout : %" PRIu32 "ms", timeoutTime.count()); expectedBackoff = &theBackoffComplianceTestVector[2]; NL_TEST_ASSERT(inSuite, timeoutTime >= expectedBackoff->backoffMin - margin); @@ -417,7 +417,7 @@ void CheckResendApplicationMessage(nlTestSuite * inSuite, void * inContext) ctx.GetIOContext().DriveIOUntil(1500_ms32, [&] { return loopback.mSentMessageCount >= 5; }); now = System::SystemClock().GetMonotonicTimestamp(); timeoutTime = now - startTime; - ChipLogProgress(Test, "Attempt #4 Timeout : %d ms", timeoutTime.count()); + ChipLogProgress(Test, "Attempt #4 Timeout : %" PRIu32 "ms", timeoutTime.count()); expectedBackoff = &theBackoffComplianceTestVector[3]; NL_TEST_ASSERT(inSuite, timeoutTime >= expectedBackoff->backoffMin - margin); diff --git a/src/platform/ESP32/ConfigurationManagerImpl.cpp b/src/platform/ESP32/ConfigurationManagerImpl.cpp index 88005bda31a6d4..20dc895b36d047 100644 --- a/src/platform/ESP32/ConfigurationManagerImpl.cpp +++ b/src/platform/ESP32/ConfigurationManagerImpl.cpp @@ -71,19 +71,22 @@ CHIP_ERROR ConfigurationManagerImpl::Init() { ChipLogError(DeviceLayer, "CONFIG_NVS_ENCRYPTION is enabled, but no partition with subtype nvs_keys found in the partition table."); - SuccessOrExit(MapConfigError(esp_err)); + err = MapConfigError(esp_err); + SuccessOrExit(err); } esp_err = nvs_flash_read_security_cfg(key_part, &cfg); if (esp_err == ESP_ERR_NVS_KEYS_NOT_INITIALIZED) { ChipLogError(DeviceLayer, "NVS key partition empty"); - SuccessOrExit(MapConfigError(esp_err)); + err = MapConfigError(esp_err); + SuccessOrExit(err); } else if (esp_err != ESP_OK) { ChipLogError(DeviceLayer, "Failed to read NVS security cfg, err:0x%02x", esp_err); - SuccessOrExit(MapConfigError(esp_err)); + err = MapConfigError(esp_err); + SuccessOrExit(err); } // Securely initialize the nvs partitions, @@ -93,7 +96,8 @@ CHIP_ERROR ConfigurationManagerImpl::Init() { ChipLogError(DeviceLayer, "Failed to initialize NVS partition %s err:0x%02x", CHIP_DEVICE_CONFIG_CHIP_FACTORY_NAMESPACE_PARTITION, esp_err); - SuccessOrExit(MapConfigError(esp_err)); + err = MapConfigError(esp_err); + SuccessOrExit(err); } esp_err = nvs_flash_secure_init_partition(CHIP_DEVICE_CONFIG_CHIP_CONFIG_NAMESPACE_PARTITION, &cfg); @@ -101,7 +105,8 @@ CHIP_ERROR ConfigurationManagerImpl::Init() { ChipLogError(DeviceLayer, "Failed to initialize NVS partition %s err:0x%02x", CHIP_DEVICE_CONFIG_CHIP_CONFIG_NAMESPACE_PARTITION, esp_err); - SuccessOrExit(MapConfigError(esp_err)); + err = MapConfigError(esp_err); + SuccessOrExit(err); } esp_err = nvs_flash_secure_init_partition(CHIP_DEVICE_CONFIG_CHIP_COUNTERS_NAMESPACE_PARTITION, &cfg); @@ -109,19 +114,23 @@ CHIP_ERROR ConfigurationManagerImpl::Init() { ChipLogError(DeviceLayer, "Failed to initialize NVS partition %s err:0x%02x", CHIP_DEVICE_CONFIG_CHIP_COUNTERS_NAMESPACE_PARTITION, esp_err); - SuccessOrExit(MapConfigError(esp_err)); + err = MapConfigError(esp_err); + SuccessOrExit(err); } #else // Initialize the nvs partitions, // nvs_flash_init_partition() will initialize the partition only if it is not already initialized. - esp_err_t esp_err = nvs_flash_init_partition(CHIP_DEVICE_CONFIG_CHIP_FACTORY_NAMESPACE_PARTITION); - SuccessOrExit(MapConfigError(esp_err)); - esp_err = nvs_flash_init_partition(CHIP_DEVICE_CONFIG_CHIP_CONFIG_NAMESPACE_PARTITION); - SuccessOrExit(MapConfigError(esp_err)); - esp_err = nvs_flash_init_partition(CHIP_DEVICE_CONFIG_CHIP_COUNTERS_NAMESPACE_PARTITION); - SuccessOrExit(MapConfigError(esp_err)); - esp_err = nvs_flash_init_partition(CHIP_DEVICE_CONFIG_CHIP_KVS_NAMESPACE_PARTITION); - SuccessOrExit(MapConfigError(esp_err)); + err = MapConfigError(nvs_flash_init_partition(CHIP_DEVICE_CONFIG_CHIP_FACTORY_NAMESPACE_PARTITION)); + SuccessOrExit(err); + + err = MapConfigError(nvs_flash_init_partition(CHIP_DEVICE_CONFIG_CHIP_CONFIG_NAMESPACE_PARTITION)); + SuccessOrExit(err); + + err = MapConfigError(nvs_flash_init_partition(CHIP_DEVICE_CONFIG_CHIP_COUNTERS_NAMESPACE_PARTITION)); + SuccessOrExit(err); + + err = MapConfigError(nvs_flash_init_partition(CHIP_DEVICE_CONFIG_CHIP_KVS_NAMESPACE_PARTITION)); + SuccessOrExit(err); #endif // Force initialization of NVS namespaces if they doesn't already exist. @@ -188,7 +197,14 @@ CHIP_ERROR ConfigurationManagerImpl::StoreTotalOperationalHours(uint32_t totalOp CHIP_ERROR ConfigurationManagerImpl::GetSoftwareVersionString(char * buf, size_t bufSize) { memset(buf, 0, bufSize); - const esp_app_desc_t * appDescription = esp_ota_get_app_description(); + const esp_app_desc_t * appDescription = NULL; + +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) + appDescription = esp_app_get_description(); +#else + appDescription = esp_ota_get_app_description(); +#endif + ReturnErrorCodeIf(bufSize < sizeof(appDescription->version), CHIP_ERROR_BUFFER_TOO_SMALL); ReturnErrorCodeIf(sizeof(appDescription->version) > ConfigurationManager::kMaxSoftwareVersionStringLength, CHIP_ERROR_INTERNAL); strcpy(buf, appDescription->version); @@ -215,7 +231,7 @@ CHIP_ERROR ConfigurationManagerImpl::GetLocationCapability(uint8_t & location) return err; #else - location = static_cast(chip::app::Clusters::GeneralCommissioning::RegulatoryLocationType::kIndoor); + location = static_cast(chip::app::Clusters::GeneralCommissioning::RegulatoryLocationType::kIndoor); return CHIP_NO_ERROR; #endif } diff --git a/src/platform/ESP32/ESP32Config.cpp b/src/platform/ESP32/ESP32Config.cpp index d47af60778e155..a536d46ef722c3 100644 --- a/src/platform/ESP32/ESP32Config.cpp +++ b/src/platform/ESP32/ESP32Config.cpp @@ -339,7 +339,7 @@ CHIP_ERROR ESP32Config::WriteConfigValueBin(Key key, const uint8_t * data, size_ // Commit the value to the persistent store. ReturnMappedErrorOnFailure(nvs_commit(handle)); - ChipLogProgress(DeviceLayer, "NVS set: %s/%s = (blob length %" PRId32 ")", StringOrNullMarker(key.Namespace), + ChipLogProgress(DeviceLayer, "NVS set: %s/%s = (blob length %u)", StringOrNullMarker(key.Namespace), StringOrNullMarker(key.Name), dataLen); return CHIP_NO_ERROR; } diff --git a/src/platform/ESP32/OTAImageProcessorImpl.cpp b/src/platform/ESP32/OTAImageProcessorImpl.cpp index ccf8c0498663bd..a1bd313e75f378 100644 --- a/src/platform/ESP32/OTAImageProcessorImpl.cpp +++ b/src/platform/ESP32/OTAImageProcessorImpl.cpp @@ -173,7 +173,7 @@ void OTAImageProcessorImpl::HandleFinalize(intptr_t context) return; } imageProcessor->ReleaseBlock(); - ChipLogProgress(SoftwareUpdate, "OTA image downloaded to offset 0x%x", imageProcessor->mOTAUpdatePartition->address); + ChipLogProgress(SoftwareUpdate, "OTA image downloaded to offset 0x%" PRIx32, imageProcessor->mOTAUpdatePartition->address); PostOTAStateChangeEvent(DeviceLayer::kOtaDownloadComplete); } @@ -241,7 +241,7 @@ void OTAImageProcessorImpl::HandleApply(intptr_t context) PostOTAStateChangeEvent(DeviceLayer::kOtaApplyFailed); return; } - ESP_LOGI(TAG, "Applying, Boot partition set offset:0x%x", imageProcessor->mOTAUpdatePartition->address); + ESP_LOGI(TAG, "Applying, Boot partition set offset:0x%" PRIx32, imageProcessor->mOTAUpdatePartition->address); PostOTAStateChangeEvent(DeviceLayer::kOtaApplyComplete); diff --git a/src/platform/ESP32/SystemTimeSupport.cpp b/src/platform/ESP32/SystemTimeSupport.cpp index 33bec43435bc35..2dc288145ce497 100644 --- a/src/platform/ESP32/SystemTimeSupport.cpp +++ b/src/platform/ESP32/SystemTimeSupport.cpp @@ -95,8 +95,9 @@ CHIP_ERROR ClockImpl::SetClock_RealTime(Microseconds64 aNewCurTime) const time_t timep = tv.tv_sec; struct tm calendar; localtime_r(&timep, &calendar); - ChipLogProgress(DeviceLayer, "Real time clock set to %ld (%04d/%02d/%02d %02d:%02d:%02d UTC)", tv.tv_sec, calendar.tm_year, - calendar.tm_mon, calendar.tm_mday, calendar.tm_hour, calendar.tm_min, calendar.tm_sec); + ChipLogProgress(DeviceLayer, "Real time clock set to %lld (%04d/%02d/%02d %02d:%02d:%02d UTC)", + static_cast(tv.tv_sec), calendar.tm_year, calendar.tm_mon, calendar.tm_mday, calendar.tm_hour, + calendar.tm_min, calendar.tm_sec); } #endif // CHIP_PROGRESS_LOGGING return CHIP_NO_ERROR; diff --git a/src/platform/ESP32/route_hook/ESP32RouteHook.c b/src/platform/ESP32/route_hook/ESP32RouteHook.c index b6acadeda48eac..01f58bfdb3db7b 100644 --- a/src/platform/ESP32/route_hook/ESP32RouteHook.c +++ b/src/platform/ESP32/route_hook/ESP32RouteHook.c @@ -105,10 +105,10 @@ static void ra_recv_handler(struct netif * netif, const uint8_t * icmp_payload, route.prefix = prefix; route.preference = preference; route.lifetime_seconds = lwip_ntohl(rio_header.route_lifetime); - ESP_LOGI(TAG, "prefix %s lifetime %u\n", ip6addr_ntoa(&prefix), route.lifetime_seconds); + ESP_LOGI(TAG, "prefix %s lifetime %" PRIu32, ip6addr_ntoa(&prefix), route.lifetime_seconds); if (esp_route_table_add_route_entry(&route) == NULL) { - ESP_LOGI(TAG, "Failed to add route table entry\n"); + ESP_LOGI(TAG, "Failed to add route table entry"); } } }