From 26d99253935a5db17575f6da05e100d3ae058ad3 Mon Sep 17 00:00:00 2001 From: muhaidong Date: Thu, 10 Apr 2025 21:17:05 +0800 Subject: [PATCH] fix(phy): fix phy data partition restoring default fails issue Closes https://github.com/espressif/esp-idf/issues/14698 --- components/esp_phy/src/phy_init.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/components/esp_phy/src/phy_init.c b/components/esp_phy/src/phy_init.c index dc6cce167c..8ba871652a 100644 --- a/components/esp_phy/src/phy_init.c +++ b/components/esp_phy/src/phy_init.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -478,6 +478,13 @@ const esp_phy_init_data_t* esp_phy_get_init_data(void) assert(memcmp(init_data_store + init_data_store_length - sizeof(phy_init_magic_post), PHY_INIT_MAGIC, sizeof(phy_init_magic_post)) == 0); + err = esp_partition_erase_range(partition, 0, partition->size); + if (err != ESP_OK) { + ESP_LOGE(TAG, "failed to erase partition (0x%x)!", err); + free(init_data_store); + return NULL; + } + // write default data err = esp_partition_write(partition, 0, init_data_store, init_data_store_length); if (err != ESP_OK) {