Skip to content

Commit 111c6c0

Browse files
KonstantinKondrashovradimkarnis
authored andcommitted
feat(espefuse): Adds API for getting block and wafer versions
1 parent 36d9735 commit 111c6c0

26 files changed

+74
-71
lines changed

espefuse/efuse/base_fields.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,42 @@ def is_efuses_incompatible_for_burn(self):
653653
# Overwrite this function for a specific target if you want to check if a certain eFuse(s) can be burned.
654654
return False
655655

656+
def get_major_chip_version(self):
657+
try:
658+
return self["WAFER_VERSION_MAJOR"].get()
659+
except KeyError:
660+
return 0
661+
662+
def get_minor_chip_version(self):
663+
try:
664+
return self["WAFER_VERSION_MINOR"].get()
665+
except KeyError:
666+
return 0
667+
668+
def get_chip_version(self):
669+
return self.get_major_chip_version() * 100 + self.get_minor_chip_version()
670+
671+
def get_major_block_version(self):
672+
try:
673+
return self["BLK_VERSION_MAJOR"].get()
674+
except KeyError:
675+
return 0
676+
677+
def get_minor_block_version(self):
678+
try:
679+
return self["BLK_VERSION_MINOR"].get()
680+
except KeyError:
681+
return 0
682+
683+
def get_block_version(self):
684+
return self.get_major_block_version() * 100 + self.get_minor_block_version()
685+
686+
def get_pkg_version(self):
687+
try:
688+
return self["PKG_VERSION"].get()
689+
except KeyError:
690+
return 0
691+
656692

657693
class EfuseFieldBase(EfuseProtectBase):
658694
def __init__(self, parent, param):

