Skip to content

espefuse.py can't create a json file (ESPTOOL-1367) #1180

Description

@S3bz0n3

Operating System

Windows11

Esptool Version

V5.5.4

Python Version

3.14.4

Chip Description

ESP32

Device Description

I'm using the ESP32 Wrover E

Hardware Configuration

SPI and I2C several LEDs and GPIOS are used

How is Esptool Run

VS Code

Full Esptool Command Line that Was Run

C:\Espressif\tools\python\v5.5.4\venv\Scripts\python.exe D:\ESP.espressif\v5.5.4\esp-idf\components\esptool_py\esptool\espefuse.py -p COM4 summary --format json --file D:\test.json

Esptool Output

C:\Espressif\tools\python\v5.5.4\venv\Scripts\python.exe D:\ESP\.espressif\v5.5.4\esp-idf\components\esptool_py\esptool\espefuse.py -p COM4 summary --format json --file D:\test.json
espefuse.py v4.12.0
Connecting....
Detecting chip type... ESP32

=== Run "summary" command ===
Saving efuse values to D:\test.json

More Information

The root cause is a missing file.close() call in the JSON output path of the summary() method in espefuse/efuse/base_operations.py.

The human-readable output path correctly closes the file:
if human_output:
for line in summary_efuse:
log.print(escape(line), file=file)
if file != sys.stdout:
file.close() # ✅ file is closed, buffer is flushed
log.print("Done")
elif format == "json":
json.dump(json_efuse, file, sort_keys=True, indent=4)
log.print("") # ❌ file is never closed, buffer is lost

Suggested fix
elif format == "json":
json.dump(json_efuse, file, sort_keys=True, indent=4)
if file != sys.stdout:
file.close()
log.print("")

Other Steps to Reproduce

python -m espefuse --port COM4 summary --format json --file output.json

Command reports success: "Saving efuse values to output.json"

But: output.json is 0 bytes

I Have Read the Troubleshooting Guide

  • I confirm I have read the troubleshooting guide.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions