]> granicus.if.org Git - esp-idf/commitdiff
Fix bug that when we do full calibration init data bin is not used
authorJack <jack@espressif.com>
Thu, 4 Jan 2018 03:48:24 +0000 (11:48 +0800)
committerJack <jack@espressif.com>
Tue, 9 Jan 2018 07:31:34 +0000 (15:31 +0800)
components/esp32/Kconfig
components/esp32/phy_init.c

index 888bba17ebb1bf7a675a73c48a605871649271a4..57b0599d9d06f461a1ecbbdde16b6fd0e7df0849 100644 (file)
@@ -940,13 +940,18 @@ endmenu  # Wi-Fi
 menu PHY
 
 config ESP32_PHY_CALIBRATION_AND_DATA_STORAGE
-    bool "Do phy calibration and store calibration data in NVS"
+    bool "Store phy calibration data in NVS"
     default y
     help
         If this option is enabled, NVS will be initialized and calibration data will be loaded from there.
         PHY calibration will be skipped on deep sleep wakeup. If calibration data is not found, full calibration
-        will be performed and stored in NVS. In all other cases, only partial calibration will be performed. 
+        will be performed and stored in NVS. Normally, only partial calibration will be performed. 
+        If this option is disabled, full calibration will be performed.
 
+        If it's easy that your board calibrate bad data, choose 'n'.
+        Two cases for example, you should choose 'n':
+        1.If your board is easy to be booted up with antenna disconnected.
+        2.Because of your board design, each time when you do calibration, the result are too unstable.
         If unsure, choose 'y'.
 
 config ESP32_PHY_INIT_DATA_IN_PARTITION
index 94a89afd670d9a74735af14853dacd78e9097ca9..280a4f09427cc801aaf543eb6c5ffeec2526ef01 100644 (file)
@@ -266,17 +266,17 @@ void esp_phy_load_cal_and_init(void)
         abort();
     }
 
-#ifdef CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE
-    esp_phy_calibration_mode_t calibration_mode = PHY_RF_CAL_PARTIAL;
-    if (rtc_get_reset_reason(0) == DEEPSLEEP_RESET) {
-        calibration_mode = PHY_RF_CAL_NONE;
-    }
     const esp_phy_init_data_t* init_data = esp_phy_get_init_data();
     if (init_data == NULL) {
         ESP_LOGE(TAG, "failed to obtain PHY init data");
         abort();
     }
 
+#ifdef CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE
+    esp_phy_calibration_mode_t calibration_mode = PHY_RF_CAL_PARTIAL;
+    if (rtc_get_reset_reason(0) == DEEPSLEEP_RESET) {
+        calibration_mode = PHY_RF_CAL_NONE;
+    }
     esp_err_t err = esp_phy_load_cal_data_from_nvs(cal_data);
     if (err != ESP_OK) {
         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)
     } else {
         err = ESP_OK;
     }
-    esp_phy_release_init_data(init_data);
 #else
-    esp_phy_rf_init(NULL, PHY_RF_CAL_FULL, cal_data);
+    esp_phy_rf_init(init_data, PHY_RF_CAL_FULL, cal_data);
 #endif
 
+    esp_phy_release_init_data(init_data);
+
     free(cal_data); // PHY maintains a copy of calibration data, so we can free this
 }