-
Notifications
You must be signed in to change notification settings - Fork 147
Check chip using metadata #816
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I'm honestly not sure where exactly to add the checks. We could modify |
|
I think I agree that it's a bit much for If you don't like that idea, I also think what you currently have isn't so bad, it's just three checks. |
|
I've grouped the two bits of metadata into |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds chip detection via metadata extracted from the ELF file to ensure that the firmware being flashed matches the target device. Key changes include:
- Introduction of a new Metadata module to parse metadata from the ELF file.
- Integration of chip detection in both the CLI and cargo tools via an added ensure_chip_compatibility function.
- Addition of a new FirmwareChipMismatch error variant to handle chip mismatches.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| espflash/src/image_format/mod.rs | Re-exports the new Metadata module. |
| espflash/src/image_format/metadata.rs | Implements Metadata parsing from the ELF’s .espressif.metadata section. |
| espflash/src/error.rs | Adds a new FirmwareChipMismatch error variant. |
| espflash/src/cli/monitor/mod.rs | Updates log format detection to use the Metadata instead of raw symbols. |
| espflash/src/cli/mod.rs | Adds the ensure_chip_compatibility function and updates bin writing logic. |
| cargo-espflash/src/main.rs | Integrates chip compatibility check into the flashing workflow. |
| CHANGELOG.md | Updates the changelog to reflect the addition of chip detection. |
Comments suppressed due to low confidence (1)
espflash/src/cli/mod.rs:1090
- [nitpick] The variable 'elf_chip' is reused (shadowed) in the match block, which can be confusing. Consider renaming the parsed output (for example, to 'parsed_chip') for clarity.
match Chip::from_str(elf_chip, false) {
Move metadata handling out of Symbols Clippy
SergioGasquez
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks
espflash/src/cli/monitor/mod.rs
Outdated
|
|
||
| mod line_endings; | ||
| mod symbols; | ||
| pub(crate) mod symbols; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry if I've missed something, but why does the visibility of this module need to change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It shouldn't I just forgot to undo it, thanks
This PR reads chip name from the .elf and prevents flashing if it differs from the detected device.