espefuse/efuse/esp32c2/fields.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def __init__(
102102
for efuse in self.Fields.BLOCK2_CALIBRATION_EFUSES
103103
]
104104
else:
105-
if self["BLK_VERSION_MINOR"].get() == 1:
105+
if self.get_block_version() >= 1:
106106
self.efuses += [
107107
EfuseField.convert(self, efuse)
108108
for efuse in self.Fields.BLOCK2_CALIBRATION_EFUSES

espefuse/efuse/esp32c2/mem_definition.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,7 @@ class EfuseDefineFields(EfuseFieldsBase):
9797
def __init__(self, extend_efuse_table) -> None:
9898
# List of efuse fields from TRM the chapter eFuse Controller.
9999
self.EFUSES = []
100-
101100
self.KEYBLOCKS = []
102-
103-
# if BLK_VERSION_MINOR is 1, these efuse fields are in BLOCK2
104101
self.BLOCK2_CALIBRATION_EFUSES = []
105102

106103
dir_name = os.path.dirname(os.path.abspath(__file__))

espefuse/efuse/esp32c2/operations.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,18 +150,16 @@ def set_flash_voltage(esp, efuses, args):
150150

151151

152152
def adc_info(esp, efuses, args):
153-
print("")
154153
# fmt: off
155-
if efuses["BLK_VERSION_MINOR"].get() == 1:
154+
print("Block version:", efuses.get_block_version())
155+
if efuses.get_block_version() >= 1:
156156
print("Temperature Sensor Calibration = {}C".format(efuses["TEMP_CALIB"].get()))
157157
print("ADC OCode = ", efuses["OCODE"].get())
158158
print("ADC1:")
159159
print("INIT_CODE_ATTEN0 = ", efuses["ADC1_INIT_CODE_ATTEN0"].get())
160160
print("INIT_CODE_ATTEN3 = ", efuses["ADC1_INIT_CODE_ATTEN3"].get())
161161
print("CAL_VOL_ATTEN0 = ", efuses["ADC1_CAL_VOL_ATTEN0"].get())
162162
print("CAL_VOL_ATTEN3 = ", efuses["ADC1_CAL_VOL_ATTEN3"].get())
163-
else:
164-
print("BLK_VERSION_MINOR = {}".format(efuses["BLK_VERSION_MINOR"].get_meaning()))
165163
# fmt: on
166164

167165

espefuse/efuse/esp32c3/fields.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def __init__(
102102
for efuse in self.Fields.BLOCK2_CALIBRATION_EFUSES
103103
]
104104
else:
105-
if self["BLK_VERSION_MAJOR"].get() == 1:
105+
if self.get_block_version() >= 100:
106106
self.efuses += [
107107
EfuseField.convert(self, efuse)
108108
for efuse in self.Fields.BLOCK2_CALIBRATION_EFUSES

espefuse/efuse/esp32c3/mem_definition.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,8 @@ class EfuseDefineFields(EfuseFieldsBase):
130130
def __init__(self, extend_efuse_table) -> None:
131131
# List of efuse fields from TRM the chapter eFuse Controller.
132132
self.EFUSES = []
133-
134133
self.KEYBLOCKS = []
135-
136-
# if BLK_VERSION_MAJOR is 1, these efuse fields are in BLOCK2
137134
self.BLOCK2_CALIBRATION_EFUSES = []
138-
139135
self.CALC = []
140136

141137
dir_name = os.path.dirname(os.path.abspath(__file__))

espefuse/efuse/esp32c3/operations.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,9 @@ def set_flash_voltage(esp, efuses, args):
192192

193193

194194
def adc_info(esp, efuses, args):
195-
print("")
196195
# fmt: off
197-
if efuses["BLK_VERSION_MAJOR"].get() == 1:
196+
print("Block version:", efuses.get_block_version())
197+
if efuses.get_block_version() >= 100:
198198
print("Temperature Sensor Calibration = {}C".format(efuses["TEMP_CALIB"].get()))
199199
print("ADC OCode = ", efuses["OCODE"].get())
200200
print("ADC1:")
@@ -206,8 +206,6 @@ def adc_info(esp, efuses, args):
206206
print("CAL_VOL_ATTEN1 = ", efuses["ADC1_CAL_VOL_ATTEN1"].get())
207207
print("CAL_VOL_ATTEN2 = ", efuses["ADC1_CAL_VOL_ATTEN2"].get())
208208
print("CAL_VOL_ATTEN3 = ", efuses["ADC1_CAL_VOL_ATTEN3"].get())
209-
else:
210-
print("BLK_VERSION_MAJOR = {}".format(efuses["BLK_VERSION_MAJOR"].get_meaning()))
211209
# fmt: on
212210

213211

espefuse/efuse/esp32c6/fields.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def __init__(
102102
for efuse in self.Fields.BLOCK2_CALIBRATION_EFUSES
103103
]
104104
else:
105-
if self["BLK_VERSION_MINOR"].get() == 1:
105+
if self.get_block_version() >= 1:
106106
self.efuses += [
107107
EfuseField.convert(self, efuse)
108108
for efuse in self.Fields.BLOCK2_CALIBRATION_EFUSES

espefuse/efuse/esp32c6/mem_definition.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,8 @@ class EfuseDefineFields(EfuseFieldsBase):
114114
def __init__(self, extend_efuse_table) -> None:
115115
# List of efuse fields from TRM the chapter eFuse Controller.
116116
self.EFUSES = []
117-
118117
self.KEYBLOCKS = []
119-
120-
# if BLK_VERSION_MINOR is 1, these efuse fields are in BLOCK2
121118
self.BLOCK2_CALIBRATION_EFUSES = []
122-
123119
self.CALC = []
124120

125121
dir_name = os.path.dirname(os.path.abspath(__file__))

espefuse/efuse/esp32c6/operations.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,9 @@ def set_flash_voltage(esp, efuses, args):
192192

193193

194194
def adc_info(esp, efuses, args):
195-
print("")
196195
# fmt: off
197-
if efuses["BLK_VERSION_MINOR"].get() == 1:
196+
print("Block version:", efuses.get_block_version())
197+
if efuses.get_block_version() >= 1:
198198
print("Temperature Sensor Calibration = {}C".format(efuses["TEMP_CALIB"].get()))
199199
print("ADC OCode = ", efuses["OCODE"].get())
200200
print("ADC1:")
@@ -213,8 +213,6 @@ def adc_info(esp, efuses, args):
213213
print("INIT_CODE_ATTEN0_CH4 = ", efuses['ADC1_INIT_CODE_ATTEN0_CH4'].get())
214214
print("INIT_CODE_ATTEN0_CH5 = ", efuses['ADC1_INIT_CODE_ATTEN0_CH5'].get())
215215
print("INIT_CODE_ATTEN0_CH6 = ", efuses['ADC1_INIT_CODE_ATTEN0_CH6'].get())
216-
else:
217-
print("BLK_VERSION_MINOR = {}".format(efuses["BLK_VERSION_MINOR"].get_meaning()))
218216
# fmt: on
219217

220218

0 commit comments

Comments
 (0)