Skip to content

imgtool: Output format option to dumpinfo#2622

Merged
de-nordic merged 1 commit intomcu-tools:mainfrom
5frank:dumpinfo_format
Mar 4, 2026
Merged

imgtool: Output format option to dumpinfo#2622
de-nordic merged 1 commit intomcu-tools:mainfrom
5frank:dumpinfo_format

Conversation

@5frank
Copy link

@5frank 5frank commented Feb 4, 2026

Add -f, --format option to support multiple output formats (human, yaml,
json). Default yaml for file, default human for stdout - backward
compatible.

Details:

  • Human output is unchanged
  • Refactored dump_imginfo() to separate data reading from formatting
  • JSON output uses hex strings for binary data (e.g., "e3a333ca...")
  • YAML and JSON have both "type" (int) and "type_name" (str) for TLVs
  • Image filename (basename) is included in all output formats
  • Argument --silent is silently ignored. Doesn't make sense for a
    command that outputs data. i.e. No output on success. This is the same
    as for other sub commands

@5frank 5frank requested a review from d3zd3z as a code owner February 4, 2026 17:16
@nordicjm
Copy link
Collaborator

nordicjm commented Feb 5, 2026

@fundakol please review

@nordicjm
Copy link
Collaborator

nordicjm commented Feb 5, 2026

@5frank please see failing CI

@fundakol
Copy link
Collaborator

fundakol commented Feb 5, 2026

Usage of dumpinfo is now very confusing.

  • this command does nothing: imgtool dumpinfo zephyr.signed.bin --format human -o dump.txt --silent
  • this command: imgtool dumpinfo zephyr.signed.bin --format human -o dump.txt works same as imgtool dumpinfo zephyr.signed.bin and imgtool dumpinfo zephyr.signed.bin --format yaml
  • when human format is selected option outfile has no effect

imgtool dumpinfo zephyr.signed.bin --format yaml -o dump.yaml --> produced different yaml then it was before your change, so it is not backward compatible.

@5frank
Copy link
Author

5frank commented Feb 13, 2026

@fundakol Tanks for the feedback!
You are right, it is confusing. --silent option makes no sense in combination with dumpinfo. Perhaps it had some purpose before!? I changed it to be silently ignored.

@5frank
Copy link
Author

5frank commented Feb 13, 2026

Sorry for fragmented PR. I added type_name to both yaml and json output. I fail to see how it would break anything.

@nordicjm
Copy link
Collaborator

@5frank see failing CI

@nordicjm
Copy link
Collaborator

@5frank see failing CI

Add -f, --format option to support multiple output formats (human, yaml,
json). Default yaml for file, default human for stdout - backward
compatible.

Details:
- Human output is unchanged
- Refactored dump_imginfo() to separate data reading from formatting
- JSON output uses hex strings for binary data (e.g., "e3a333ca...")
- YAML and JSON have both "type" (int) and "type_name" (str) for TLVs
- Image filename (basename) is included in all output formats
- Argument `--silent` is silently ignored. Doesn't make sense for a
  command that outputs data. i.e. No output on success. This is the same
  as for other sub commands

Signed-off-by: Simon Frank <simon.frank@lohmega.com>
Copy link
Collaborator

@fundakol fundakol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good. I could make a few comments about code formatting, but since we don't have any rules defined for this repository, I don't want to block this PR.

@de-nordic de-nordic merged commit 7448115 into mcu-tools:main Mar 4, 2026
65 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants