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

Add the esp-idf bootloader support crate #3281

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

bjoernQ
Copy link
Contributor

@bjoernQ bjoernQ commented Mar 20, 2025

Thank you for your contribution!

We appreciate the time and effort you've put into this pull request.
To help us review it efficiently, please ensure you've gone through the following checklist:

Submission Checklist 📝

  • I have updated existing examples or added new ones (if applicable).
  • I have used cargo xtask fmt-packages command to ensure that all changed code is formatted correctly.
  • My changes were added to the CHANGELOG.md in the proper section.
  • I have added necessary changes to user code to the Migration Guide.
  • My changes are in accordance to the esp-rs developer guidelines

Extra:

Pull Request Details 📖

Description

This adds the initial esp-bootloader-support-esp-idf - only supports the app-descriptor for now

See #3124 (review)

Next steps would be

When we add MCUboot support we will have a similar crate for that

skip-changelog because of the change to the linker script

Testing

As said for now this offers limited functionality. To easily test that

  • add a dependency in examples
  • add esp_bootloader_support_esp_idf::esp_app_desc!(); to one of the examples
  • run the example
  • build a recent esp-idf bootloader (e.g. from 5.4)
  • use espflash to flash the example with the bootloader built above
  • hopefully see it boots fine

@bjoernQ bjoernQ added the skip-changelog No changelog modification needed label Mar 20, 2025
@bjoernQ bjoernQ force-pushed the esp-idf-bootloader-support-crate branch from 1c49519 to 3844552 Compare March 20, 2025 13:28
@@ -1,4 +1,5 @@
.rodata_desc : ALIGN(4)
{
/* this might get replaced with actual data by build.rs */
KEEP(*(.rodata_desc));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

to make sure the linker won't discard it when nothing else is referencing it

@bjoernQ bjoernQ marked this pull request as ready for review March 20, 2025 14:00
const fn str_to_cstr_array<const C: usize>(s: &str) -> [::core::ffi::c_char; C] {
let bytes = s.as_bytes();
if bytes.len() >= C {
assert!(true, "String is too long for the C-string field");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be false?

I suppose you could just move the bytes.len() < C into the assert. 😄

Copy link
Contributor Author

@bjoernQ bjoernQ Mar 21, 2025

Choose a reason for hiding this comment

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

actually it's useless - the compiler will understand the overflow even before we can assert anything - so I removed this

(I admit, initially I pretty much just copied this code from somewhere)

@bjoernQ bjoernQ marked this pull request as draft March 21, 2025 07:48
@bjoernQ bjoernQ marked this pull request as ready for review March 21, 2025 08:55
@bugadani
Copy link
Contributor

Just a wild idea that popped up, could we/should we store the partition table as metadata for this crate (even if optionally, through a feature/config)? It's technically not part of the application itself, but it's I think also rare to have a single application work with multiple partition tables.

@bjoernQ
Copy link
Contributor Author

bjoernQ commented Mar 25, 2025

Just a wild idea that popped up, could we/should we store the partition table as metadata for this crate (even if optionally, through a feature/config)? It's technically not part of the application itself, but it's I think also rare to have a single application work with multiple partition tables.

You mean in .espressif.metadata? If there is any place where we want to do that, then it's this crate 😄

Not entirely sure what the use-case would be? espflash reading and using it? I see how this makes it easier to pass an ELF to someone to flash it but on the other hand should we remove the parition-table argument from espflash? If not how to resolve conflicting information

Maybe I just don't see the obvious 😆

But this sparked a different idea: Later I will add things like OTA and NVS support (which probably need to be features since they will change the available APIs) and we could encode that in the metadata to signal to the flashing tool (i.e. espflash) that an OTA / NVS partition is needed and refuse to flash if not 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-changelog No changelog modification needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants