Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 46 additions & 21 deletions espefuse.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

import esptool

import json

# Table of efuse values - (category, block, word in block, mask, write disable bit, read disable bit, type, description)
# Match values in efuse_reg.h & Efuse technical reference chapter
EFUSES = [
Expand Down Expand Up @@ -496,10 +498,16 @@ def dump(esp, _efuses, args):
def summary(esp, efuses, args):
""" Print a human-readable summary of efuse contents """
ROW_FORMAT = "%-22s %-50s%s= %s %s %s"
print(ROW_FORMAT.replace("-50", "-12") % ("EFUSE_NAME", "Description", "", "[Meaningful Value]", "[Readable/Writeable]", "(Hex Value)"))
print("-" * 88)
human_output = (args.format == 'summary')
json_efuse = {}
if args.file != sys.stdout:
print("Saving efuse values to " + args.file.name)
if human_output:
print(ROW_FORMAT.replace("-50", "-12") % ("EFUSE_NAME", "Description", "", "[Meaningful Value]", "[Readable/Writeable]", "(Hex Value)"),file=args.file)
print("-" * 88,file=args.file)
for category in set(e.category for e in efuses):
print("%s fuses:" % category.title())
if human_output:
print("%s fuses:" % category.title(),file=args.file)
for e in (e for e in efuses if e.category == category):
raw = e.get_raw()
try:
Expand All @@ -515,25 +523,40 @@ def summary(esp, efuses, args):
perms = "-/W"
else:
perms = "-/-"
value = str(e.get())
base_value = e.get()
value = str(base_value)
if not readable:
value = value.replace("0", "?")
print(ROW_FORMAT % (e.register_name, e.description, "\n " if len(value) > 20 else "", value, perms, raw))
if human_output:
print(ROW_FORMAT % (e.register_name, e.description, "\n " if len(value) > 20 else "", value, perms, raw),file=args.file)
if args.format == 'json':
json_efuse[e.register_name] = {
'value': base_value if readable else value,
'readable':readable,
'writeable':writeable}
if human_output:
print("",file=args.file)
if human_output:
sdio_force = efuses["XPD_SDIO_FORCE"]
sdio_tieh = efuses["XPD_SDIO_TIEH"]
sdio_reg = efuses["XPD_SDIO_REG"]
if sdio_force.get() == 0:
print("Flash voltage (VDD_SDIO) determined by GPIO12 on reset (High for 1.8V, Low/NC for 3.3V).",file=args.file)
elif sdio_reg.get() == 0:
print("Flash voltage (VDD_SDIO) internal regulator disabled by efuse.",file=args.file)
elif sdio_tieh.get() == 0:
print("Flash voltage (VDD_SDIO) set to 1.8V by efuse.",file=args.file)
else:
print("Flash voltage (VDD_SDIO) set to 3.3V by efuse.",file=args.file)
warnings = efuses.get_coding_scheme_warnings()
if warnings:
print("WARNING: Coding scheme has encoding bit error warnings (0x%x)" % warnings,file=args.file)
if args.file != sys.stdout:
args.file.close()
print("Done")
if args.format == 'json':
json.dump(json_efuse,args.file,sort_keys=True,indent=4)
print("")
sdio_force = efuses["XPD_SDIO_FORCE"]
sdio_tieh = efuses["XPD_SDIO_TIEH"]
sdio_reg = efuses["XPD_SDIO_REG"]
if sdio_force.get() == 0:
print("Flash voltage (VDD_SDIO) determined by GPIO12 on reset (High for 1.8V, Low/NC for 3.3V).")
elif sdio_reg.get() == 0:
print("Flash voltage (VDD_SDIO) internal regulator disabled by efuse.")
elif sdio_tieh.get() == 0:
print("Flash voltage (VDD_SDIO) set to 1.8V by efuse.")
else:
print("Flash voltage (VDD_SDIO) set to 3.3V by efuse.")
warnings = efuses.get_coding_scheme_warnings()
if warnings:
print("WARNING: Coding scheme has encoding bit error warnings (0x%x)" % warnings)


def burn_efuse(esp, efuses, args):
Expand Down Expand Up @@ -836,8 +859,10 @@ def add_force_write_always(p):
help='Run espefuse.py {command} -h for additional help')

subparsers.add_parser('dump', help='Dump raw hex values of all efuses')
subparsers.add_parser('summary',
help='Print human-readable summary of efuse values')
p = subparsers.add_parser('summary',
help='Print human-readable summary of efuse values')
p.add_argument('--format', help='Select the summary format',choices=['summary','json'],default='summary')
p.add_argument('--file', help='File to save the efuse summary',type=argparse.FileType('w'),default=sys.stdout)

p = subparsers.add_parser('burn_efuse',
help='Burn the efuse with the specified name')
Expand Down