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

Move esp-idf bootloader and partition table to known location after build #97

Closed
MabezDev opened this issue May 19, 2022 · 3 comments · Fixed by #264
Closed

Move esp-idf bootloader and partition table to known location after build #97

MabezDev opened this issue May 19, 2022 · 3 comments · Fixed by #264

Comments

@MabezDev
Copy link
Member

Currently, they are tucked away in the build folder of esp-idf-sys, in which a unique fingerprint is appended to the folder name. E.g

target/xtensa-esp32-espidf/debug/build/esp-idf-sys-1d1212f75c9bfd7a/out/build/bootloader/bootloader.bin

Because of the fingerprint, it's not possible for tooling (like espflash) to grab the bootloader and partition table automatically. If we moved it to a known location in the target directory we could allow tooling to automatically pick up bootload and partition table changes.

I think moving them to the $TARGET/$PROFILE/ makes sense. E.g target/xtensa-esp32-espidf/debug/build/esp-idf-sys-1d1212f75c9bfd7a/out/build/bootloader/bootloader.bin would get copied to target/xtensa-esp32-espidf/debug/bootloader.bin.

@N3xed
Copy link
Collaborator

N3xed commented May 19, 2022

You can actually build the crate with cargo build --message-format json and extract these messages with the cargo_metadata crate (using cargo_metadata::MessageIter). One such message is BuildScript which contains the path to the our-dir of that build script.

I actually use that approach in my (very long) WIP cargo-idf tool here. You can get almost all information with that and cargo metadata.

@MabezDev
Copy link
Member Author

That's a good point! Definitely useful for the cases where the tool is invoking the cargo build process. In the case of espflash (note, not cargo-espflash, the wrapper) it is typically used as a cargo runner, and has no sway over cargo's build process.

Hypothetical usage I am picturing.

[target.xtensa-esp32s2-espidf]
runner = "espflash --bootloader target/bootloader.bin --monitor"

I suppose it be possible to write a build script that could find the esp-idf-sys directory inside target/ and move it to where ever?

@jessebraham
Copy link
Member

@MabezDev I have followed the advice of @N3xed and used the messages provided by cargo_metadata to locate bootloader.bin/partition-table.bin and use them whenever able in cargo-espflash. Once I have tested this more I will open a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants