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

Support header_version up to version 2 #7

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

alexlarsson
Copy link

This adds support for header_version 1 and 2, including dtb and dtbo support.

In addition it fixes various bugs and adds some tests. See the commits for details.

This needs to be ssize, not ksize.
When creating a new image, if the stat fails with ENOENT we need to
not check if it is a block device, we now do that randomly if the
`S_ISBLK(st.st_mode)` check happens to pas with uninitialized `st`.
We need to skip the ramdisk as well to get to the second part.
It was using the ramdisk size
This means less duplicated code, especially when we later
add support for more parts.
This imports bootimh.h from upstream commit
e55998a0f2b61b685d5eb4a486ca3a0c680b1a2f, which has added v2 support.

(File is: https://android.googlesource.com/platform/system/tools/mkbootimg/+/e55998a0f2b61b685d5eb4a486ca3a0c680b1a2f/include/bootimg/bootimg.h)

The upstream version was C++, so the struct derivation like:

  struct boot_img_hdr_v1 : public boot_img_hdr_v0 {
    uint32_t recovery_dtbo_size;
    ...

Was changed to:

  struct boot_img_hdr_v1 {
    struct boot_img_hdr_v0 v0;
    uint32_t recovery_dtbo_size;
    ...

To make this work in C.
This adds support for the "recovery dtbo" and "dtb" parts in the header.

Whenever we add a feature from the later versions we update the header
version, but we never go backwards with versions. New headers start as
version 1, so will only become 1 or 2 as needed.

We also display some new information from v0 headers that were not shown
before (os version, header version), as well as the new data in the v1
and v2 headers.
This builds and inspects some images in various ways and checks
that we get the right results.
@alexlarsson
Copy link
Author

Fixed some commit message typos

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.

None yet

1 participant