Skip to content
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

Make try_from() return the actual error with the partition table. #36

Merged
merged 1 commit into from
Jun 19, 2024

Conversation

AVee
Copy link
Contributor

@AVee AVee commented May 3, 2024

The try_from() function used to just try both binary and csv partition tables, which resulted in a situation where it's unknown which of the two produced a sensible error.

By checking for the magic bytes 0xAA 0x50 at the start we can know which type of file we are dealing with and parse that type, and return errors accordingly. It also makes Error::InvalidPartitionTable obsolete as it was only used in this specific scenario.

Errors from espflash now look like this:

Error:   × Failed to parse partition table
  ╰─▶ Partition with type 'data' and subtype 'ota' must have size of 0x2000 (8k) bytes

Should resolve #20

Copy link
Member

@jessebraham jessebraham left a comment

Choose a reason for hiding this comment

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

Very sorry for taking so long to get to this. This is a much better approach IMO. Thanks!

@jessebraham jessebraham merged commit 6d2d0c3 into esp-rs:main Jun 19, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No information is provided on _why_ a partition table is invalid
2 participants