]> granicus.if.org Git - esp-idf/commitdiff
component/esp32 : fix phy init with NULL init_data
authorTian Hao <tianhao@espressif.com>
Thu, 15 Jun 2017 10:37:53 +0000 (18:37 +0800)
committerTian Hao <tianhao@espressif.com>
Fri, 16 Jun 2017 04:09:13 +0000 (12:09 +0800)
1. fix phy init with NULL init_data
2. do full calibration without CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE
3. fix libphy.a printf

components/esp32/lib
components/esp32/phy_init.c

index a4ddb18d8cbfcc8278c5ca41eafb9b34733d8e07..d2fc812f7f50fabb715564b99da70c8760085812 160000 (submodule)
@@ -1 +1 @@
-Subproject commit a4ddb18d8cbfcc8278c5ca41eafb9b34733d8e07
+Subproject commit d2fc812f7f50fabb715564b99da70c8760085812
index 9ebc87e9c0cb73caf1d125955a7a4ef923bd7663..ab62aad2caa6e1de61de9554f2ac430ec3984e1f 100644 (file)
@@ -263,6 +263,13 @@ static esp_err_t store_cal_data_to_nvs_handle(nvs_handle handle,
 
 void esp_phy_load_cal_and_init(void)
 {
+    esp_phy_calibration_data_t* cal_data =
+            (esp_phy_calibration_data_t*) calloc(sizeof(esp_phy_calibration_data_t), 1);
+    if (cal_data == NULL) {
+        ESP_LOGE(TAG, "failed to allocate memory for RF calibration 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) {
@@ -273,12 +280,7 @@ void esp_phy_load_cal_and_init(void)
         ESP_LOGE(TAG, "failed to obtain PHY init data");
         abort();
     }
-    esp_phy_calibration_data_t* cal_data =
-            (esp_phy_calibration_data_t*) calloc(sizeof(esp_phy_calibration_data_t), 1);
-    if (cal_data == NULL) {
-        ESP_LOGE(TAG, "failed to allocate memory for RF calibration data");
-        abort();
-    }
+
     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);
@@ -293,10 +295,11 @@ void esp_phy_load_cal_and_init(void)
         err = ESP_OK;
     }
     esp_phy_release_init_data(init_data);
-    free(cal_data); // PHY maintains a copy of calibration data, so we can free this
 #else
-    esp_phy_rf_init(NULL, PHY_RF_CAL_NONE, NULL);
+    esp_phy_rf_init(NULL, PHY_RF_CAL_FULL, cal_data);
 #endif
+
+    free(cal_data); // PHY maintains a copy of calibration data, so we can free this
 }
 
 #endif // CONFIG_PHY_ENABLED