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

Determine size of bootloader dynamically #2

Open
svenrademakers opened this issue May 8, 2024 · 0 comments
Open

Determine size of bootloader dynamically #2

svenrademakers opened this issue May 8, 2024 · 0 comments

Comments

@svenrademakers
Copy link
Contributor

Add the necessary sunxi_boot_size function to determine it dynamically from headers:

  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.

Originally posted by @CFSworks in #1 (comment)

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

No branches or pull requests

1 participant