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

Fix image creation for direct boot #118

Merged

Conversation

bjoernQ
Copy link
Contributor

@bjoernQ bjoernQ commented Dec 31, 2021

This goes together with: MabezDev/esp32c3-experiments#5

It just doesn't produce gaps between the segments.

Edit:
Turned out the code used the VMA addresses of the sections but it's needed to use the LMA

Some additional logging statements revealed this:

CodeSegment addr=42000000 len=8, new addr = 0
CodeSegment addr=42000008 len=b378, new addr = 8
CodeSegment addr=3c00b380 len=32d8, new addr = b380
CodeSegment addr=3fc80000 len=c, new addr = 80000
length = 524300

So, it added 478336 zero bytes before the .data section

Now it looks like this

CodeSegment addr=0 len=8, new addr = 0
CodeSegment addr=8 len=b378, new addr = 8
CodeSegment addr=b380 len=32d8, new addr = b380
CodeSegment addr=e660 len=c, new addr = e660
length = 58988

Also, the final image looks like this when using probe-rs for flashing.

@icewind1991
Copy link
Member

I don't think this is correct, the padding should be required when merging segments that have blank space between them, otherwise the memory mapping wont line up with the flash addresses

@bjoernQ
Copy link
Contributor Author

bjoernQ commented Dec 31, 2021

In my understanding the flash just gets mapped twice linearly - certainly the LMA and VMA needs to be configured accordingly in the linker script

The current implementation generates a 500k image for the Rust sample because of the gaps.

@bjoernQ
Copy link
Contributor Author

bjoernQ commented Dec 31, 2021

But I agree it's probably solvable just with the linker script and no change here. Would be better but not sure yet

Will look into that tomorrow

@bjoernQ bjoernQ force-pushed the fix-direct-boot-image-generation branch from 0cfe92b to 28d3615 Compare January 1, 2022 14:38
@bjoernQ bjoernQ changed the title For direct boot: copy segments without gaps into the resulting image Fix image creation for direct boot Jan 1, 2022
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.

LGTM, thanks! Seems to have fixed the incorrect output for DATA_SECTION_TEST in the esp32c3-experiments repository as intended.

@jessebraham jessebraham merged commit eeb0e8f into esp-rs:master Feb 8, 2022
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.

3 participants