Implement an ELF Loader#12
Merged
Merged
Conversation
Signed-off-by: Alice Ziuziakowska <a.ziuziakowska@lowrisc.org>
Signed-off-by: Alice Ziuziakowska <a.ziuziakowska@lowrisc.org>
engdoreis
reviewed
May 27, 2026
3370378 to
0aceb00
Compare
engdoreis
reviewed
May 27, 2026
| if ((addr % flash::PageSize) != 0) { | ||
| auto to_next = flash::PageSize - (addr % flash::PageSize); | ||
| auto n = std::min(to_next, data.size()); | ||
| std::vector<uint8_t> page(data.first(n).begin(), data.first(n).end()); |
Collaborator
There was a problem hiding this comment.
is this copy due to the type difference?
Contributor
Author
There was a problem hiding this comment.
Yes, the page program commands expect a std::span<uint8_t>, I think because the underlying transfer operations use a RW span and use an enum for the transfer direction type.
Signed-off-by: Alice Ziuziakowska <a.ziuziakowska@lowrisc.org>
engdoreis
approved these changes
May 28, 2026
This was referenced May 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements a simple ELF loader using the ELFIO header-library, exposed through a new
bootstrap-elfcommand.This loader first erases the sectors corresponding to each segment, and then programs them. For binaries which are quite sparse (the main use-case for this is OpenSBI+payload firmwares) this saves a lot of time by not writing gaps between segments.
With this ELF loader we should also be able to remove the dependency on objcopy'd
.binfiles in Mocha (1), (2).Comparison (put the board into Bootstrap mode using
ftditool gpio-write --ftdi Digilent 0 0, then2 0and then2 1: