Support GKIs without ramdisk

Fix #5819
This commit is contained in:
topjohnwu
2022-05-12 03:04:55 -07:00
parent 622e09862a
commit 985249c3d0
3 changed files with 17 additions and 2 deletions

View File

@ -398,6 +398,13 @@ void boot_img::parse_image(uint8_t *addr, format_t type) {
}
fprintf(stderr, "%-*s [%s]\n", PADDING, "RAMDISK_FMT", fmt2name[r_fmt]);
}
if (!hdr->is_vendor && hdr->ramdisk_size() == 0 && hdr->header_version() == 4) {
// When a v4 boot image does not contain ramdisk, we will have to create
// the CPIO from scratch. However, since this ramdisk will have to be merged
// with other vendor ramdisks, it has to use the exact same compression method.
// v4 GKIs are required to use lz4 (legacy), so hardcode it here.
r_fmt = LZ4_LEGACY;
}
if (auto size = hdr->extra_size()) {
e_fmt = check_fmt_lg(extra, size);
fprintf(stderr, "%-*s [%s]\n", PADDING, "EXTRA_FMT", fmt2name[e_fmt]);