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

Accommodate for bigger boot-loaders to be written #1

Merged
merged 1 commit into from
May 8, 2024

Conversation

svenrademakers
Copy link
Contributor

The changes i've added to support loading different dts's grew the bootloader over the size specified here. It took me quite a while to figure out the installer was not copying all bytes.

@CFSworks
Copy link
Collaborator

CFSworks commented May 7, 2024

Ah yeah sorry about that. I hardcoded the U-Boot image size with the intent on making it automatically determine the size (like with the root filesystem, using some code in src/image.rs to read headers and deduce how much needs copying) on a future date, and then forgot to do it! :)

This PR is fine by me to be merged, but might only serve as a band-aid. The long-term fix would be to add the necessary sunxi_boot_size function to determine it dynamically from headers. It shouldn't be too hard:

  1. Accept a <F: Read + Seek> (as does erofs_size).
  2. Seek to current position + 0x8000. The reason for "current position" (not "start") is so that the function works on either an open u-boot-sunxi-with-spl.bin (good for testing) OR the raw mmcblk0 (which is already seeked to the correct offset).
  3. At this new offset will be the contents of u-boot.img, which will either be:
  • A legacy/classic U-Boot uImage: header starts with the 4 bytes 27 05 19 56, and the total uImage size is the 64 byte header + body size stored as a big endian u32 at offset 0xC within the header.
  • A FIT: header starts with D0 0D FE ED , total header size is a big-endian u32 at offset 0x4, whole header to be parsed with fdt crate (a FIT's header is in standard FDT format). Body size is determined by iterating every child of "/images", summing together the "data-size" and "data-offset" properties of each (as usizes), then selecting the maximum. Total FIT size is header size + body size.
  1. Seek back to the original position that the caller expects.
  2. Return the boot image size as the u-boot.img size + 0x8000.

If the above seems easy for you to do, it's be the more robust option vs. just updating the hardcoded size. But if it'd be too far out of your way (especially with all of the other tasks on your plate right now), this PR can be merged and I'll paste the above paragraph into an issue instead.

@svenrademakers
Copy link
Contributor Author

It would be nice for me to get more familiar with Uboot/Fit. As you mentioned, I think this task is further down on the priority list, so I will merge this PR for now.

@svenrademakers svenrademakers merged commit 217a36e into master May 8, 2024
2 of 4 checks passed
@svenrademakers svenrademakers deleted the feature/up_bootloader_size branch May 8, 2024 08:59
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.

2 participants