Kaynağa Gözat

adc: update adc calibration efuse version

ADC calibration scheme and algorithm are not changed. Only the eFuse bit BLOCK1_VERSION is changed. This MR updated the logic to recognize the adc efuse version
Armando 4 yıl önce
ebeveyn
işleme
bfb2a264c6

+ 5 - 10
components/efuse/esp32s3/esp_efuse_rtc_calib.c

@@ -19,20 +19,15 @@
 
 int esp_efuse_rtc_calib_get_ver(void)
 {
-    uint32_t blk1_version = 0;
-    uint32_t blk2_version = 0;
-    ESP_ERROR_CHECK(esp_efuse_read_field_blob(ESP_EFUSE_BLOCK1_VERSION, &blk1_version, ESP_EFUSE_BLOCK1_VERSION[0]->bit_count));
-    ESP_ERROR_CHECK(esp_efuse_read_field_blob(ESP_EFUSE_BLOCK2_VERSION, &blk2_version, ESP_EFUSE_BLOCK2_VERSION[0]->bit_count));
+    uint32_t blk_ver_major = 0;
+    ESP_ERROR_CHECK(esp_efuse_read_field_blob(ESP_EFUSE_BLK_VER_MAJOR, &blk_ver_major, ESP_EFUSE_BLK_VER_MAJOR[0]->bit_count));
 
-    if (blk1_version == blk2_version) {
-        return blk1_version;
-    } else {
-        blk1_version = 0;
-        blk2_version = 0;
+    uint32_t cali_version_v1 = (blk_ver_major == 1) ? 1 : 0;
+    if (!cali_version_v1) {
         ESP_LOGW("eFuse", "calibration efuse version does not match, set default version: %d", 0);
     }
 
-    return blk2_version;
+    return cali_version_v1;
 }
 
 uint16_t esp_efuse_rtc_calib_get_init_code(int version, uint32_t adc_unit, int atten)

+ 9 - 9
components/efuse/esp32s3/esp_efuse_table.c

@@ -9,7 +9,7 @@
 #include <assert.h>
 #include "esp_efuse_table.h"
 
-// md5_digest_table ee5142bc489eee22230a49b5c7cafe00
+// md5_digest_table 9444b887379d924049af42806ca71d45
 // This file was generated from the file esp_efuse_table.csv. DO NOT CHANGE THIS FILE MANUALLY.
 // If you want to change some fields, you need to change esp_efuse_table.csv file
 // then run `efuse_common_table` or `efuse_custom_table` command it will generate this file.
@@ -412,8 +412,8 @@ static const esp_efuse_desc_t PKG_VERSION[] = {
     {EFUSE_BLK1, 117, 3}, 	 // Package version,
 };
 
-static const esp_efuse_desc_t BLOCK1_VERSION[] = {
-    {EFUSE_BLK1, 120, 3}, 	 // BLOCK1 efuse version 0:No calibration 1:With calibration,
+static const esp_efuse_desc_t BLK_VER_MINOR[] = {
+    {EFUSE_BLK1, 120, 3}, 	 // BLK_VERSION_MINOR,
 };
 
 static const esp_efuse_desc_t ADC2_CAL_VOL_ATTEN3[] = {
@@ -424,8 +424,8 @@ static const esp_efuse_desc_t OPTIONAL_UNIQUE_ID[] = {
     {EFUSE_BLK2, 0, 128}, 	 // Optional unique 128-bit ID,
 };
 
-static const esp_efuse_desc_t BLOCK2_VERSION[] = {
-    {EFUSE_BLK2, 128, 4}, 	 // Version of BLOCK2,
+static const esp_efuse_desc_t BLK_VER_MAJOR[] = {
+    {EFUSE_BLK2, 128, 2}, 	 // BLK_VERSION_MAJOR,
 };
 
 static const esp_efuse_desc_t TEMP_CALIB[] = {
@@ -1031,8 +1031,8 @@ const esp_efuse_desc_t* ESP_EFUSE_PKG_VERSION[] = {
     NULL
 };
 
-const esp_efuse_desc_t* ESP_EFUSE_BLOCK1_VERSION[] = {
-    &BLOCK1_VERSION[0],    		// BLOCK1 efuse version 0:No calibration 1:With calibration
+const esp_efuse_desc_t* ESP_EFUSE_BLK_VER_MINOR[] = {
+    &BLK_VER_MINOR[0],    		// BLK_VERSION_MINOR
     NULL
 };
 
@@ -1046,8 +1046,8 @@ const esp_efuse_desc_t* ESP_EFUSE_OPTIONAL_UNIQUE_ID[] = {
     NULL
 };
 
-const esp_efuse_desc_t* ESP_EFUSE_BLOCK2_VERSION[] = {
-    &BLOCK2_VERSION[0],    		// Version of BLOCK2
+const esp_efuse_desc_t* ESP_EFUSE_BLK_VER_MAJOR[] = {
+    &BLK_VER_MAJOR[0],    		// BLK_VERSION_MAJOR
     NULL
 };
 

+ 2 - 2
components/efuse/esp32s3/esp_efuse_table.csv

@@ -129,13 +129,13 @@
     SPI_PAD_CONFIG_D7,                    EFUSE_BLK1,  108,    6,     SPI_PAD_configure D7
     WAFER_VERSION,                        EFUSE_BLK1,  114,    3,     WAFER version 0:A
     PKG_VERSION,                          EFUSE_BLK1,  117,    3,     Package version
-    BLOCK1_VERSION,                       EFUSE_BLK1,  120,    3,     BLOCK1 efuse version 0:No calibration 1:With calibration
+    BLK_VER_MINOR,                        EFUSE_BLK1,  120,    3,     BLK_VERSION_MINOR, won't influence users
     ADC2_CAL_VOL_ATTEN3,                  EFUSE_BLK1,  186,    6,     ADC2 calibration voltage at atten3
 
 # SYS_DATA_PART1 BLOCK# - System configuration
 #######################
     OPTIONAL_UNIQUE_ID,                   EFUSE_BLK2,    0,  128,     Optional unique 128-bit ID
-    BLOCK2_VERSION,                       EFUSE_BLK2,  128,    4,     Version of BLOCK2
+    BLK_VER_MAJOR,                        EFUSE_BLK2,  128,    2,     BLK_VERSION_MAJOR, change of this bit means users need to update firmware
     TEMP_CALIB,                           EFUSE_BLK2,  132,    9,     Temperature calibration data
     OCODE,                                EFUSE_BLK2,  141,    8,     ADC OCode
     ADC1_INIT_CODE_ATTEN0,                EFUSE_BLK2,  149,    8,     ADC1 init code at atten0

+ 3 - 3
components/efuse/esp32s3/include/esp_efuse_table.h

@@ -9,7 +9,7 @@ extern "C" {
 #endif
 
 
-// md5_digest_table ee5142bc489eee22230a49b5c7cafe00
+// md5_digest_table 9444b887379d924049af42806ca71d45
 // This file was generated from the file esp_efuse_table.csv. DO NOT CHANGE THIS FILE MANUALLY.
 // If you want to change some fields, you need to change esp_efuse_table.csv file
 // then run `efuse_common_table` or `efuse_custom_table` command it will generate this file.
@@ -114,10 +114,10 @@ extern const esp_efuse_desc_t* ESP_EFUSE_SPI_PAD_CONFIG_D6[];
 extern const esp_efuse_desc_t* ESP_EFUSE_SPI_PAD_CONFIG_D7[];
 extern const esp_efuse_desc_t* ESP_EFUSE_WAFER_VERSION[];
 extern const esp_efuse_desc_t* ESP_EFUSE_PKG_VERSION[];
-extern const esp_efuse_desc_t* ESP_EFUSE_BLOCK1_VERSION[];
+extern const esp_efuse_desc_t* ESP_EFUSE_BLK_VER_MINOR[];
 extern const esp_efuse_desc_t* ESP_EFUSE_ADC2_CAL_VOL_ATTEN3[];
 extern const esp_efuse_desc_t* ESP_EFUSE_OPTIONAL_UNIQUE_ID[];
-extern const esp_efuse_desc_t* ESP_EFUSE_BLOCK2_VERSION[];
+extern const esp_efuse_desc_t* ESP_EFUSE_BLK_VER_MAJOR[];
 extern const esp_efuse_desc_t* ESP_EFUSE_TEMP_CALIB[];
 extern const esp_efuse_desc_t* ESP_EFUSE_OCODE[];
 extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_INIT_CODE_ATTEN0[];

+ 9 - 17
components/esp_hw_support/port/esp32s3/rtc_init.c

@@ -69,25 +69,17 @@ void rtc_init(rtc_config_t cfg)
     REGI2C_WRITE_MASK(I2C_DIG_REG, I2C_DIG_REG_EXT_RTC_DREG, RTC_CNTL_DBIAS_1V10);
 
     if (cfg.cali_ocode) {
-        uint32_t blk1_version = 0;
-        uint32_t blk2_version = 0;
-        esp_err_t err = esp_efuse_read_field_blob(ESP_EFUSE_BLOCK1_VERSION, &blk1_version, 3);
+        uint32_t blk_ver_major = 0;
+        esp_err_t err = esp_efuse_read_field_blob(ESP_EFUSE_BLK_VER_MAJOR, &blk_ver_major, ESP_EFUSE_BLK_VER_MAJOR[0]->bit_count);
         if (err != ESP_OK) {
-            blk1_version = 0;
-            SOC_LOGW(TAG, "efuse read fail, set default blk1_version: %d\n", blk1_version);
+            blk_ver_major = 0;
+            SOC_LOGW(TAG, "efuse read fail, set default blk_ver_major: %d\n", blk_ver_major);
         }
-        err = esp_efuse_read_field_blob(ESP_EFUSE_BLOCK2_VERSION, &blk2_version, 4);
-        if (err != ESP_OK) {
-            blk2_version = 0;
-            SOC_LOGW(TAG, "efuse read fail, set default blk2_version: %d\n", blk2_version);
-        }
-        if (blk1_version != blk2_version) {
-            blk1_version = 0;
-            blk2_version = 0;
-            SOC_LOGW(TAG, "calibration efuse version does not match, set default version: %d\n", 0);
-        }
-        if (blk2_version == 1) {
-            set_ocode_by_efuse(blk2_version);
+
+        //default blk_ver_major will fallback to using the self-calibration way for OCode
+        bool ocode_efuse_cali = (blk_ver_major == 1);
+        if (ocode_efuse_cali) {
+            set_ocode_by_efuse(blk_ver_major);
         } else {
             calibrate_ocode();
         }