Support Samsung 2SI with skip_initramfs in dtb cmdline

Samsung Galaxy A21S and Galaxy M12, probably others, are hdr_v2 boot.img with 2SI judging by the ramdisk contents, but the dtb contains an extra cmdline with skip_initramfs present, even though this shouldn't exist on 2SI and the kernel apparently doesn't even contain a skip_initramfs function

I can't find examples of other devices where skip_initramfs is present in the dtb other than these so patch it out like we do the kernel

Co-authored-by: topjohnwu <topjohnwu@gmail.com>
This commit is contained in:
Chris Renshaw 2021-10-30 21:20:10 -07:00 committed by topjohnwu
parent 6663fd3526
commit 59161efd08

View File

@ -141,8 +141,22 @@ static bool dtb_patch(const char *file) {
fdt = static_cast<uint8_t*>(memmem(fdt, end - fdt, DTB_MAGIC, sizeof(fdt32_t))); fdt = static_cast<uint8_t*>(memmem(fdt, end - fdt, DTB_MAGIC, sizeof(fdt32_t)));
if (fdt == nullptr) if (fdt == nullptr)
break; break;
if (int fstab = find_fstab(fdt); fstab >= 0) {
int node; int node;
// Patch the chosen node for bootargs
fdt_for_each_subnode(node, fdt, 0) {
if (fdt_get_name(fdt, node, nullptr) != "chosen"sv)
continue;
int len;
if (char *value = (char *) fdt_getprop(fdt, node, "bootargs", &len)) {
if (char *skip = strstr(value, "skip_initramfs")) {
fprintf(stderr, "Patch [skip_initramfs] -> [want_initramfs]\n");
// Don't use strcpy, we do NOT want it null terminated
memcpy(skip, "want", 4);
patched = true;
}
}
}
if (int fstab = find_fstab(fdt); fstab >= 0) {
fdt_for_each_subnode(node, fdt, fstab) { fdt_for_each_subnode(node, fdt, fstab) {
if (!keep_verity) { if (!keep_verity) {
int len; int len;