Skip to content

Commit 16391c2

Browse files
committed
Merge branch 'bugfix/full_calibration_will_not_use_init_data' into 'master'
Fix bug that when we do full calibration init data bin is not used See merge request !1746
2 parents 675844c + 11c0dae commit 16391c2

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

components/esp32/Kconfig

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -940,13 +940,18 @@ endmenu # Wi-Fi
940940
menu PHY
941941

942942
config ESP32_PHY_CALIBRATION_AND_DATA_STORAGE
943-
bool "Do phy calibration and store calibration data in NVS"
943+
bool "Store phy calibration data in NVS"
944944
default y
945945
help
946946
If this option is enabled, NVS will be initialized and calibration data will be loaded from there.
947947
PHY calibration will be skipped on deep sleep wakeup. If calibration data is not found, full calibration
948-
will be performed and stored in NVS. In all other cases, only partial calibration will be performed.
948+
will be performed and stored in NVS. Normally, only partial calibration will be performed.
949+
If this option is disabled, full calibration will be performed.
949950

951+
If it's easy that your board calibrate bad data, choose 'n'.
952+
Two cases for example, you should choose 'n':
953+
1.If your board is easy to be booted up with antenna disconnected.
954+
2.Because of your board design, each time when you do calibration, the result are too unstable.
950955
If unsure, choose 'y'.
951956

952957
config ESP32_PHY_INIT_DATA_IN_PARTITION

components/esp32/phy_init.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -266,17 +266,17 @@ void esp_phy_load_cal_and_init(void)
266266
abort();
267267
}
268268

269-
#ifdef CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE
270-
esp_phy_calibration_mode_t calibration_mode = PHY_RF_CAL_PARTIAL;
271-
if (rtc_get_reset_reason(0) == DEEPSLEEP_RESET) {
272-
calibration_mode = PHY_RF_CAL_NONE;
273-
}
274269
const esp_phy_init_data_t* init_data = esp_phy_get_init_data();
275270
if (init_data == NULL) {
276271
ESP_LOGE(TAG, "failed to obtain PHY init data");
277272
abort();
278273
}
279274

275+
#ifdef CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE
276+
esp_phy_calibration_mode_t calibration_mode = PHY_RF_CAL_PARTIAL;
277+
if (rtc_get_reset_reason(0) == DEEPSLEEP_RESET) {
278+
calibration_mode = PHY_RF_CAL_NONE;
279+
}
280280
esp_err_t err = esp_phy_load_cal_data_from_nvs(cal_data);
281281
if (err != ESP_OK) {
282282
ESP_LOGW(TAG, "failed to load RF calibration data (0x%x), falling back to full calibration", err);
@@ -290,11 +290,12 @@ void esp_phy_load_cal_and_init(void)
290290
} else {
291291
err = ESP_OK;
292292
}
293-
esp_phy_release_init_data(init_data);
294293
#else
295-
esp_phy_rf_init(NULL, PHY_RF_CAL_FULL, cal_data);
294+
esp_phy_rf_init(init_data, PHY_RF_CAL_FULL, cal_data);
296295
#endif
297296

297+
esp_phy_release_init_data(init_data);
298+
298299
free(cal_data); // PHY maintains a copy of calibration data, so we can free this
299300
}
300301

0 commit comments

Comments
 (0)