Skip to content

Commit

Permalink
feat(espefuse): Adds API for getting block and wafer versions
Browse files Browse the repository at this point in the history
  • Loading branch information
KonstantinKondrashov authored and radimkarnis committed Nov 4, 2024
1 parent 36d9735 commit 111c6c0
Show file tree
Hide file tree
Showing 26 changed files with 74 additions and 71 deletions.
36 changes: 36 additions & 0 deletions espefuse/efuse/base_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,42 @@ def is_efuses_incompatible_for_burn(self):
# 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):
Expand Down
2 changes: 1 addition & 1 deletion espefuse/efuse/esp32c2/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def __init__(
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
Expand Down
3 changes: 0 additions & 3 deletions espefuse/efuse/esp32c2/mem_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__))
Expand Down
6 changes: 2 additions & 4 deletions espefuse/efuse/esp32c2/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,16 @@ 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:")
print("INIT_CODE_ATTEN0 = ", efuses["ADC1_INIT_CODE_ATTEN0"].get())
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


Expand Down
2 changes: 1 addition & 1 deletion espefuse/efuse/esp32c3/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def __init__(
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
Expand Down
4 changes: 0 additions & 4 deletions espefuse/efuse/esp32c3/mem_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__))
Expand Down
6 changes: 2 additions & 4 deletions espefuse/efuse/esp32c3/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:")
Expand All @@ -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


Expand Down
2 changes: 1 addition & 1 deletion espefuse/efuse/esp32c6/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def __init__(
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
Expand Down
4 changes: 0 additions & 4 deletions espefuse/efuse/esp32c6/mem_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__))
Expand Down
6 changes: 2 additions & 4 deletions espefuse/efuse/esp32c6/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:")
Expand All @@ -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


Expand Down
2 changes: 1 addition & 1 deletion espefuse/efuse/esp32h2/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def __init__(
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
Expand Down
4 changes: 0 additions & 4 deletions espefuse/efuse/esp32h2/mem_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__))
Expand Down
6 changes: 2 additions & 4 deletions espefuse/efuse/esp32h2/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:")
Expand All @@ -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


Expand Down
2 changes: 1 addition & 1 deletion espefuse/efuse/esp32h2beta1/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def __init__(
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
Expand Down
4 changes: 0 additions & 4 deletions espefuse/efuse/esp32h2beta1/mem_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__))
Expand Down
6 changes: 2 additions & 4 deletions espefuse/efuse/esp32h2beta1/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:")
Expand All @@ -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


Expand Down
2 changes: 1 addition & 1 deletion espefuse/efuse/esp32s2/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def __init__(
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
Expand Down
4 changes: 0 additions & 4 deletions espefuse/efuse/esp32s2/mem_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__))
Expand Down
6 changes: 2 additions & 4 deletions espefuse/efuse/esp32s2/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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


Expand Down
2 changes: 1 addition & 1 deletion espefuse/efuse/esp32s3/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def __init__(
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
Expand Down
4 changes: 0 additions & 4 deletions espefuse/efuse/esp32s3/mem_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__))
Expand Down
5 changes: 2 additions & 3 deletions espefuse/efuse/esp32s3/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:")
Expand All @@ -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


Expand Down
2 changes: 1 addition & 1 deletion espefuse/efuse/esp32s3beta2/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def __init__(
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
Expand Down
4 changes: 0 additions & 4 deletions espefuse/efuse/esp32s3beta2/mem_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__))
Expand Down
6 changes: 2 additions & 4 deletions espefuse/efuse/esp32s3beta2/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:")
Expand All @@ -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


Expand Down
Loading

0 comments on commit 111c6c0

Please sign in to comment.