[PATCH 17/17] android: boot: support bootconfig

Safae Ouajih souajih at baylibre.com
Sat Nov 26 17:59:31 CET 2022


This adds support for Bootconfig feature.
- The bootconfig feature replaces the androidboot.*
  kernel cmdline options.
- CONFIG_LIBXBC must be enabled

Signed-off-by: Safae Ouajih <souajih at baylibre.com>
---
 boot/image-android.c    | 22 +++++++++++++++++++++-
 include/android_image.h |  3 +++
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/boot/image-android.c b/boot/image-android.c
index 557047660bc3..1c4d21e945a1 100644
--- a/boot/image-android.c
+++ b/boot/image-android.c
@@ -14,6 +14,10 @@
 #include <mapmem.h>
 #include <linux/libfdt.h>
 
+#ifdef CONFIG_LIBXB
+#include <xbc.h>
+#endif
+
 #define ANDROID_IMAGE_DEFAULT_KERNEL_ADDR	0x10008000
 
 static char andr_tmp_str[ANDR_BOOT_ARGS_SIZE + 1];
@@ -60,6 +64,7 @@ static void android_vendor_boot_image_v3_v4_parse_hdr(const struct andr_vendor_b
 	data->image_name = hdr->name;
 	data->kernel_addr = hdr->kernel_addr;
 	data->ramdisk_addr = hdr->ramdisk_addr;
+	data->bootconfig_size = hdr->bootconfig_size;
 	end = (ulong)hdr;
 	end += hdr->page_size;
 	if (hdr->vendor_ramdisk_size) {
@@ -74,7 +79,15 @@ static void android_vendor_boot_image_v3_v4_parse_hdr(const struct andr_vendor_b
 
 	end += ALIGN(hdr->dtb_size, hdr->page_size);
 	end += ALIGN(hdr->vendor_ramdisk_table_size, hdr->page_size);
-	end += ALIGN(hdr->bootconfig_size, hdr->page_size);
+#ifdef CONFIG_LIBXB
+	data->bootconfig_addr = end;
+	if (hdr->bootconfig_size) {
+		data->bootconfig_size += addBootConfigTrailer(data->bootconfig_addr,
+							      data->bootconfig_size);
+		data->ramdisk_size += data->bootconfig_size;
+	}
+#endif
+	end += ALIGN(data->bootconfig_size, hdr->page_size);
 	data->vendor_boot_img_total_size = end - (ulong)hdr;
 }
 
@@ -351,6 +364,13 @@ int android_image_get_ramdisk(const void *hdr, const void *vendor_boot_img,
 		       img_data.vendor_ramdisk_size);
 		memcpy((void *)(ramdisk_ptr + img_data.vendor_ramdisk_size),
 		       (void *)img_data.ramdisk_ptr, img_data.boot_ramdisk_size);
+#ifdef CONFIG_LIBXB
+		if (img_data.bootconfig_size) {
+			memcpy((void *)(ramdisk_ptr + img_data.vendor_ramdisk_size +
+			       img_data.boot_ramdisk_size), (void *)img_data.bootconfig_addr,
+			       img_data.bootconfig_size);
+		}
+#endif
 	}
 
 	printf("RAM disk load addr 0x%08lx size %u KiB\n",
diff --git a/include/android_image.h b/include/android_image.h
index b9591633c9f7..17412a609320 100644
--- a/include/android_image.h
+++ b/include/android_image.h
@@ -333,6 +333,9 @@ struct andr_image_data {
 	ulong recovery_dtbo_ptr;
 	u32 recovery_dtbo_size;
 
+	ulong bootconfig_addr;
+	ulong bootconfig_size;
+
 	const char *kcmdline;
 	const char *kcmdline_extra;
 	const char *image_name;
-- 
2.25.1



More information about the U-Boot mailing list