Fix eFuse summary parser for espefuse v5.x output format

The R/W permission field uses 'R/W' not just 'R' at end of line,
and values can be 'False', '0', hex, or binary representations.
This commit is contained in:
Ryan Malloy 2026-01-30 20:52:09 -07:00
parent 945939bdad
commit f2f2dbd5eb

View File

@ -400,15 +400,18 @@ class SecurityManager:
def _parse_efuse_summary(self, output: str) -> dict[str, str]: def _parse_efuse_summary(self, output: str) -> dict[str, str]:
"""Parse espefuse summary output into a dict of name -> value. """Parse espefuse summary output into a dict of name -> value.
espefuse summary lines look like: espefuse v5.x summary lines look like:
EFUSE_NAME (BLOCK0) = 0x00000000 R/W ADC_VREF (BLOCK0) True ADC reference voltage = 1100 R/W (0b00000)
or: MAC (BLOCK0) Factory MAC address = ab:cd:ef:01:02:03 R/W (0x...)
MAC (BLOCK0) = ab:cd:ef:01:02:03 R/W The value sits between '= ' and the R/W permission field.
""" """
efuses: dict[str, str] = {} efuses: dict[str, str] = {}
for line in output.splitlines(): for line in output.splitlines():
# Match lines with "NAME (BLOCKn) ... = value" # Match: NAME (BLOCKn) <description> = <value> R/W|R/-|-/- (<hex>)
match = re.match(r"\s*(\w+)\s+\(BLOCK\d+\)\s+.*?=\s+(.+?)\s+[RW/-]+\s*$", line) match = re.match(
r"\s*(\w+)\s+\(BLOCK\d+\)\s+.*?=\s+(.+?)\s+[RW/-]+/[RW/-]+\s",
line,
)
if match: if match:
name = match.group(1).strip() name = match.group(1).strip()
value = match.group(2).strip() value = match.group(2).strip()