-
Notifications
You must be signed in to change notification settings - Fork 147
Improve app-descriptor detection #975
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
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -809,10 +809,17 @@ where | |
| pub fn check_idf_bootloader(elf_data: &Vec<u8>) -> Result<()> { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've just tried using this function in probe-rs to fix probe-rs/probe-rs#3564 and come on why are we returning a miette diagnostic from this...?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should change that! maybe there are more places like this?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but ... probably for 5.x since this is already published public API :(
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK I've managed to work around it by this line - turning the diagnostic back into a string, and wrapping it into the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We either shouldn't use miette in the library, or embrace it and don't expose espflash's error type, but this hybrid mess is just sad.
We can extract the implementation into another function that returns the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
+1 ... we probably shouldn't embrace it but scrape it from the API surface
sure - and deprecate the current function for now Might be worth a separate issue ... pretty sure comments on a merged PR will be lost in an instant |
||
| let object = File::parse(elf_data.as_slice()).into_diagnostic()?; | ||
|
|
||
| let has_app_desc = object.symbols().any(|sym| sym.name() == Ok("esp_app_desc")); | ||
| let is_esp_hal = object.section_by_name(".espressif.metadata").is_some(); | ||
| // A project with `strip = true` will discard the | ||
| // symbol we are looking for but the section is kept | ||
| let has_app_desc = object.symbols().any(|sym| sym.name() == Ok("esp_app_desc")) | ||
| || object.section_by_name(".flash.appdesc").is_some() | ||
| || object.section_by_name(".rodata_desc").is_some(); | ||
|
|
||
| if !has_app_desc { | ||
| // when using `strip = true` we will (maybe wrongly) assume ESP-IDF | ||
| // but at least it should still guide the user into the right direction | ||
| let is_esp_hal = object.section_by_name(".espressif.metadata").is_some(); | ||
|
|
||
| if is_esp_hal { | ||
| return Err(Error::AppDescriptorNotPresent( | ||
| "ESP-IDF App Descriptor (https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/app_image_format.html#application-description) missing in your`esp-hal` application.\n | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.