mirror of
https://github.com/espressif/esptool.git
synced 2025-10-15 12:37:18 +08:00
feat(espefuse): Adds API for getting block and wafer versions
This commit is contained in:

committed by
Radim Karniš

parent
36d9735c8d
commit
111c6c03db
@@ -653,6 +653,42 @@ class EspEfusesBase(object):
|
||||
# Overwrite this function for a specific target if you want to check if a certain eFuse(s) can be burned.
|
||||
return False
|
||||
|
||||
def get_major_chip_version(self):
|
||||
try:
|
||||
return self["WAFER_VERSION_MAJOR"].get()
|
||||
except KeyError:
|
||||
return 0
|
||||
|
||||
def get_minor_chip_version(self):
|
||||
try:
|
||||
return self["WAFER_VERSION_MINOR"].get()
|
||||
except KeyError:
|
||||
return 0
|
||||
|
||||
def get_chip_version(self):
|
||||
return self.get_major_chip_version() * 100 + self.get_minor_chip_version()
|
||||
|
||||
def get_major_block_version(self):
|
||||
try:
|
||||
return self["BLK_VERSION_MAJOR"].get()
|
||||
except KeyError:
|
||||
return 0
|
||||
|
||||
def get_minor_block_version(self):
|
||||
try:
|
||||
return self["BLK_VERSION_MINOR"].get()
|
||||
except KeyError:
|
||||
return 0
|
||||
|
||||
def get_block_version(self):
|
||||
return self.get_major_block_version() * 100 + self.get_minor_block_version()
|
||||
|
||||
def get_pkg_version(self):
|
||||
try:
|
||||
return self["PKG_VERSION"].get()
|
||||
except KeyError:
|
||||
return 0
|
||||
|
||||
|
||||
class EfuseFieldBase(EfuseProtectBase):
|
||||
def __init__(self, parent, param):
|
||||
|
@@ -102,7 +102,7 @@ class EspEfuses(base_fields.EspEfusesBase):
|
||||
for efuse in self.Fields.BLOCK2_CALIBRATION_EFUSES
|
||||
]
|
||||
else:
|
||||
if self["BLK_VERSION_MINOR"].get() == 1:
|
||||
if self.get_block_version() >= 1:
|
||||
self.efuses += [
|
||||
EfuseField.convert(self, efuse)
|
||||
for efuse in self.Fields.BLOCK2_CALIBRATION_EFUSES
|
||||
|
@@ -97,10 +97,7 @@ class EfuseDefineFields(EfuseFieldsBase):
|
||||
def __init__(self, extend_efuse_table) -> None:
|
||||
# List of efuse fields from TRM the chapter eFuse Controller.
|
||||
self.EFUSES = []
|
||||
|
||||
self.KEYBLOCKS = []
|
||||
|
||||
# if BLK_VERSION_MINOR is 1, these efuse fields are in BLOCK2
|
||||
self.BLOCK2_CALIBRATION_EFUSES = []
|
||||
|
||||
dir_name = os.path.dirname(os.path.abspath(__file__))
|
||||
|
@@ -150,9 +150,9 @@ def set_flash_voltage(esp, efuses, args):
|
||||
|
||||
|
||||
def adc_info(esp, efuses, args):
|
||||
print("")
|
||||
# fmt: off
|
||||
if efuses["BLK_VERSION_MINOR"].get() == 1:
|
||||
print("Block version:", efuses.get_block_version())
|
||||
if efuses.get_block_version() >= 1:
|
||||
print("Temperature Sensor Calibration = {}C".format(efuses["TEMP_CALIB"].get()))
|
||||
print("ADC OCode = ", efuses["OCODE"].get())
|
||||
print("ADC1:")
|
||||
@@ -160,8 +160,6 @@ def adc_info(esp, efuses, args):
|
||||
print("INIT_CODE_ATTEN3 = ", efuses["ADC1_INIT_CODE_ATTEN3"].get())
|
||||
print("CAL_VOL_ATTEN0 = ", efuses["ADC1_CAL_VOL_ATTEN0"].get())
|
||||
print("CAL_VOL_ATTEN3 = ", efuses["ADC1_CAL_VOL_ATTEN3"].get())
|
||||
else:
|
||||
print("BLK_VERSION_MINOR = {}".format(efuses["BLK_VERSION_MINOR"].get_meaning()))
|
||||
# fmt: on
|
||||
|
||||
|
||||
|
@@ -102,7 +102,7 @@ class EspEfuses(base_fields.EspEfusesBase):
|
||||
for efuse in self.Fields.BLOCK2_CALIBRATION_EFUSES
|
||||
]
|
||||
else:
|
||||
if self["BLK_VERSION_MAJOR"].get() == 1:
|
||||
if self.get_block_version() >= 100:
|
||||
self.efuses += [
|
||||
EfuseField.convert(self, efuse)
|
||||
for efuse in self.Fields.BLOCK2_CALIBRATION_EFUSES
|
||||
|
@@ -130,12 +130,8 @@ class EfuseDefineFields(EfuseFieldsBase):
|
||||
def __init__(self, extend_efuse_table) -> None:
|
||||
# List of efuse fields from TRM the chapter eFuse Controller.
|
||||
self.EFUSES = []
|
||||
|
||||
self.KEYBLOCKS = []
|
||||
|
||||
# if BLK_VERSION_MAJOR is 1, these efuse fields are in BLOCK2
|
||||
self.BLOCK2_CALIBRATION_EFUSES = []
|
||||
|
||||
self.CALC = []
|
||||
|
||||
dir_name = os.path.dirname(os.path.abspath(__file__))
|
||||
|
@@ -192,9 +192,9 @@ def set_flash_voltage(esp, efuses, args):
|
||||
|
||||
|
||||
def adc_info(esp, efuses, args):
|
||||
print("")
|
||||
# fmt: off
|
||||
if efuses["BLK_VERSION_MAJOR"].get() == 1:
|
||||
print("Block version:", efuses.get_block_version())
|
||||
if efuses.get_block_version() >= 100:
|
||||
print("Temperature Sensor Calibration = {}C".format(efuses["TEMP_CALIB"].get()))
|
||||
print("ADC OCode = ", efuses["OCODE"].get())
|
||||
print("ADC1:")
|
||||
@@ -206,8 +206,6 @@ def adc_info(esp, efuses, args):
|
||||
print("CAL_VOL_ATTEN1 = ", efuses["ADC1_CAL_VOL_ATTEN1"].get())
|
||||
print("CAL_VOL_ATTEN2 = ", efuses["ADC1_CAL_VOL_ATTEN2"].get())
|
||||
print("CAL_VOL_ATTEN3 = ", efuses["ADC1_CAL_VOL_ATTEN3"].get())
|
||||
else:
|
||||
print("BLK_VERSION_MAJOR = {}".format(efuses["BLK_VERSION_MAJOR"].get_meaning()))
|
||||
# fmt: on
|
||||
|
||||
|
||||
|
@@ -102,7 +102,7 @@ class EspEfuses(base_fields.EspEfusesBase):
|
||||
for efuse in self.Fields.BLOCK2_CALIBRATION_EFUSES
|
||||
]
|
||||
else:
|
||||
if self["BLK_VERSION_MINOR"].get() == 1:
|
||||
if self.get_block_version() >= 1:
|
||||
self.efuses += [
|
||||
EfuseField.convert(self, efuse)
|
||||
for efuse in self.Fields.BLOCK2_CALIBRATION_EFUSES
|
||||
|
@@ -114,12 +114,8 @@ class EfuseDefineFields(EfuseFieldsBase):
|
||||
def __init__(self, extend_efuse_table) -> None:
|
||||
# List of efuse fields from TRM the chapter eFuse Controller.
|
||||
self.EFUSES = []
|
||||
|
||||
self.KEYBLOCKS = []
|
||||
|
||||
# if BLK_VERSION_MINOR is 1, these efuse fields are in BLOCK2
|
||||
self.BLOCK2_CALIBRATION_EFUSES = []
|
||||
|
||||
self.CALC = []
|
||||
|
||||
dir_name = os.path.dirname(os.path.abspath(__file__))
|
||||
|
@@ -192,9 +192,9 @@ def set_flash_voltage(esp, efuses, args):
|
||||
|
||||
|
||||
def adc_info(esp, efuses, args):
|
||||
print("")
|
||||
# fmt: off
|
||||
if efuses["BLK_VERSION_MINOR"].get() == 1:
|
||||
print("Block version:", efuses.get_block_version())
|
||||
if efuses.get_block_version() >= 1:
|
||||
print("Temperature Sensor Calibration = {}C".format(efuses["TEMP_CALIB"].get()))
|
||||
print("ADC OCode = ", efuses["OCODE"].get())
|
||||
print("ADC1:")
|
||||
@@ -213,8 +213,6 @@ def adc_info(esp, efuses, args):
|
||||
print("INIT_CODE_ATTEN0_CH4 = ", efuses['ADC1_INIT_CODE_ATTEN0_CH4'].get())
|
||||
print("INIT_CODE_ATTEN0_CH5 = ", efuses['ADC1_INIT_CODE_ATTEN0_CH5'].get())
|
||||
print("INIT_CODE_ATTEN0_CH6 = ", efuses['ADC1_INIT_CODE_ATTEN0_CH6'].get())
|
||||
else:
|
||||
print("BLK_VERSION_MINOR = {}".format(efuses["BLK_VERSION_MINOR"].get_meaning()))
|
||||
# fmt: on
|
||||
|
||||
|
||||
|
@@ -102,7 +102,7 @@ class EspEfuses(base_fields.EspEfusesBase):
|
||||
for efuse in self.Fields.BLOCK2_CALIBRATION_EFUSES
|
||||
]
|
||||
else:
|
||||
if self["BLK_VERSION_MINOR"].get() == 2:
|
||||
if self.get_block_version() >= 2:
|
||||
self.efuses += [
|
||||
EfuseField.convert(self, efuse)
|
||||
for efuse in self.Fields.BLOCK2_CALIBRATION_EFUSES
|
||||
|
@@ -114,12 +114,8 @@ class EfuseDefineFields(EfuseFieldsBase):
|
||||
def __init__(self, extend_efuse_table) -> None:
|
||||
# List of efuse fields from TRM the chapter eFuse Controller.
|
||||
self.EFUSES = []
|
||||
|
||||
self.KEYBLOCKS = []
|
||||
|
||||
# if BLK_VERSION_MINOR is 2, these efuse fields are in BLOCK2
|
||||
self.BLOCK2_CALIBRATION_EFUSES = []
|
||||
|
||||
self.CALC = []
|
||||
|
||||
dir_name = os.path.dirname(os.path.abspath(__file__))
|
||||
|
@@ -191,9 +191,9 @@ def set_flash_voltage(esp, efuses, args):
|
||||
|
||||
|
||||
def adc_info(esp, efuses, args):
|
||||
print("")
|
||||
# fmt: off
|
||||
if efuses["BLK_VERSION_MINOR"].get() == 2:
|
||||
print("Block version:", efuses.get_block_version())
|
||||
if efuses.get_block_version() >= 2:
|
||||
print("Temperature Sensor Calibration = {}C".format(efuses["TEMP_CALIB"].get()))
|
||||
print("")
|
||||
print("ADC1:")
|
||||
@@ -210,8 +210,6 @@ def adc_info(esp, efuses, args):
|
||||
print("CH2_ATTEN0_INITCODE_DIFF = ", efuses["ADC1_CH2_ATTEN0_INITCODE_DIFF"].get())
|
||||
print("CH3_ATTEN0_INITCODE_DIFF = ", efuses["ADC1_CH3_ATTEN0_INITCODE_DIFF"].get())
|
||||
print("CH4_ATTEN0_INITCODE_DIFF = ", efuses["ADC1_CH4_ATTEN0_INITCODE_DIFF"].get())
|
||||
else:
|
||||
print("BLK_VERSION_MINOR = {}".format(efuses["BLK_VERSION_MINOR"].get()))
|
||||
# fmt: on
|
||||
|
||||
|
||||
|
@@ -102,7 +102,7 @@ class EspEfuses(base_fields.EspEfusesBase):
|
||||
for efuse in self.Fields.BLOCK2_CALIBRATION_EFUSES
|
||||
]
|
||||
else:
|
||||
if self["BLK_VERSION_MINOR"].get() == 2:
|
||||
if self.get_block_version() >= 2:
|
||||
self.efuses += [
|
||||
EfuseField.convert(self, efuse)
|
||||
for efuse in self.Fields.BLOCK2_CALIBRATION_EFUSES
|
||||
|
@@ -110,12 +110,8 @@ class EfuseDefineFields(EfuseFieldsBase):
|
||||
def __init__(self, extend_efuse_table) -> None:
|
||||
# List of efuse fields from TRM the chapter eFuse Controller.
|
||||
self.EFUSES = []
|
||||
|
||||
self.KEYBLOCKS = []
|
||||
|
||||
# if BLK_VERSION_MAJOR is 1, these efuse fields are in BLOCK2
|
||||
self.BLOCK2_CALIBRATION_EFUSES = []
|
||||
|
||||
self.CALC: List = []
|
||||
|
||||
dir_name = os.path.dirname(os.path.abspath(__file__))
|
||||
|
@@ -191,9 +191,9 @@ def set_flash_voltage(esp, efuses, args):
|
||||
|
||||
|
||||
def adc_info(esp, efuses, args):
|
||||
print("")
|
||||
# fmt: off
|
||||
if efuses["BLK_VERSION_MINOR"].get() == 2:
|
||||
print("Block version:", efuses.get_block_version())
|
||||
if efuses.get_block_version() >= 2:
|
||||
print("Temperature Sensor Calibration = {}C".format(efuses["TEMP_CALIB"].get()))
|
||||
print("")
|
||||
print("ADC1:")
|
||||
@@ -210,8 +210,6 @@ def adc_info(esp, efuses, args):
|
||||
print("CH2_ATTEN0_INITCODE_DIFF = ", efuses["ADC1_CH2_ATTEN0_INITCODE_DIFF"].get())
|
||||
print("CH3_ATTEN0_INITCODE_DIFF = ", efuses["ADC1_CH3_ATTEN0_INITCODE_DIFF"].get())
|
||||
print("CH4_ATTEN0_INITCODE_DIFF = ", efuses["ADC1_CH4_ATTEN0_INITCODE_DIFF"].get())
|
||||
else:
|
||||
print("BLK_VERSION_MINOR = {}".format(efuses["BLK_VERSION_MINOR"].get()))
|
||||
# fmt: on
|
||||
|
||||
|
||||
|
@@ -102,7 +102,7 @@ class EspEfuses(base_fields.EspEfusesBase):
|
||||
for efuse in self.Fields.BLOCK2_CALIBRATION_EFUSES
|
||||
]
|
||||
else:
|
||||
if self["BLK_VERSION_MINOR"].get() == 1:
|
||||
if self.get_block_version() >= 1:
|
||||
self.efuses += [
|
||||
EfuseField.convert(self, efuse)
|
||||
for efuse in self.Fields.BLOCK2_CALIBRATION_EFUSES
|
||||
|
@@ -153,12 +153,8 @@ class EfuseDefineFields(EfuseFieldsBase):
|
||||
def __init__(self, extend_efuse_table) -> None:
|
||||
# List of efuse fields from TRM the chapter eFuse Controller.
|
||||
self.EFUSES = []
|
||||
|
||||
self.KEYBLOCKS = []
|
||||
|
||||
# if BLK_VERSION_MINOR is 1, these efuse fields are in BLOCK2
|
||||
self.BLOCK2_CALIBRATION_EFUSES = []
|
||||
|
||||
self.CALC = []
|
||||
|
||||
dir_name = os.path.dirname(os.path.abspath(__file__))
|
||||
|
@@ -235,9 +235,9 @@ def set_flash_voltage(esp, efuses, args):
|
||||
|
||||
|
||||
def adc_info(esp, efuses, args):
|
||||
print("")
|
||||
# fmt: off
|
||||
if efuses["BLK_VERSION_MINOR"].get() == 1:
|
||||
print("Block version:", efuses.get_block_version())
|
||||
if efuses.get_block_version() >= 1:
|
||||
print("Temperature Sensor Calibration = {}C".format(efuses["TEMP_CALIB"].get()))
|
||||
print("TADC_CALIB = {}C".format(efuses["ADC_CALIB"].get()))
|
||||
print("RTCCALIB_V1IDX_A10H = ", efuses["RTCCALIB_V1IDX_A10H"].get())
|
||||
@@ -256,8 +256,6 @@ def adc_info(esp, efuses, args):
|
||||
print("RTCCALIB_V1IDX_A21L = ", efuses["RTCCALIB_V1IDX_A21L"].get())
|
||||
print("RTCCALIB_V1IDX_A22L = ", efuses["RTCCALIB_V1IDX_A22L"].get())
|
||||
print("RTCCALIB_V1IDX_A23L = ", efuses["RTCCALIB_V1IDX_A23L"].get())
|
||||
else:
|
||||
print("BLK_VERSION_MINOR = ", efuses["BLK_VERSION_MINOR"].get_meaning())
|
||||
# fmt: on
|
||||
|
||||
|
||||
|
@@ -102,7 +102,7 @@ class EspEfuses(base_fields.EspEfusesBase):
|
||||
for efuse in self.Fields.BLOCK2_CALIBRATION_EFUSES
|
||||
]
|
||||
else:
|
||||
if self["BLK_VERSION_MAJOR"].get() == 1:
|
||||
if self.get_block_version() >= 100:
|
||||
self.efuses += [
|
||||
EfuseField.convert(self, efuse)
|
||||
for efuse in self.Fields.BLOCK2_CALIBRATION_EFUSES
|
||||
|
@@ -115,12 +115,8 @@ class EfuseDefineFields(EfuseFieldsBase):
|
||||
def __init__(self, extend_efuse_table) -> None:
|
||||
# List of efuse fields from TRM the chapter eFuse Controller.
|
||||
self.EFUSES = []
|
||||
|
||||
self.KEYBLOCKS = []
|
||||
|
||||
# if BLK_VERSION_MAJOR is 1, these efuse fields are in BLOCK2
|
||||
self.BLOCK2_CALIBRATION_EFUSES = []
|
||||
|
||||
self.CALC = []
|
||||
|
||||
dir_name = os.path.dirname(os.path.abspath(__file__))
|
||||
|
@@ -236,7 +236,8 @@ def set_flash_voltage(esp, efuses, args):
|
||||
def adc_info(esp, efuses, args):
|
||||
print("")
|
||||
# fmt: off
|
||||
if efuses["BLK_VERSION_MAJOR"].get() == 1:
|
||||
print("Block version:", efuses.get_block_version())
|
||||
if efuses.get_block_version() >= 100:
|
||||
print("Temperature Sensor Calibration = {}C".format(efuses["TEMP_CALIB"].get()))
|
||||
print("ADC OCode = ", efuses["OCODE"].get())
|
||||
print("ADC1:")
|
||||
@@ -256,8 +257,6 @@ def adc_info(esp, efuses, args):
|
||||
print("CAL_VOL_ATTEN0 = ", efuses["ADC2_CAL_VOL_ATTEN0"].get())
|
||||
print("CAL_VOL_ATTEN1 = ", efuses["ADC2_CAL_VOL_ATTEN1"].get())
|
||||
print("CAL_VOL_ATTEN2 = ", efuses["ADC2_CAL_VOL_ATTEN2"].get())
|
||||
else:
|
||||
print("BLK_VERSION_MAJOR = ", efuses["BLK_VERSION_MAJOR"].get_meaning())
|
||||
# fmt: on
|
||||
|
||||
|
||||
|
@@ -102,7 +102,7 @@ class EspEfuses(base_fields.EspEfusesBase):
|
||||
for efuse in self.Fields.BLOCK2_CALIBRATION_EFUSES
|
||||
]
|
||||
else:
|
||||
if self["BLK_VERSION_MAJOR"].get() == 1:
|
||||
if self.get_block_version() >= 100:
|
||||
self.efuses += [
|
||||
EfuseField.convert(self, efuse)
|
||||
for efuse in self.Fields.BLOCK2_CALIBRATION_EFUSES
|
||||
|
@@ -115,12 +115,8 @@ class EfuseDefineFields(EfuseFieldsBase):
|
||||
def __init__(self, extend_efuse_table) -> None:
|
||||
# List of efuse fields from TRM the chapter eFuse Controller.
|
||||
self.EFUSES = []
|
||||
|
||||
self.KEYBLOCKS = []
|
||||
|
||||
# if BLK_VERSION_MAJOR is 1, these efuse fields are in BLOCK2
|
||||
self.BLOCK2_CALIBRATION_EFUSES = []
|
||||
|
||||
self.CALC = []
|
||||
|
||||
dir_name = os.path.dirname(os.path.abspath(__file__))
|
||||
|
@@ -234,9 +234,9 @@ def set_flash_voltage(esp, efuses, args):
|
||||
|
||||
|
||||
def adc_info(esp, efuses, args):
|
||||
print("")
|
||||
# fmt: off
|
||||
if efuses["BLK_VERSION_MAJOR"].get() == 1:
|
||||
print("Block version:", efuses.get_block_version())
|
||||
if efuses.get_block_version() >= 100:
|
||||
print("Temperature Sensor Calibration = {}C".format(efuses["TEMP_CALIB"].get()))
|
||||
print("ADC OCode = ", efuses["OCODE"].get())
|
||||
print("ADC1:")
|
||||
@@ -256,8 +256,6 @@ def adc_info(esp, efuses, args):
|
||||
print("CAL_VOL_ATTEN0 = ", efuses["ADC2_CAL_VOL_ATTEN0"].get())
|
||||
print("CAL_VOL_ATTEN1 = ", efuses["ADC2_CAL_VOL_ATTEN1"].get())
|
||||
print("CAL_VOL_ATTEN2 = ", efuses["ADC2_CAL_VOL_ATTEN2"].get())
|
||||
else:
|
||||
print("BLK_VERSION_MAJOR = ", efuses["BLK_VERSION_MAJOR"].get_meaning())
|
||||
# fmt: on
|
||||
|
||||
|
||||
|
@@ -140,7 +140,20 @@ class EfuseFieldsBase(object):
|
||||
if name == "OPTIONAL_UNIQUE_ID":
|
||||
efuse.class_type = "keyblock"
|
||||
|
||||
elif includes(name, ["ADC", "LDO", "DBIAS", "_HVT", "CALIB", "OCODE"]):
|
||||
elif includes(
|
||||
name,
|
||||
[
|
||||
"ADC",
|
||||
"LDO",
|
||||
"DBIAS",
|
||||
"_HVT",
|
||||
"CALIB",
|
||||
"OCODE",
|
||||
"TEMPERATURE",
|
||||
"LSLP",
|
||||
"DSLP",
|
||||
],
|
||||
):
|
||||
efuse.category = "calibration"
|
||||
if name == "ADC_VREF":
|
||||
efuse.class_type = "vref"
|
||||
|
Reference in New Issue
Block a user