Skip to content

Commit a83c40e

Browse files
author
Zim Kalinowski
committed
Merge branch 'feature/mac_crc_v4.4' into 'release/v4.4'
esp_hw_support(esp32): If the MAC_FACTORY CRC check fails, then INVALID_CRC instead of abort (v4.4) See merge request espressif/esp-idf!22115
2 parents 9160670 + c1ea064 commit a83c40e

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

components/esp_hw_support/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ menu "Hardware Settings"
1414

1515
# Insert chip-specific MAC config
1616
rsource "./port/$IDF_TARGET/Kconfig.mac"
17+
18+
config ESP_MAC_IGNORE_MAC_CRC_ERROR
19+
bool "Ignore MAC CRC error (not recommended)"
20+
depends on IDF_TARGET_ESP32
21+
default n
22+
help
23+
If you have an invalid MAC CRC (ESP_ERR_INVALID_CRC) problem
24+
and you still want to use this chip, you can enable this option to bypass such an error.
25+
This applies to both MAC_FACTORY and CUSTOM_MAC efuses.
1726
endmenu
1827

1928
menu "Sleep Config"

components/esp_hw_support/mac_addr.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ esp_err_t esp_efuse_mac_get_custom(uint8_t *mac)
9797

9898
if (efuse_crc != calc_crc) {
9999
ESP_LOGE(TAG, "Base MAC address from BLK3 of EFUSE CRC error, efuse_crc = 0x%02x; calc_crc = 0x%02x", efuse_crc, calc_crc);
100+
#ifdef CONFIG_ESP_MAC_IGNORE_MAC_CRC_ERROR
101+
ESP_LOGW(TAG, "Ignore MAC CRC error");
102+
#else
100103
return ESP_ERR_INVALID_CRC;
104+
#endif
101105
}
102106
return ESP_OK;
103107
#endif
@@ -133,7 +137,11 @@ esp_err_t esp_efuse_mac_get_default(uint8_t *mac)
133137
return ESP_OK;
134138
} else {
135139
ESP_LOGE(TAG, "Base MAC address from BLK0 of EFUSE CRC error, efuse_crc = 0x%02x; calc_crc = 0x%02x", efuse_crc, calc_crc);
136-
abort();
140+
#ifdef CONFIG_ESP_MAC_IGNORE_MAC_CRC_ERROR
141+
ESP_LOGW(TAG, "Ignore MAC CRC error");
142+
#else
143+
return ESP_ERR_INVALID_CRC;
144+
#endif
137145
}
138146
}
139147
#endif // CONFIG_IDF_TARGET_ESP32

components/esp_phy/src/phy_init.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ static esp_err_t load_cal_data_from_nvs_handle(nvs_handle_t handle,
594594
return ESP_ERR_INVALID_SIZE;
595595
}
596596
uint8_t sta_mac[6];
597-
esp_efuse_mac_get_default(sta_mac);
597+
ESP_ERROR_CHECK(esp_efuse_mac_get_default(sta_mac));
598598
if (memcmp(sta_mac, cal_data_mac, sizeof(sta_mac)) != 0) {
599599
ESP_LOGE(TAG, "%s: calibration data MAC check failed: expected " \
600600
MACSTR ", found " MACSTR,
@@ -626,7 +626,7 @@ static esp_err_t store_cal_data_to_nvs_handle(nvs_handle_t handle,
626626
}
627627

628628
uint8_t sta_mac[6];
629-
esp_efuse_mac_get_default(sta_mac);
629+
ESP_ERROR_CHECK(esp_efuse_mac_get_default(sta_mac));
630630
err = nvs_set_blob(handle, PHY_CAL_MAC_KEY, sta_mac, sizeof(sta_mac));
631631
if (err != ESP_OK) {
632632
ESP_LOGE(TAG, "%s: store calibration mac failed(0x%x)\n", __func__, err);
@@ -717,7 +717,7 @@ void esp_phy_load_cal_and_init(void)
717717
calibration_mode = PHY_RF_CAL_FULL;
718718
}
719719

720-
esp_efuse_mac_get_default(sta_mac);
720+
ESP_ERROR_CHECK(esp_efuse_mac_get_default(sta_mac));
721721
memcpy(cal_data->mac, sta_mac, 6);
722722
esp_err_t ret = register_chipv7_phy(init_data, cal_data, calibration_mode);
723723
if (ret == ESP_CAL_DATA_CHECK_FAIL) {

0 commit comments

Comments
 (0)