public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH v2 0/5] android: add bootconfig support
@ 2025-10-17 13:19 Guillaume La Roque (TI.com)
  2025-10-17 13:19 ` [PATCH v2 1/5] boot: android: import addBootConfigParameters() from AOSP Guillaume La Roque (TI.com)
                   ` (5 more replies)
  0 siblings, 6 replies; 23+ messages in thread
From: Guillaume La Roque (TI.com) @ 2025-10-17 13:19 UTC (permalink / raw)
  To: Tom Rini, Mattijs Korpershoek
  Cc: Julien Masson, Guillaume La Roque, u-boot, Simon Glass,
	Nicolas Belin, Neil Armstrong, Andrew Goodbody, Aaron Kling,
	George Chan, Sam Day, Jerome Forissier, Maxime Fournier

This patchset add support of android bootconfig partition[1] in u-boot.
With Android boot image v4, all androidboot.* arguments must be
passed via bootconfig instead of using the kernel commandline.

[1] https://source.android.com/docs/core/architecture/bootloader/implementing-bootconfig

Signed-off-by: Guillaume La Roque (TI.com) <glaroque@baylibre.com>
---
Changes in v2:
- Add test
- Add new command to be able to load and read bootconfig before booting
- Somes fixes to works with sandbox test
- Link to v1: https://lore.kernel.org/all/20241128-bootconfig-v1-0-0e63a5dae82c@baylibre.com/

---
Guillaume La Roque (TI.com) (4):
      boot: android: Add sandbox memory mapping support
      boot: android: Add bootconfig support
      cmd: abootimg: Add 'get ramdisk' command
      test: abootimg: Add test for bootconfig handling

Mattijs Korpershoek (TI.com) (1):
      boot: android: import addBootConfigParameters() from AOSP

 boot/image-android.c                        | 180 ++++++++++++++++++++++++----
 cmd/abootimg.c                              |  35 +++++-
 test/py/tests/test_android/test_abootimg.py | 108 +++++++++++++++--
 3 files changed, 292 insertions(+), 31 deletions(-)
---
base-commit: 2ba64e303b2706e5c42a6bf982326d632342ca66
change-id: 20241128-bootconfig-276e247be992

Best regards,
-- 
Guillaume La Roque (TI.com) <glaroque@baylibre.com>


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH v2 1/5] boot: android: import addBootConfigParameters() from AOSP
  2025-10-17 13:19 [PATCH v2 0/5] android: add bootconfig support Guillaume La Roque (TI.com)
@ 2025-10-17 13:19 ` Guillaume La Roque (TI.com)
  2025-10-31 15:39   ` Mattijs Korpershoek
  2025-10-17 13:19 ` [PATCH v2 2/5] boot: android: Add sandbox memory mapping support Guillaume La Roque (TI.com)
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 23+ messages in thread
From: Guillaume La Roque (TI.com) @ 2025-10-17 13:19 UTC (permalink / raw)
  To: Tom Rini, Mattijs Korpershoek
  Cc: Julien Masson, Guillaume La Roque, u-boot, Simon Glass,
	Nicolas Belin, Neil Armstrong, Andrew Goodbody, Aaron Kling,
	George Chan, Sam Day, Jerome Forissier, Maxime Fournier

From: "Mattijs Korpershoek (TI.com)" <mkorpershoek@kernel.org>

To properly implement Android boot image v4, U-Boot must be able to
add additional entries to the bootconfig.

Add `add_bootconfig_parameters()` to do so.

This has been imported from Google's U-Boot source[1]
The variables/function names have been reworked to be
compliant with U-Boot's coding style.

[1] https://android.googlesource.com/platform/external/u-boot/+/7af0a0506d4de6f5ea147d10fb0664a8af07d326
Signed-off-by: Mattijs Korpershoek (TI.com) <mkorpershoek@kernel.org>
Signed-off-by: Guillaume La Roque (TI.com) <glaroque@baylibre.com>
---
 boot/image-android.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/boot/image-android.c b/boot/image-android.c
index e46dee0d9b3..3a0a934acc7 100644
--- a/boot/image-android.c
+++ b/boot/image-android.c
@@ -57,6 +57,44 @@ static ulong add_trailer(ulong bootconfig_start_addr, ulong bootconfig_size)
 	return BOOTCONFIG_TRAILER_SIZE;
 }
 
+/*
+ * Add a string of boot config parameters to memory appended by the trailer.
+ * NOTE: This function expects bootconfig_start_addr to be already mapped.
+ *       It works directly with the mapped pointer, not a physical address.
+ */
+u32 add_bootconfig_parameters(char *params, ulong params_size,
+			      ulong bootconfig_start_addr, u32 bootconfig_size)
+{
+	if (!params || !bootconfig_start_addr)
+		return -1;
+
+	if (params_size == 0)
+		return 0;
+
+	u32 applied_bytes = 0;
+	u32 new_size = 0;
+	ulong end = bootconfig_start_addr + bootconfig_size;
+
+	if (is_trailer_present(end)) {
+		end -= BOOTCONFIG_TRAILER_SIZE;
+		applied_bytes -= BOOTCONFIG_TRAILER_SIZE;
+		memcpy(&new_size, (void *)end, BOOTCONFIG_SIZE_SIZE);
+	} else {
+		/*
+		 * When no trailer is present, the bootconfig_size includes the actual content.
+		 * We should write new parameters right after the existing content.
+		 */
+		end = bootconfig_start_addr + bootconfig_size;
+		new_size = bootconfig_size;
+	}
+
+	memcpy((void *)end, params, params_size);
+	applied_bytes += params_size;
+	applied_bytes += add_trailer(bootconfig_start_addr,
+				     bootconfig_size + applied_bytes);
+	return applied_bytes;
+}
+
 __weak ulong get_avendor_bootimg_addr(void)
 {
 	return -1;

-- 
2.34.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v2 2/5] boot: android: Add sandbox memory mapping support
  2025-10-17 13:19 [PATCH v2 0/5] android: add bootconfig support Guillaume La Roque (TI.com)
  2025-10-17 13:19 ` [PATCH v2 1/5] boot: android: import addBootConfigParameters() from AOSP Guillaume La Roque (TI.com)
@ 2025-10-17 13:19 ` Guillaume La Roque (TI.com)
  2025-10-31 15:49   ` Mattijs Korpershoek
  2025-10-17 13:19 ` [PATCH v2 3/5] boot: android: Add bootconfig support Guillaume La Roque (TI.com)
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 23+ messages in thread
From: Guillaume La Roque (TI.com) @ 2025-10-17 13:19 UTC (permalink / raw)
  To: Tom Rini, Mattijs Korpershoek
  Cc: Julien Masson, Guillaume La Roque, u-boot, Simon Glass,
	Nicolas Belin, Neil Armstrong, Andrew Goodbody, Aaron Kling,
	George Chan, Sam Day, Jerome Forissier, Maxime Fournier

Use map_to_sysmem() to convert header pointers to physical addresses
in parse_hdr functions, and add proper map_sysmem()/unmap_sysmem()
calls in android_image_get_data() for sandbox compatibility.

Signed-off-by: Guillaume La Roque (TI.com) <glaroque@baylibre.com>
---
 boot/image-android.c | 41 ++++++++++++++++++++++++++++-------------
 1 file changed, 28 insertions(+), 13 deletions(-)

diff --git a/boot/image-android.c b/boot/image-android.c
index 3a0a934acc7..613f2aa4b9e 100644
--- a/boot/image-android.c
+++ b/boot/image-android.c
@@ -112,7 +112,7 @@ static void android_boot_image_v3_v4_parse_hdr(const struct andr_boot_img_hdr_v3
 	 * The header takes a full page, the remaining components are aligned
 	 * on page boundary.
 	 */
-	end = (ulong)hdr;
+	end = map_to_sysmem(hdr);
 	end += ANDR_GKI_PAGE_SIZE;
 	data->kernel_ptr = end;
 	data->kernel_size = hdr->kernel_size;
@@ -125,7 +125,7 @@ static void android_boot_image_v3_v4_parse_hdr(const struct andr_boot_img_hdr_v3
 	if (hdr->header_version > 3)
 		end += ALIGN(hdr->signature_size, ANDR_GKI_PAGE_SIZE);
 
-	data->boot_img_total_size = end - (ulong)hdr;
+	data->boot_img_total_size = end - map_to_sysmem(hdr);
 }
 
 static void android_vendor_boot_image_v3_v4_parse_hdr(const struct andr_vnd_boot_img_hdr
@@ -144,7 +144,7 @@ static void android_vendor_boot_image_v3_v4_parse_hdr(const struct andr_vnd_boot
 	data->ramdisk_addr = hdr->ramdisk_addr;
 	data->dtb_load_addr = hdr->dtb_addr;
 	data->bootconfig_size = hdr->bootconfig_size;
-	end = (ulong)hdr;
+	end = map_to_sysmem(hdr);
 
 	if (hdr->header_version > 3)
 		end += ALIGN(ANDR_VENDOR_BOOT_V4_SIZE, hdr->page_size);
@@ -165,12 +165,16 @@ static void android_vendor_boot_image_v3_v4_parse_hdr(const struct andr_vnd_boot
 	end += ALIGN(hdr->vendor_ramdisk_table_size, hdr->page_size);
 	data->bootconfig_addr = end;
 	if (hdr->bootconfig_size) {
-		data->bootconfig_size += add_trailer(data->bootconfig_addr,
+		void *bootconfig_ptr = map_sysmem(data->bootconfig_addr,
+						  data->bootconfig_size +
+						  BOOTCONFIG_TRAILER_SIZE);
+		data->bootconfig_size += add_trailer((ulong)bootconfig_ptr,
 						     data->bootconfig_size);
+		unmap_sysmem(bootconfig_ptr);
 		data->ramdisk_size += data->bootconfig_size;
 	}
 	end += ALIGN(data->bootconfig_size, hdr->page_size);
-	data->vendor_boot_img_total_size = end - (ulong)hdr;
+	data->vendor_boot_img_total_size = end - map_to_sysmem(hdr);
 }
 
 static void android_boot_image_v0_v1_v2_parse_hdr(const struct andr_boot_img_hdr_v0 *hdr,
@@ -185,7 +189,7 @@ static void android_boot_image_v0_v1_v2_parse_hdr(const struct andr_boot_img_hdr
 	data->header_version = hdr->header_version;
 	data->dtb_load_addr = hdr->dtb_addr;
 
-	end = (ulong)hdr;
+	end = map_to_sysmem(hdr);
 
 	/*
 	 * The header takes a full page, the remaining components are aligned
@@ -218,7 +222,7 @@ static void android_boot_image_v0_v1_v2_parse_hdr(const struct andr_boot_img_hdr
 		end += ALIGN(hdr->dtb_size, hdr->page_size);
 	}
 
-	data->boot_img_total_size = end - (ulong)hdr;
+	data->boot_img_total_size = end - map_to_sysmem(hdr);
 }
 
 bool android_image_get_bootimg_size(const void *hdr, u32 *boot_img_size)
@@ -269,31 +273,42 @@ bool android_image_get_vendor_bootimg_size(const void *hdr, u32 *vendor_boot_img
 bool android_image_get_data(const void *boot_hdr, const void *vendor_boot_hdr,
 			    struct andr_image_data *data)
 {
+	const struct andr_boot_img_hdr_v0 *bhdr;
+	const struct andr_vnd_boot_img_hdr *vhdr;
+
 	if (!boot_hdr || !data) {
 		printf("boot_hdr or data params can't be NULL\n");
 		return false;
 	}
 
-	if (!is_android_boot_image_header(boot_hdr)) {
+	bhdr = map_sysmem((ulong)boot_hdr, sizeof(*bhdr));
+	if (!is_android_boot_image_header(bhdr)) {
 		printf("Incorrect boot image header\n");
+		unmap_sysmem(bhdr);
 		return false;
 	}
 
-	if (((struct andr_boot_img_hdr_v0 *)boot_hdr)->header_version > 2) {
+	if (bhdr->header_version > 2) {
 		if (!vendor_boot_hdr) {
 			printf("For boot header v3+ vendor boot image has to be provided\n");
+			unmap_sysmem(bhdr);
 			return false;
 		}
-		if (!is_android_vendor_boot_image_header(vendor_boot_hdr)) {
+		vhdr = map_sysmem((ulong)vendor_boot_hdr, sizeof(*vhdr));
+		if (!is_android_vendor_boot_image_header(vhdr)) {
 			printf("Incorrect vendor boot image header\n");
+			unmap_sysmem(vhdr);
+			unmap_sysmem(bhdr);
 			return false;
 		}
-		android_boot_image_v3_v4_parse_hdr(boot_hdr, data);
-		android_vendor_boot_image_v3_v4_parse_hdr(vendor_boot_hdr, data);
+		android_boot_image_v3_v4_parse_hdr((const struct andr_boot_img_hdr_v3 *)bhdr, data);
+		android_vendor_boot_image_v3_v4_parse_hdr(vhdr, data);
+		unmap_sysmem(vhdr);
 	} else {
-		android_boot_image_v0_v1_v2_parse_hdr(boot_hdr, data);
+		android_boot_image_v0_v1_v2_parse_hdr(bhdr, data);
 	}
 
+	unmap_sysmem(bhdr);
 	return true;
 }
 

-- 
2.34.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v2 3/5] boot: android: Add bootconfig support
  2025-10-17 13:19 [PATCH v2 0/5] android: add bootconfig support Guillaume La Roque (TI.com)
  2025-10-17 13:19 ` [PATCH v2 1/5] boot: android: import addBootConfigParameters() from AOSP Guillaume La Roque (TI.com)
  2025-10-17 13:19 ` [PATCH v2 2/5] boot: android: Add sandbox memory mapping support Guillaume La Roque (TI.com)
@ 2025-10-17 13:19 ` Guillaume La Roque (TI.com)
  2025-10-31 15:58   ` Mattijs Korpershoek
  2025-10-17 13:19 ` [PATCH v2 4/5] cmd: abootimg: Add 'get ramdisk' command Guillaume La Roque (TI.com)
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 23+ messages in thread
From: Guillaume La Roque (TI.com) @ 2025-10-17 13:19 UTC (permalink / raw)
  To: Tom Rini, Mattijs Korpershoek
  Cc: Julien Masson, Guillaume La Roque, u-boot, Simon Glass,
	Nicolas Belin, Neil Armstrong, Andrew Goodbody, Aaron Kling,
	George Chan, Sam Day, Jerome Forissier, Maxime Fournier

For android vendor boot image version 4 bootconfig is mandatory.[1]

In the android_image_get_ramdisk function, after copying both vendor and
boot ramdisks, we extract all androidboot.* entries from the kernel
command line. These entries are added to the bootconfig section.
We then update the sizes of the ramdisk and bootconfig.
Finally, all androidboot.* entries are removed from the kernel command
line.

Signed-off-by: Guillaume La Roque (TI.com) <glaroque@baylibre.com>
---
 boot/image-android.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 93 insertions(+), 8 deletions(-)

diff --git a/boot/image-android.c b/boot/image-android.c
index 613f2aa4b9e..cf038a4a62f 100644
--- a/boot/image-android.c
+++ b/boot/image-android.c
@@ -534,17 +534,102 @@ int android_image_get_ramdisk(const void *hdr, const void *vendor_boot_img,
 			ramdisk_ptr = img_data.ramdisk_addr;
 		}
 		*rd_data = ramdisk_ptr;
-		memcpy((void *)(ramdisk_ptr), (void *)img_data.vendor_ramdisk_ptr,
+
+		/* Extract androidboot.* parameters from bootargs */
+		const char *bootargs = env_get("bootargs");
+		char *androidboot_params = NULL;
+		char *new_bootargs = NULL;
+		size_t androidboot_params_len = 0;
+
+		if (bootargs && img_data.bootconfig_size) {
+			size_t len = strlen(bootargs);
+
+			androidboot_params = malloc(len + 1);
+			new_bootargs = malloc(len + 1);
+			if (!androidboot_params || !new_bootargs) {
+				free(androidboot_params);
+				free(new_bootargs);
+				printf("Error: malloc failed\n");
+				return -ENOMEM;
+			}
+
+			/* Extract androidboot.* and build new bootargs in one pass */
+			const char *src = bootargs;
+			char *bc_dst = androidboot_params;
+			char *args_dst = new_bootargs;
+
+			while (*src) {
+				/* Skip leading spaces */
+				while (*src == ' ')
+					src++;
+				if (!*src)
+					break;
+
+				/* Check if this param starts with androidboot. */
+				if (strncmp(src, "androidboot.", 12) == 0) {
+					/* Copy to bootconfig (add newline if not first) */
+					if (bc_dst != androidboot_params)
+						*bc_dst++ = '\n';
+					while (*src && *src != ' ')
+						*bc_dst++ = *src++;
+				} else {
+					/* Copy to new bootargs (add space if not first) */
+					if (args_dst != new_bootargs)
+						*args_dst++ = ' ';
+					while (*src && *src != ' ')
+						*args_dst++ = *src++;
+				}
+			}
+
+			*bc_dst++ = '\n';  /* Final newline for bootconfig */
+			*bc_dst = '\0';
+			*args_dst = '\0';
+			androidboot_params_len = bc_dst - androidboot_params;
+
+			/* Update bootargs if we extracted any androidboot params */
+			if (androidboot_params_len > 1)
+				env_set("bootargs", new_bootargs);
+		}
+
+		/* Map addresses for memcpy operations */
+		void *ramdisk_dest = map_sysmem(ramdisk_ptr, img_data.ramdisk_size);
+		void *vendor_ramdisk_src = map_sysmem(img_data.vendor_ramdisk_ptr,
+						      img_data.vendor_ramdisk_size);
+		void *boot_ramdisk_src = map_sysmem(img_data.ramdisk_ptr,
+						    img_data.boot_ramdisk_size);
+
+		memcpy(ramdisk_dest, vendor_ramdisk_src,
 		       img_data.vendor_ramdisk_size);
-		ramdisk_ptr += img_data.vendor_ramdisk_size;
-		memcpy((void *)(ramdisk_ptr), (void *)img_data.ramdisk_ptr,
-		       img_data.boot_ramdisk_size);
-		ramdisk_ptr += img_data.boot_ramdisk_size;
+		memcpy((char *)ramdisk_dest + img_data.vendor_ramdisk_size,
+		       boot_ramdisk_src, img_data.boot_ramdisk_size);
+
 		if (img_data.bootconfig_size) {
-			memcpy((void *)
-			       (ramdisk_ptr), (void *)img_data.bootconfig_addr,
-			       img_data.bootconfig_size);
+			void *bootconfig_src = map_sysmem(img_data.bootconfig_addr,
+							  img_data.bootconfig_size);
+			memcpy((char *)ramdisk_dest + img_data.vendor_ramdisk_size +
+			       img_data.boot_ramdisk_size,
+			       bootconfig_src, img_data.bootconfig_size);
+			unmap_sysmem(bootconfig_src);
+
+			/* Add androidboot.* parameters to bootconfig */
+			if (androidboot_params && androidboot_params_len > 1) {
+				ulong bootconfig_ptr = (ulong)ramdisk_dest +
+						       img_data.vendor_ramdisk_size +
+						       img_data.boot_ramdisk_size;
+				img_data.ramdisk_size +=
+					add_bootconfig_parameters(androidboot_params,
+								  androidboot_params_len,
+								  bootconfig_ptr,
+								  img_data.bootconfig_size);
+			}
 		}
+
+		free(androidboot_params);
+		free(new_bootargs);
+
+		unmap_sysmem(boot_ramdisk_src);
+		unmap_sysmem(vendor_ramdisk_src);
+		unmap_sysmem(ramdisk_dest);
 	} else {
 		/* Ramdisk can be used in-place, use current ptr */
 		if (img_data.ramdisk_addr == 0 ||

-- 
2.34.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v2 4/5] cmd: abootimg: Add 'get ramdisk' command
  2025-10-17 13:19 [PATCH v2 0/5] android: add bootconfig support Guillaume La Roque (TI.com)
                   ` (2 preceding siblings ...)
  2025-10-17 13:19 ` [PATCH v2 3/5] boot: android: Add bootconfig support Guillaume La Roque (TI.com)
@ 2025-10-17 13:19 ` Guillaume La Roque (TI.com)
  2025-10-31 16:13   ` Mattijs Korpershoek
  2025-10-17 13:19 ` [PATCH v2 5/5] test: abootimg: Add test for bootconfig handling Guillaume La Roque (TI.com)
  2025-10-18  6:07 ` [PATCH v2 0/5] android: add bootconfig support george chan
  5 siblings, 1 reply; 23+ messages in thread
From: Guillaume La Roque (TI.com) @ 2025-10-17 13:19 UTC (permalink / raw)
  To: Tom Rini, Mattijs Korpershoek
  Cc: Julien Masson, Guillaume La Roque, u-boot, Simon Glass,
	Nicolas Belin, Neil Armstrong, Andrew Goodbody, Aaron Kling,
	George Chan, Sam Day, Jerome Forissier, Maxime Fournier

Add support for retrieving ramdisk address and size from Android boot
images. This command allows users to extract the ramdisk information
for boot image v3+ which combines vendor ramdisk, boot ramdisk and
bootconfig sections.

Signed-off-by: Guillaume La Roque (TI.com) <glaroque@baylibre.com>
---
 cmd/abootimg.c | 35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/cmd/abootimg.c b/cmd/abootimg.c
index 6fb52153786..2a8e2c20941 100644
--- a/cmd/abootimg.c
+++ b/cmd/abootimg.c
@@ -230,6 +230,33 @@ static int do_abootimg_addr(struct cmd_tbl *cmdtp, int flag, int argc,
 	return CMD_RET_SUCCESS;
 }
 
+static int abootimg_get_ramdisk(int argc, char *const argv[])
+{
+	ulong rd_data, rd_len;
+
+	if (argc > 2)
+		return CMD_RET_USAGE;
+
+	/*
+	 * Call android_image_get_ramdisk with UNMAPPED addresses
+	 * The function will do its own mapping internally as needed
+	 */
+	if (android_image_get_ramdisk((void *)abootimg_addr(),
+				      (void *)get_avendor_bootimg_addr(),
+				      &rd_data, &rd_len))
+		return CMD_RET_FAILURE;
+
+	if (argc == 0) {
+		printf("%lx\n", rd_data);
+	} else {
+		env_set_hex(argv[0], rd_data);
+		if (argc == 2)
+			env_set_hex(argv[1], rd_len);
+	}
+
+	return CMD_RET_SUCCESS;
+}
+
 static int do_abootimg_get(struct cmd_tbl *cmdtp, int flag, int argc,
 			   char *const argv[])
 {
@@ -249,6 +276,8 @@ static int do_abootimg_get(struct cmd_tbl *cmdtp, int flag, int argc,
 		return abootimg_get_dtb_load_addr(argc, argv);
 	else if (!strcmp(param, "dtb"))
 		return abootimg_get_dtb(argc, argv);
+	else if (!strcmp(param, "ramdisk"))
+		return abootimg_get_ramdisk(argc, argv);
 
 	return CMD_RET_USAGE;
 }
@@ -315,5 +344,9 @@ U_BOOT_CMD(
 	"    - get address and size (hex) of DT blob in the image by index\n"
 	"      <num>: index number of desired DT blob in DTB area\n"
 	"      [addr_var]: variable name to contain DT blob address\n"
-	"      [size_var]: variable name to contain DT blob size"
+	"      [size_var]: variable name to contain DT blob size\n"
+	"abootimg get ramdisk [addr_var [size_var]]\n"
+	"    - get address and size (hex) of ramdisk in the image\n"
+	"      [addr_var]: variable name to contain ramdisk address\n"
+	"      [size_var]: variable name to contain ramdisk size"
 );

-- 
2.34.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v2 5/5] test: abootimg: Add test for bootconfig handling
  2025-10-17 13:19 [PATCH v2 0/5] android: add bootconfig support Guillaume La Roque (TI.com)
                   ` (3 preceding siblings ...)
  2025-10-17 13:19 ` [PATCH v2 4/5] cmd: abootimg: Add 'get ramdisk' command Guillaume La Roque (TI.com)
@ 2025-10-17 13:19 ` Guillaume La Roque (TI.com)
  2025-10-19 13:06   ` Simon Glass
  2025-10-31 16:27   ` Mattijs Korpershoek
  2025-10-18  6:07 ` [PATCH v2 0/5] android: add bootconfig support george chan
  5 siblings, 2 replies; 23+ messages in thread
From: Guillaume La Roque (TI.com) @ 2025-10-17 13:19 UTC (permalink / raw)
  To: Tom Rini, Mattijs Korpershoek
  Cc: Julien Masson, Guillaume La Roque, u-boot, Simon Glass,
	Nicolas Belin, Neil Armstrong, Andrew Goodbody, Aaron Kling,
	George Chan, Sam Day, Jerome Forissier, Maxime Fournier

Add test to verify that androidboot.* parameters are correctly extracted
from bootargs and appended to the bootconfig section when using
'abootimg get ramdisk' with boot image v4 and vendor_boot image.

The test verifies:
- androidboot.* parameters are removed from bootargs
- They are appended to the bootconfig section in the ramdisk
- Non-androidboot parameters remain in bootargs
- The bootconfig trailer is properly updated

Signed-off-by: Guillaume La Roque (TI.com) <glaroque@baylibre.com>
---
 test/py/tests/test_android/test_abootimg.py | 108 +++++++++++++++++++++++++---
 1 file changed, 99 insertions(+), 9 deletions(-)

diff --git a/test/py/tests/test_android/test_abootimg.py b/test/py/tests/test_android/test_abootimg.py
index 2aadb692b30..bd5fb992a7d 100644
--- a/test/py/tests/test_android/test_abootimg.py
+++ b/test/py/tests/test_android/test_abootimg.py
@@ -69,15 +69,33 @@ e5bddc8a7b792d8e8788c896ce9b88d32ebe6c971e7ddd3543cae734cd01
 c0ffc84c0000b0766d1a87d4e5afeadd3dab7a6f10000000f84163d5d7cd
 d43a000000000000000060c53e7544995700400000"""
 
-# vendor boot image v4 hex dump
-vboot_img_hex = """1f8b0808baaecd63020376626f6f742e696d6700edd8310b824018c6f1b3
-222a08f41b3436b4280dcdd19c11d16ee9109d18d59042d047ec8b04cd0d
-d19d5a4345534bf6ffc173ef29272f38e93b1d0ec67dd79d548462aa1cd2
-d5d20b0000f8438678f90c18d584b8a4bbb3a557991ecb2a0000f80d6b2f
-f4179b656be5c532f2fc066f040000000080e23936af2755f62a3d918df1
-db2a7ab67f9ffdeb7df7cda3465ecb79c4ce7e5c577562bb9364b74449a5
-1e467e20c53c0a57de763193c1779b3b4fcd9d4ee27c6a0e00000000c0ff
-309ffea7010000000040f1dc004129855400400000"""
+# vendor boot image v4 hex dump (contains initial bootconfig: androidboot.hardware=test)
+vboot_img_hex = """1f8b08000000000002ffeddb316a02411806d009a49040606d3d84374823a9a348b095
+915951b2c9caee8690ce237a91406a0b497603e215dcbc577cf3334cf5350303b3787a
+9c4fa6d3e7dbf02b6b63dfc6b01b0180ffe726644d5e37975bb34108c76efa1eb65974
+c7fed691c600e02a64e7ab3e8494afe37bd128050000007ae6707ffad202000000f45b
+155fd3b67e59eee26751c674a711000000e89ff896aa729b5665d98c37b14a1fb1ca1f
+da4f7f5e02000000a0377e0040ab5ba000500000"""
+
+# bootable boot image v4 hex dump (contains actual bootable kernel)
+boot_bootable_img_hex = """1f8b08081663ee6802ff626f6f745f626f6f7461626c655f76342e696d67
+00edd1c14ac3401485e159b80a083ec24dba4f117c81d8140c6dad24ee25
+4da6e9d07452321305dfca37d4d4ec5cb954fe6f37ccb967606ef298e6db
+2c0d3f94526feae25adda81fae140000000000f8ab66e17c67ecdc1d025d
+1d3a89125bf79da9e5beebbc64a7b2d1f27a27cfda7959e9deea369a8263
+a0eaecde34e2c75b375495766e3fb46114cca430a7a12dbd96e3654a7663
+dfb9f4feeb383514beecbdb1cd1489e3380a5cabf5596ea7c4f78b62acf1
+a66ccdbbaea380950100000000f06b79b249b362f5f2b44e16cb87ed3a5d
+e67c0a0000000000ffcc27ba944c7e00300000"""
+
+# bootable vendor boot image v4 hex dump (contains actual bootable ramdisk)
+vendor_boot_bootable_img_hex = """1f8b08081663ee6802ff76656e646f725f626f6f745f626f6f7461626c65
+5f76342e696d6700edd8b10a02310cc6f10c0e7220f8080737b8b93ab9a8
+282e571171959e0d787058a84557f5c96ddd7d80c3ff0f92217c5396408e
+f56abf30e63090649c9b3c53bd050000fcab57d45b3c35de47db749a06bb
+e1eff08c7d0100d00bf6ea826f5dbef0d38b0dee618396f3f27bf69ddedb
+b316558a4d462255fe132c4dbdde6e0a160700000000408f7c0027597569
+00200000"""
 
 # Expected response for "abootimg dtb_dump" command
 dtb_dump_resp="""## DTB area contents (concat format):
@@ -179,6 +197,24 @@ def abootimgv4_disk_image_boot(ubman):
         gtdi3 = AbootimgTestDiskImage(ubman, 'bootv4.img', boot_img_hex)
     return gtdi3
 
+gtdi4 = None
+@pytest.fixture(scope='function')
+def abootimgv4_bootable_disk_image_boot(ubman):
+    """pytest fixture to provide bootable boot image v4."""
+    global gtdi4
+    if not gtdi4:
+        gtdi4 = AbootimgTestDiskImage(ubman, 'boot_bootable_v4.img', boot_bootable_img_hex)
+    return gtdi4
+
+gtdi5 = None
+@pytest.fixture(scope='function')
+def abootimgv4_bootable_disk_image_vboot(ubman):
+    """pytest fixture to provide bootable vendor boot image v4."""
+    global gtdi5
+    if not gtdi5:
+        gtdi5 = AbootimgTestDiskImage(ubman, 'vendor_boot_bootable_v4.img', vendor_boot_bootable_img_hex)
+    return gtdi5
+
 @pytest.mark.boardspec('sandbox')
 @pytest.mark.buildconfigspec('android_boot_image')
 @pytest.mark.buildconfigspec('cmd_abootimg')
@@ -266,3 +302,57 @@ def test_abootimgv4(abootimgv4_disk_image_vboot, abootimgv4_disk_image_boot, ubm
     ubman.run_command('fdt get value v / model')
     response = ubman.run_command('env print v')
     assert response == 'v=x2'
+
+@pytest.mark.boardspec('sandbox')
+@pytest.mark.buildconfigspec('android_boot_image')
+@pytest.mark.buildconfigspec('cmd_abootimg')
+@pytest.mark.requiredtool('xxd')
+@pytest.mark.requiredtool('gunzip')
+def test_abootimg_bootconfig(abootimgv4_disk_image_vboot,
+                              abootimgv4_disk_image_boot,
+                              ubman):
+    """Test bootconfig handling with boot image v4.
+
+    Verifies that androidboot.* parameters from bootargs are appended to the
+    bootconfig section in vendor_boot image in memory, and that non-androidboot
+    parameters remain in bootargs.
+    """
+
+    # Setup addresses
+    ram_base = utils.find_ram_base(ubman)
+    ramdisk_addr_r = ram_base + 0x4000000
+    ubman.run_command('setenv ramdisk_addr_r 0x%x' % ramdisk_addr_r)
+    ubman.run_command('setenv loadaddr 0x%x' % loadaddr)
+    ubman.run_command('setenv vloadaddr 0x%x' % vloadaddr)
+
+    # Set bootargs with androidboot.* parameters
+    ubman.run_command('setenv bootargs "androidboot.serialno=ABC123 androidboot.mode=recovery console=ttyS0"')
+
+    # Load images
+    ubman.run_command('host load hostfs - 0x%x %s' % (vloadaddr,
+        abootimgv4_disk_image_vboot.path))
+    ubman.run_command('host load hostfs - 0x%x %s' % (loadaddr,
+        abootimgv4_disk_image_boot.path))
+    ubman.run_command('abootimg addr 0x%x 0x%x' % (loadaddr, vloadaddr))
+
+    # Extract ramdisk (triggers bootconfig append)
+    ubman.run_command('abootimg get ramdisk ramdisk_addr ramdisk_size')
+
+    # Get ramdisk address
+    response = ubman.run_command('env print ramdisk_addr')
+    ramdisk_start = int(response.split('=')[1], 16)
+
+    # Verify androidboot.* parameters were removed from bootargs
+    response = ubman.run_command('env print bootargs')
+    assert 'androidboot.' not in response
+    assert 'console=ttyS0' in response
+
+    # Get ramdisk size and verify BOOTCONFIG magic at the end
+    response = ubman.run_command('env print ramdisk_size')
+    ramdisk_size = int(response.split('=')[1], 16)
+
+    # Dump the end of the ramdisk where BOOTCONFIG trailer should be
+    response = ubman.run_command('md.b 0x%x 96' % (ramdisk_start))
+
+    # Verify BOOTCONFIG magic is present
+    assert 'BOOTCONFIG' in response or 'BOOTCON' in response

-- 
2.34.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 0/5] android: add bootconfig support
  2025-10-17 13:19 [PATCH v2 0/5] android: add bootconfig support Guillaume La Roque (TI.com)
                   ` (4 preceding siblings ...)
  2025-10-17 13:19 ` [PATCH v2 5/5] test: abootimg: Add test for bootconfig handling Guillaume La Roque (TI.com)
@ 2025-10-18  6:07 ` george chan
  2025-10-20 13:58   ` Guillaume La Roque
  5 siblings, 1 reply; 23+ messages in thread
From: george chan @ 2025-10-18  6:07 UTC (permalink / raw)
  To: Guillaume La Roque (TI.com)
  Cc: Tom Rini, Mattijs Korpershoek, Julien Masson, u-boot, Simon Glass,
	Nicolas Belin, Neil Armstrong, Andrew Goodbody, Aaron Kling,
	Sam Day, Jerome Forissier, Maxime Fournier

Dear Guillaume,

Thx for your patch.

在 2025年10月17日週五 21:19,Guillaume La Roque (TI.com) <glaroque@baylibre.com>
寫道:

> This patchset add support of android bootconfig partition[1] in u-boot.
> With Android boot image v4, all androidboot.* arguments must be
> passed via bootconfig instead of using the kernel commandline.
>

it looks like the above add logic handled bootargs well.

is this logic support the use case of appending existing bootargs from env
and handle the one mentioned in
[1] for simulation of vendor bootloader behavior to append some
androidboot.* bootcmd to formulate a new bootargs? Or is this series
complementary to [1] so as aimed to "move" androidboot.* only to
bootconfig? If this [1] user case is covered then I am very happy to stop
[1] if this series can have same result.

Btw, I am wondering if this series assumed Androidboot v4 only, so kernel
ver must >= 5.4 and enabled with bootconfig. Since then bootconfig can be
unlimited to it's length. So all predefined androidboot.* from bootloader,
can now move out, and no need of default bootargs in env file any more.

And how about those Androidboot v2 case?

[1] https://lists.denx.de/pipermail/u-boot/2025-October/599708.html

Regards
George

>
> [1]
> https://source.android.com/docs/core/architecture/bootloader/implementing-bootconfig
>
> Signed-off-by: Guillaume La Roque (TI.com) <glaroque@baylibre.com>
> ---
> Changes in v2:
> - Add test
> - Add new command to be able to load and read bootconfig before booting
> - Somes fixes to works with sandbox test
> - Link to v1:
> https://lore.kernel.org/all/20241128-bootconfig-v1-0-0e63a5dae82c@baylibre.com/
>
> ---
> Guillaume La Roque (TI.com) (4):
>       boot: android: Add sandbox memory mapping support
>       boot: android: Add bootconfig support
>       cmd: abootimg: Add 'get ramdisk' command
>       test: abootimg: Add test for bootconfig handling
>
> Mattijs Korpershoek (TI.com) (1):
>       boot: android: import addBootConfigParameters() from AOSP
>
>  boot/image-android.c                        | 180
> ++++++++++++++++++++++++----
>  cmd/abootimg.c                              |  35 +++++-
>  test/py/tests/test_android/test_abootimg.py | 108 +++++++++++++++--
>  3 files changed, 292 insertions(+), 31 deletions(-)
> ---
> base-commit: 2ba64e303b2706e5c42a6bf982326d632342ca66
> change-id: 20241128-bootconfig-276e247be992
>
> Best regards,
> --
> Guillaume La Roque (TI.com) <glaroque@baylibre.com>
>
>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 5/5] test: abootimg: Add test for bootconfig handling
  2025-10-17 13:19 ` [PATCH v2 5/5] test: abootimg: Add test for bootconfig handling Guillaume La Roque (TI.com)
@ 2025-10-19 13:06   ` Simon Glass
  2025-10-19 16:01     ` Tom Rini
  2025-10-31 16:27   ` Mattijs Korpershoek
  1 sibling, 1 reply; 23+ messages in thread
From: Simon Glass @ 2025-10-19 13:06 UTC (permalink / raw)
  To: Guillaume La Roque (TI.com)
  Cc: Tom Rini, Mattijs Korpershoek, Julien Masson, u-boot,
	Nicolas Belin, Neil Armstrong, Andrew Goodbody, Aaron Kling,
	George Chan, Sam Day, Jerome Forissier, Maxime Fournier

Hi Guillaume,

On Fri, 17 Oct 2025 at 14:19, Guillaume La Roque (TI.com)
<glaroque@baylibre.com> wrote:
>
> Add test to verify that androidboot.* parameters are correctly extracted
> from bootargs and appended to the bootconfig section when using
> 'abootimg get ramdisk' with boot image v4 and vendor_boot image.
>
> The test verifies:
> - androidboot.* parameters are removed from bootargs
> - They are appended to the bootconfig section in the ramdisk
> - Non-androidboot parameters remain in bootargs
> - The bootconfig trailer is properly updated
>
> Signed-off-by: Guillaume La Roque (TI.com) <glaroque@baylibre.com>
> ---
>  test/py/tests/test_android/test_abootimg.py | 108 +++++++++++++++++++++++++---
>  1 file changed, 99 insertions(+), 9 deletions(-)
>
> diff --git a/test/py/tests/test_android/test_abootimg.py b/test/py/tests/test_android/test_abootimg.py
> index 2aadb692b30..bd5fb992a7d 100644
> --- a/test/py/tests/test_android/test_abootimg.py
> +++ b/test/py/tests/test_android/test_abootimg.py
> @@ -69,15 +69,33 @@ e5bddc8a7b792d8e8788c896ce9b88d32ebe6c971e7ddd3543cae734cd01
>  c0ffc84c0000b0766d1a87d4e5afeadd3dab7a6f10000000f84163d5d7cd
>  d43a000000000000000060c53e7544995700400000"""
>
> -# vendor boot image v4 hex dump
> -vboot_img_hex = """1f8b0808baaecd63020376626f6f742e696d6700edd8310b824018c6f1b3
> -222a08f41b3436b4280dcdd19c11d16ee9109d18d59042d047ec8b04cd0d
> -d19d5a4345534bf6ffc173ef29272f38e93b1d0ec67dd79d548462aa1cd2
> -d5d20b0000f8438678f90c18d584b8a4bbb3a557991ecb2a0000f80d6b2f
> -f4179b656be5c532f2fc066f040000000080e23936af2755f62a3d918df1
> -db2a7ab67f9ffdeb7df7cda3465ecb79c4ce7e5c577562bb9364b74449a5
> -1e467e20c53c0a57de763193c1779b3b4fcd9d4ee27c6a0e00000000c0ff
> -309ffea7010000000040f1dc004129855400400000"""
> +# vendor boot image v4 hex dump (contains initial bootconfig: androidboot.hardware=test)
> +vboot_img_hex = """1f8b08000000000002ffeddb316a02411806d009a49040606d3d84374823a9a348b095
> +915951b2c9caee8690ce237a91406a0b497603e215dcbc577cf3334cf5350303b3787a
> +9c4fa6d3e7dbf02b6b63dfc6b01b0180ffe726644d5e37975bb34108c76efa1eb65974
> +c7fed691c600e02a64e7ab3e8494afe37bd128050000007ae6707ffad202000000f45b
> +155fd3b67e59eee26751c674a711000000e89ff896aa729b5665d98c37b14a1fb1ca1f
> +da4f7f5e02000000a0377e0040ab5ba000500000"""
> +
> +# bootable boot image v4 hex dump (contains actual bootable kernel)
> +boot_bootable_img_hex = """1f8b08081663ee6802ff626f6f745f626f6f7461626c655f76342e696d67
> +00edd1c14ac3401485e159b80a083ec24dba4f117c81d8140c6dad24ee25
> +4da6e9d07452321305dfca37d4d4ec5cb954fe6f37ccb967606ef298e6db
> +2c0d3f94526feae25adda81fae140000000000f8ab66e17c67ecdc1d025d
> +1d3a89125bf79da9e5beebbc64a7b2d1f27a27cfda7959e9deea369a8263
> +a0eaecde34e2c75b375495766e3fb46114cca430a7a12dbd96e3654a7663
> +dfb9f4feeb383514beecbdb1cd1489e3380a5cabf5596ea7c4f78b62acf1
> +a66ccdbbaea380950100000000f06b79b249b362f5f2b44e16cb87ed3a5d
> +e67c0a0000000000ffcc27ba944c7e00300000"""
> +
> +# bootable vendor boot image v4 hex dump (contains actual bootable ramdisk)
> +vendor_boot_bootable_img_hex = """1f8b08081663ee6802ff76656e646f725f626f6f745f626f6f7461626c65
> +5f76342e696d6700edd8b10a02310cc6f10c0e7220f8080737b8b93ab9a8
> +282e571171959e0d787058a84557f5c96ddd7d80c3ff0f92217c5396408e
> +f56abf30e63090649c9b3c53bd050000fcab57d45b3c35de47db749a06bb
> +e1eff08c7d0100d00bf6ea826f5dbef0d38b0dee618396f3f27bf69ddedb
> +b316558a4d462255fe132c4dbdde6e0a160700000000408f7c0027597569
> +00200000"""
>
>  # Expected response for "abootimg dtb_dump" command
>  dtb_dump_resp="""## DTB area contents (concat format):
> @@ -179,6 +197,24 @@ def abootimgv4_disk_image_boot(ubman):
>          gtdi3 = AbootimgTestDiskImage(ubman, 'bootv4.img', boot_img_hex)
>      return gtdi3
>
> +gtdi4 = None
> +@pytest.fixture(scope='function')
> +def abootimgv4_bootable_disk_image_boot(ubman):
> +    """pytest fixture to provide bootable boot image v4."""
> +    global gtdi4
> +    if not gtdi4:
> +        gtdi4 = AbootimgTestDiskImage(ubman, 'boot_bootable_v4.img', boot_bootable_img_hex)
> +    return gtdi4
> +
> +gtdi5 = None
> +@pytest.fixture(scope='function')
> +def abootimgv4_bootable_disk_image_vboot(ubman):
> +    """pytest fixture to provide bootable vendor boot image v4."""
> +    global gtdi5
> +    if not gtdi5:
> +        gtdi5 = AbootimgTestDiskImage(ubman, 'vendor_boot_bootable_v4.img', vendor_boot_bootable_img_hex)
> +    return gtdi5
> +
>  @pytest.mark.boardspec('sandbox')
>  @pytest.mark.buildconfigspec('android_boot_image')
>  @pytest.mark.buildconfigspec('cmd_abootimg')
> @@ -266,3 +302,57 @@ def test_abootimgv4(abootimgv4_disk_image_vboot, abootimgv4_disk_image_boot, ubm
>      ubman.run_command('fdt get value v / model')
>      response = ubman.run_command('env print v')
>      assert response == 'v=x2'
> +
> +@pytest.mark.boardspec('sandbox')
> +@pytest.mark.buildconfigspec('android_boot_image')
> +@pytest.mark.buildconfigspec('cmd_abootimg')
> +@pytest.mark.requiredtool('xxd')
> +@pytest.mark.requiredtool('gunzip')
> +def test_abootimg_bootconfig(abootimgv4_disk_image_vboot,
> +                              abootimgv4_disk_image_boot,
> +                              ubman):
> +    """Test bootconfig handling with boot image v4.
> +
> +    Verifies that androidboot.* parameters from bootargs are appended to the
> +    bootconfig section in vendor_boot image in memory, and that non-androidboot
> +    parameters remain in bootargs.
> +    """
> +
> +    # Setup addresses
> +    ram_base = utils.find_ram_base(ubman)
> +    ramdisk_addr_r = ram_base + 0x4000000
> +    ubman.run_command('setenv ramdisk_addr_r 0x%x' % ramdisk_addr_r)
> +    ubman.run_command('setenv loadaddr 0x%x' % loadaddr)
> +    ubman.run_command('setenv vloadaddr 0x%x' % vloadaddr)
> +
> +    # Set bootargs with androidboot.* parameters
> +    ubman.run_command('setenv bootargs "androidboot.serialno=ABC123 androidboot.mode=recovery console=ttyS0"')
> +
> +    # Load images
> +    ubman.run_command('host load hostfs - 0x%x %s' % (vloadaddr,
> +        abootimgv4_disk_image_vboot.path))
> +    ubman.run_command('host load hostfs - 0x%x %s' % (loadaddr,
> +        abootimgv4_disk_image_boot.path))
> +    ubman.run_command('abootimg addr 0x%x 0x%x' % (loadaddr, vloadaddr))
> +
> +    # Extract ramdisk (triggers bootconfig append)
> +    ubman.run_command('abootimg get ramdisk ramdisk_addr ramdisk_size')
> +
> +    # Get ramdisk address
> +    response = ubman.run_command('env print ramdisk_addr')
> +    ramdisk_start = int(response.split('=')[1], 16)
> +
> +    # Verify androidboot.* parameters were removed from bootargs
> +    response = ubman.run_command('env print bootargs')
> +    assert 'androidboot.' not in response
> +    assert 'console=ttyS0' in response
> +
> +    # Get ramdisk size and verify BOOTCONFIG magic at the end
> +    response = ubman.run_command('env print ramdisk_size')
> +    ramdisk_size = int(response.split('=')[1], 16)
> +
> +    # Dump the end of the ramdisk where BOOTCONFIG trailer should be
> +    response = ubman.run_command('md.b 0x%x 96' % (ramdisk_start))
> +
> +    # Verify BOOTCONFIG magic is present
> +    assert 'BOOTCONFIG' in response or 'BOOTCON' in response
>

It looks like this test could be written in C?

Regards,
Simon

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 5/5] test: abootimg: Add test for bootconfig handling
  2025-10-19 13:06   ` Simon Glass
@ 2025-10-19 16:01     ` Tom Rini
  2025-10-20  5:18       ` Simon Glass
  0 siblings, 1 reply; 23+ messages in thread
From: Tom Rini @ 2025-10-19 16:01 UTC (permalink / raw)
  To: Simon Glass
  Cc: Guillaume La Roque (TI.com), Mattijs Korpershoek, Julien Masson,
	u-boot, Nicolas Belin, Neil Armstrong, Andrew Goodbody,
	Aaron Kling, George Chan, Sam Day, Jerome Forissier,
	Maxime Fournier

[-- Attachment #1: Type: text/plain, Size: 8036 bytes --]

On Sun, Oct 19, 2025 at 02:06:05PM +0100, Simon Glass wrote:
> Hi Guillaume,
> 
> On Fri, 17 Oct 2025 at 14:19, Guillaume La Roque (TI.com)
> <glaroque@baylibre.com> wrote:
> >
> > Add test to verify that androidboot.* parameters are correctly extracted
> > from bootargs and appended to the bootconfig section when using
> > 'abootimg get ramdisk' with boot image v4 and vendor_boot image.
> >
> > The test verifies:
> > - androidboot.* parameters are removed from bootargs
> > - They are appended to the bootconfig section in the ramdisk
> > - Non-androidboot parameters remain in bootargs
> > - The bootconfig trailer is properly updated
> >
> > Signed-off-by: Guillaume La Roque (TI.com) <glaroque@baylibre.com>
> > ---
> >  test/py/tests/test_android/test_abootimg.py | 108 +++++++++++++++++++++++++---
> >  1 file changed, 99 insertions(+), 9 deletions(-)
> >
> > diff --git a/test/py/tests/test_android/test_abootimg.py b/test/py/tests/test_android/test_abootimg.py
> > index 2aadb692b30..bd5fb992a7d 100644
> > --- a/test/py/tests/test_android/test_abootimg.py
> > +++ b/test/py/tests/test_android/test_abootimg.py
> > @@ -69,15 +69,33 @@ e5bddc8a7b792d8e8788c896ce9b88d32ebe6c971e7ddd3543cae734cd01
> >  c0ffc84c0000b0766d1a87d4e5afeadd3dab7a6f10000000f84163d5d7cd
> >  d43a000000000000000060c53e7544995700400000"""
> >
> > -# vendor boot image v4 hex dump
> > -vboot_img_hex = """1f8b0808baaecd63020376626f6f742e696d6700edd8310b824018c6f1b3
> > -222a08f41b3436b4280dcdd19c11d16ee9109d18d59042d047ec8b04cd0d
> > -d19d5a4345534bf6ffc173ef29272f38e93b1d0ec67dd79d548462aa1cd2
> > -d5d20b0000f8438678f90c18d584b8a4bbb3a557991ecb2a0000f80d6b2f
> > -f4179b656be5c532f2fc066f040000000080e23936af2755f62a3d918df1
> > -db2a7ab67f9ffdeb7df7cda3465ecb79c4ce7e5c577562bb9364b74449a5
> > -1e467e20c53c0a57de763193c1779b3b4fcd9d4ee27c6a0e00000000c0ff
> > -309ffea7010000000040f1dc004129855400400000"""
> > +# vendor boot image v4 hex dump (contains initial bootconfig: androidboot.hardware=test)
> > +vboot_img_hex = """1f8b08000000000002ffeddb316a02411806d009a49040606d3d84374823a9a348b095
> > +915951b2c9caee8690ce237a91406a0b497603e215dcbc577cf3334cf5350303b3787a
> > +9c4fa6d3e7dbf02b6b63dfc6b01b0180ffe726644d5e37975bb34108c76efa1eb65974
> > +c7fed691c600e02a64e7ab3e8494afe37bd128050000007ae6707ffad202000000f45b
> > +155fd3b67e59eee26751c674a711000000e89ff896aa729b5665d98c37b14a1fb1ca1f
> > +da4f7f5e02000000a0377e0040ab5ba000500000"""
> > +
> > +# bootable boot image v4 hex dump (contains actual bootable kernel)
> > +boot_bootable_img_hex = """1f8b08081663ee6802ff626f6f745f626f6f7461626c655f76342e696d67
> > +00edd1c14ac3401485e159b80a083ec24dba4f117c81d8140c6dad24ee25
> > +4da6e9d07452321305dfca37d4d4ec5cb954fe6f37ccb967606ef298e6db
> > +2c0d3f94526feae25adda81fae140000000000f8ab66e17c67ecdc1d025d
> > +1d3a89125bf79da9e5beebbc64a7b2d1f27a27cfda7959e9deea369a8263
> > +a0eaecde34e2c75b375495766e3fb46114cca430a7a12dbd96e3654a7663
> > +dfb9f4feeb383514beecbdb1cd1489e3380a5cabf5596ea7c4f78b62acf1
> > +a66ccdbbaea380950100000000f06b79b249b362f5f2b44e16cb87ed3a5d
> > +e67c0a0000000000ffcc27ba944c7e00300000"""
> > +
> > +# bootable vendor boot image v4 hex dump (contains actual bootable ramdisk)
> > +vendor_boot_bootable_img_hex = """1f8b08081663ee6802ff76656e646f725f626f6f745f626f6f7461626c65
> > +5f76342e696d6700edd8b10a02310cc6f10c0e7220f8080737b8b93ab9a8
> > +282e571171959e0d787058a84557f5c96ddd7d80c3ff0f92217c5396408e
> > +f56abf30e63090649c9b3c53bd050000fcab57d45b3c35de47db749a06bb
> > +e1eff08c7d0100d00bf6ea826f5dbef0d38b0dee618396f3f27bf69ddedb
> > +b316558a4d462255fe132c4dbdde6e0a160700000000408f7c0027597569
> > +00200000"""
> >
> >  # Expected response for "abootimg dtb_dump" command
> >  dtb_dump_resp="""## DTB area contents (concat format):
> > @@ -179,6 +197,24 @@ def abootimgv4_disk_image_boot(ubman):
> >          gtdi3 = AbootimgTestDiskImage(ubman, 'bootv4.img', boot_img_hex)
> >      return gtdi3
> >
> > +gtdi4 = None
> > +@pytest.fixture(scope='function')
> > +def abootimgv4_bootable_disk_image_boot(ubman):
> > +    """pytest fixture to provide bootable boot image v4."""
> > +    global gtdi4
> > +    if not gtdi4:
> > +        gtdi4 = AbootimgTestDiskImage(ubman, 'boot_bootable_v4.img', boot_bootable_img_hex)
> > +    return gtdi4
> > +
> > +gtdi5 = None
> > +@pytest.fixture(scope='function')
> > +def abootimgv4_bootable_disk_image_vboot(ubman):
> > +    """pytest fixture to provide bootable vendor boot image v4."""
> > +    global gtdi5
> > +    if not gtdi5:
> > +        gtdi5 = AbootimgTestDiskImage(ubman, 'vendor_boot_bootable_v4.img', vendor_boot_bootable_img_hex)
> > +    return gtdi5
> > +
> >  @pytest.mark.boardspec('sandbox')
> >  @pytest.mark.buildconfigspec('android_boot_image')
> >  @pytest.mark.buildconfigspec('cmd_abootimg')
> > @@ -266,3 +302,57 @@ def test_abootimgv4(abootimgv4_disk_image_vboot, abootimgv4_disk_image_boot, ubm
> >      ubman.run_command('fdt get value v / model')
> >      response = ubman.run_command('env print v')
> >      assert response == 'v=x2'
> > +
> > +@pytest.mark.boardspec('sandbox')
> > +@pytest.mark.buildconfigspec('android_boot_image')
> > +@pytest.mark.buildconfigspec('cmd_abootimg')
> > +@pytest.mark.requiredtool('xxd')
> > +@pytest.mark.requiredtool('gunzip')
> > +def test_abootimg_bootconfig(abootimgv4_disk_image_vboot,
> > +                              abootimgv4_disk_image_boot,
> > +                              ubman):
> > +    """Test bootconfig handling with boot image v4.
> > +
> > +    Verifies that androidboot.* parameters from bootargs are appended to the
> > +    bootconfig section in vendor_boot image in memory, and that non-androidboot
> > +    parameters remain in bootargs.
> > +    """
> > +
> > +    # Setup addresses
> > +    ram_base = utils.find_ram_base(ubman)
> > +    ramdisk_addr_r = ram_base + 0x4000000
> > +    ubman.run_command('setenv ramdisk_addr_r 0x%x' % ramdisk_addr_r)
> > +    ubman.run_command('setenv loadaddr 0x%x' % loadaddr)
> > +    ubman.run_command('setenv vloadaddr 0x%x' % vloadaddr)
> > +
> > +    # Set bootargs with androidboot.* parameters
> > +    ubman.run_command('setenv bootargs "androidboot.serialno=ABC123 androidboot.mode=recovery console=ttyS0"')
> > +
> > +    # Load images
> > +    ubman.run_command('host load hostfs - 0x%x %s' % (vloadaddr,
> > +        abootimgv4_disk_image_vboot.path))
> > +    ubman.run_command('host load hostfs - 0x%x %s' % (loadaddr,
> > +        abootimgv4_disk_image_boot.path))
> > +    ubman.run_command('abootimg addr 0x%x 0x%x' % (loadaddr, vloadaddr))
> > +
> > +    # Extract ramdisk (triggers bootconfig append)
> > +    ubman.run_command('abootimg get ramdisk ramdisk_addr ramdisk_size')
> > +
> > +    # Get ramdisk address
> > +    response = ubman.run_command('env print ramdisk_addr')
> > +    ramdisk_start = int(response.split('=')[1], 16)
> > +
> > +    # Verify androidboot.* parameters were removed from bootargs
> > +    response = ubman.run_command('env print bootargs')
> > +    assert 'androidboot.' not in response
> > +    assert 'console=ttyS0' in response
> > +
> > +    # Get ramdisk size and verify BOOTCONFIG magic at the end
> > +    response = ubman.run_command('env print ramdisk_size')
> > +    ramdisk_size = int(response.split('=')[1], 16)
> > +
> > +    # Dump the end of the ramdisk where BOOTCONFIG trailer should be
> > +    response = ubman.run_command('md.b 0x%x 96' % (ramdisk_start))
> > +
> > +    # Verify BOOTCONFIG magic is present
> > +    assert 'BOOTCONFIG' in response or 'BOOTCON' in response
> >
> 
> It looks like this test could be written in C?

But this is just extending existing tests, and so this is fine. Looking
at
https://source.denx.de/u-boot/u-boot/-/pipelines/27943/test_report?job_name=sandbox%20test.py%3A%20%5Bamd64%5D
we can see these tests are currently under 400ms each, FYI.

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 5/5] test: abootimg: Add test for bootconfig handling
  2025-10-19 16:01     ` Tom Rini
@ 2025-10-20  5:18       ` Simon Glass
  2025-10-24 15:09         ` Guillaume La Roque
  0 siblings, 1 reply; 23+ messages in thread
From: Simon Glass @ 2025-10-20  5:18 UTC (permalink / raw)
  To: Tom Rini
  Cc: Guillaume La Roque (TI.com), Mattijs Korpershoek, Julien Masson,
	u-boot, Nicolas Belin, Neil Armstrong, Andrew Goodbody,
	Aaron Kling, George Chan, Sam Day, Jerome Forissier,
	Maxime Fournier

Hi,

On Sun, 19 Oct 2025 at 17:01, Tom Rini <trini@konsulko.com> wrote:
>
> On Sun, Oct 19, 2025 at 02:06:05PM +0100, Simon Glass wrote:
> > Hi Guillaume,
> >
> > On Fri, 17 Oct 2025 at 14:19, Guillaume La Roque (TI.com)
> > <glaroque@baylibre.com> wrote:
> > >
> > > Add test to verify that androidboot.* parameters are correctly extracted
> > > from bootargs and appended to the bootconfig section when using
> > > 'abootimg get ramdisk' with boot image v4 and vendor_boot image.
> > >
> > > The test verifies:
> > > - androidboot.* parameters are removed from bootargs
> > > - They are appended to the bootconfig section in the ramdisk
> > > - Non-androidboot parameters remain in bootargs
> > > - The bootconfig trailer is properly updated
> > >
> > > Signed-off-by: Guillaume La Roque (TI.com) <glaroque@baylibre.com>
> > > ---
> > >  test/py/tests/test_android/test_abootimg.py | 108 +++++++++++++++++++++++++---
> > >  1 file changed, 99 insertions(+), 9 deletions(-)
> > >
> > > diff --git a/test/py/tests/test_android/test_abootimg.py b/test/py/tests/test_android/test_abootimg.py
> > > index 2aadb692b30..bd5fb992a7d 100644
> > > --- a/test/py/tests/test_android/test_abootimg.py
> > > +++ b/test/py/tests/test_android/test_abootimg.py
> > > @@ -69,15 +69,33 @@ e5bddc8a7b792d8e8788c896ce9b88d32ebe6c971e7ddd3543cae734cd01
> > >  c0ffc84c0000b0766d1a87d4e5afeadd3dab7a6f10000000f84163d5d7cd
> > >  d43a000000000000000060c53e7544995700400000"""
> > >
> > > -# vendor boot image v4 hex dump
> > > -vboot_img_hex = """1f8b0808baaecd63020376626f6f742e696d6700edd8310b824018c6f1b3
> > > -222a08f41b3436b4280dcdd19c11d16ee9109d18d59042d047ec8b04cd0d
> > > -d19d5a4345534bf6ffc173ef29272f38e93b1d0ec67dd79d548462aa1cd2
> > > -d5d20b0000f8438678f90c18d584b8a4bbb3a557991ecb2a0000f80d6b2f
> > > -f4179b656be5c532f2fc066f040000000080e23936af2755f62a3d918df1
> > > -db2a7ab67f9ffdeb7df7cda3465ecb79c4ce7e5c577562bb9364b74449a5
> > > -1e467e20c53c0a57de763193c1779b3b4fcd9d4ee27c6a0e00000000c0ff
> > > -309ffea7010000000040f1dc004129855400400000"""
> > > +# vendor boot image v4 hex dump (contains initial bootconfig: androidboot.hardware=test)
> > > +vboot_img_hex = """1f8b08000000000002ffeddb316a02411806d009a49040606d3d84374823a9a348b095
> > > +915951b2c9caee8690ce237a91406a0b497603e215dcbc577cf3334cf5350303b3787a
> > > +9c4fa6d3e7dbf02b6b63dfc6b01b0180ffe726644d5e37975bb34108c76efa1eb65974
> > > +c7fed691c600e02a64e7ab3e8494afe37bd128050000007ae6707ffad202000000f45b
> > > +155fd3b67e59eee26751c674a711000000e89ff896aa729b5665d98c37b14a1fb1ca1f
> > > +da4f7f5e02000000a0377e0040ab5ba000500000"""
> > > +
> > > +# bootable boot image v4 hex dump (contains actual bootable kernel)
> > > +boot_bootable_img_hex = """1f8b08081663ee6802ff626f6f745f626f6f7461626c655f76342e696d67
> > > +00edd1c14ac3401485e159b80a083ec24dba4f117c81d8140c6dad24ee25
> > > +4da6e9d07452321305dfca37d4d4ec5cb954fe6f37ccb967606ef298e6db
> > > +2c0d3f94526feae25adda81fae140000000000f8ab66e17c67ecdc1d025d
> > > +1d3a89125bf79da9e5beebbc64a7b2d1f27a27cfda7959e9deea369a8263
> > > +a0eaecde34e2c75b375495766e3fb46114cca430a7a12dbd96e3654a7663
> > > +dfb9f4feeb383514beecbdb1cd1489e3380a5cabf5596ea7c4f78b62acf1
> > > +a66ccdbbaea380950100000000f06b79b249b362f5f2b44e16cb87ed3a5d
> > > +e67c0a0000000000ffcc27ba944c7e00300000"""
> > > +
> > > +# bootable vendor boot image v4 hex dump (contains actual bootable ramdisk)
> > > +vendor_boot_bootable_img_hex = """1f8b08081663ee6802ff76656e646f725f626f6f745f626f6f7461626c65
> > > +5f76342e696d6700edd8b10a02310cc6f10c0e7220f8080737b8b93ab9a8
> > > +282e571171959e0d787058a84557f5c96ddd7d80c3ff0f92217c5396408e
> > > +f56abf30e63090649c9b3c53bd050000fcab57d45b3c35de47db749a06bb
> > > +e1eff08c7d0100d00bf6ea826f5dbef0d38b0dee618396f3f27bf69ddedb
> > > +b316558a4d462255fe132c4dbdde6e0a160700000000408f7c0027597569
> > > +00200000"""
> > >
> > >  # Expected response for "abootimg dtb_dump" command
> > >  dtb_dump_resp="""## DTB area contents (concat format):
> > > @@ -179,6 +197,24 @@ def abootimgv4_disk_image_boot(ubman):
> > >          gtdi3 = AbootimgTestDiskImage(ubman, 'bootv4.img', boot_img_hex)
> > >      return gtdi3
> > >
> > > +gtdi4 = None
> > > +@pytest.fixture(scope='function')
> > > +def abootimgv4_bootable_disk_image_boot(ubman):
> > > +    """pytest fixture to provide bootable boot image v4."""
> > > +    global gtdi4
> > > +    if not gtdi4:
> > > +        gtdi4 = AbootimgTestDiskImage(ubman, 'boot_bootable_v4.img', boot_bootable_img_hex)
> > > +    return gtdi4
> > > +
> > > +gtdi5 = None
> > > +@pytest.fixture(scope='function')
> > > +def abootimgv4_bootable_disk_image_vboot(ubman):
> > > +    """pytest fixture to provide bootable vendor boot image v4."""
> > > +    global gtdi5
> > > +    if not gtdi5:
> > > +        gtdi5 = AbootimgTestDiskImage(ubman, 'vendor_boot_bootable_v4.img', vendor_boot_bootable_img_hex)
> > > +    return gtdi5
> > > +
> > >  @pytest.mark.boardspec('sandbox')
> > >  @pytest.mark.buildconfigspec('android_boot_image')
> > >  @pytest.mark.buildconfigspec('cmd_abootimg')
> > > @@ -266,3 +302,57 @@ def test_abootimgv4(abootimgv4_disk_image_vboot, abootimgv4_disk_image_boot, ubm
> > >      ubman.run_command('fdt get value v / model')
> > >      response = ubman.run_command('env print v')
> > >      assert response == 'v=x2'
> > > +
> > > +@pytest.mark.boardspec('sandbox')
> > > +@pytest.mark.buildconfigspec('android_boot_image')
> > > +@pytest.mark.buildconfigspec('cmd_abootimg')
> > > +@pytest.mark.requiredtool('xxd')
> > > +@pytest.mark.requiredtool('gunzip')
> > > +def test_abootimg_bootconfig(abootimgv4_disk_image_vboot,
> > > +                              abootimgv4_disk_image_boot,
> > > +                              ubman):
> > > +    """Test bootconfig handling with boot image v4.
> > > +
> > > +    Verifies that androidboot.* parameters from bootargs are appended to the
> > > +    bootconfig section in vendor_boot image in memory, and that non-androidboot
> > > +    parameters remain in bootargs.
> > > +    """
> > > +
> > > +    # Setup addresses
> > > +    ram_base = utils.find_ram_base(ubman)
> > > +    ramdisk_addr_r = ram_base + 0x4000000
> > > +    ubman.run_command('setenv ramdisk_addr_r 0x%x' % ramdisk_addr_r)
> > > +    ubman.run_command('setenv loadaddr 0x%x' % loadaddr)
> > > +    ubman.run_command('setenv vloadaddr 0x%x' % vloadaddr)
> > > +
> > > +    # Set bootargs with androidboot.* parameters
> > > +    ubman.run_command('setenv bootargs "androidboot.serialno=ABC123 androidboot.mode=recovery console=ttyS0"')
> > > +
> > > +    # Load images
> > > +    ubman.run_command('host load hostfs - 0x%x %s' % (vloadaddr,
> > > +        abootimgv4_disk_image_vboot.path))
> > > +    ubman.run_command('host load hostfs - 0x%x %s' % (loadaddr,
> > > +        abootimgv4_disk_image_boot.path))
> > > +    ubman.run_command('abootimg addr 0x%x 0x%x' % (loadaddr, vloadaddr))
> > > +
> > > +    # Extract ramdisk (triggers bootconfig append)
> > > +    ubman.run_command('abootimg get ramdisk ramdisk_addr ramdisk_size')
> > > +
> > > +    # Get ramdisk address
> > > +    response = ubman.run_command('env print ramdisk_addr')
> > > +    ramdisk_start = int(response.split('=')[1], 16)
> > > +
> > > +    # Verify androidboot.* parameters were removed from bootargs
> > > +    response = ubman.run_command('env print bootargs')
> > > +    assert 'androidboot.' not in response
> > > +    assert 'console=ttyS0' in response
> > > +
> > > +    # Get ramdisk size and verify BOOTCONFIG magic at the end
> > > +    response = ubman.run_command('env print ramdisk_size')
> > > +    ramdisk_size = int(response.split('=')[1], 16)
> > > +
> > > +    # Dump the end of the ramdisk where BOOTCONFIG trailer should be
> > > +    response = ubman.run_command('md.b 0x%x 96' % (ramdisk_start))
> > > +
> > > +    # Verify BOOTCONFIG magic is present
> > > +    assert 'BOOTCONFIG' in response or 'BOOTCON' in response
> > >
> >
> > It looks like this test could be written in C?
>
> But this is just extending existing tests, and so this is fine. Looking
> at
> https://source.denx.de/u-boot/u-boot/-/pipelines/27943/test_report?job_name=sandbox%20test.py%3A%20%5Bamd64%5D
> we can see these tests are currently under 400ms each, FYI.

Yes, OK. The python tests are ~100x slower though, so we really should
use C where possible. Part of this is being hidden by the overhead of
individually running the C tests from Python. I suppose we could
improve that by running the tests in batches, but I haven't looked at
it.

Reviewed-by: Simon Glass <sjg@chromium.org>

Regards,
Simon

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 0/5] android: add bootconfig support
  2025-10-18  6:07 ` [PATCH v2 0/5] android: add bootconfig support george chan
@ 2025-10-20 13:58   ` Guillaume La Roque
  2025-10-20 15:45     ` george chan
  0 siblings, 1 reply; 23+ messages in thread
From: Guillaume La Roque @ 2025-10-20 13:58 UTC (permalink / raw)
  To: george chan
  Cc: Tom Rini, Mattijs Korpershoek, Julien Masson, u-boot, Simon Glass,
	Nicolas Belin, Neil Armstrong, Andrew Goodbody, Aaron Kling,
	Sam Day, Jerome Forissier, Maxime Fournier

Hi George,


Le 18/10/2025 à 08:07, george chan a écrit :
> Dear Guillaume,
>
> Thx for your patch.
>
> 在 2025年10月17日週五 21:19,Guillaume La Roque (TI.com) 
> <glaroque@baylibre.com> 寫道:
>
>     This patchset add support of android bootconfig partition[1] in
>     u-boot.
>     With Android boot image v4, all androidboot.* arguments must be
>     passed via bootconfig instead of using the kernel commandline.
>
>
> it looks like the above add logic handled bootargs well.
>
> is this logic support the use case of appending existing bootargs from 
> env and handle the one mentioned in
> [1] for simulation of vendor bootloader behavior to append some 
> androidboot.* bootcmd to formulate a new bootargs? Or is this series 
> complementary to [1] so as aimed to "move" androidboot.* only to 
> bootconfig? If this [1] user case is covered then I am very happy to 
> stop [1] if this series can have same result.
>
> Btw, I am wondering if this series assumed Androidboot v4 only, so 
> kernel ver must >= 5.4 and enabled with bootconfig. Since then 
> bootconfig can be unlimited to it's length. So all predefined 
> androidboot.* from bootloader, can now move out, and no need of 
> default bootargs in env file any more.
>
> And how about those Androidboot v2 case?
>
> [1] https://lists.denx.de/pipermail/u-boot/2025-October/599708.html

in TI project we have this patch 
https://git.ti.com/cgit/ti-u-boot/ti-u-boot/commit/?h=ti-u-boot-2024.04-next&id=9d802d798ac143e06ffe545606aa657a6c32cc63 
, we forgot to upstream it but i'll plan to do it if it's not a problem 
for you. let me know if it's ok for you and i send it this week. Normaly 
this patch resolve your issue, it's not mandatory for bootconfig support 
but needed to not lost all other bootargs no link to android in bootargs 
when you use bootmeth_android.


Except if i do some error in code, boot config code was only do when you 
have android image version 4, code take all androidboot.* param in 
bootarg, remove it in booatarg and put it in bootconfig partition before 
booting android.

some arg was adding in bootargs in bootargs automatically(serial, avb 
arg, slot etc etc) so instead of check where it's done version of 
android boot image we have  we prefer to do it just before booting.

for fastboot boot i never test it with TI board.

Guillaume

>
> Regards
> George
>
>
>     [1]
>     https://source.android.com/docs/core/architecture/bootloader/implementing-bootconfig
>
>     Signed-off-by: Guillaume La Roque (TI.com) <glaroque@baylibre.com>
>     ---
>     Changes in v2:
>     - Add test
>     - Add new command to be able to load and read bootconfig before
>     booting
>     - Somes fixes to works with sandbox test
>     - Link to v1:
>     https://lore.kernel.org/all/20241128-bootconfig-v1-0-0e63a5dae82c@baylibre.com/
>
>     ---
>     Guillaume La Roque (TI.com) (4):
>           boot: android: Add sandbox memory mapping support
>           boot: android: Add bootconfig support
>           cmd: abootimg: Add 'get ramdisk' command
>           test: abootimg: Add test for bootconfig handling
>
>     Mattijs Korpershoek (TI.com) (1):
>           boot: android: import addBootConfigParameters() from AOSP
>
>      boot/image-android.c                        | 180
>     ++++++++++++++++++++++++----
>      cmd/abootimg.c                              |  35 +++++-
>      test/py/tests/test_android/test_abootimg.py | 108 +++++++++++++++--
>      3 files changed, 292 insertions(+), 31 deletions(-)
>     ---
>     base-commit: 2ba64e303b2706e5c42a6bf982326d632342ca66
>     change-id: 20241128-bootconfig-276e247be992
>
>     Best regards,
>     -- 
>     Guillaume La Roque (TI.com) <glaroque@baylibre.com>
>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 0/5] android: add bootconfig support
  2025-10-20 13:58   ` Guillaume La Roque
@ 2025-10-20 15:45     ` george chan
  0 siblings, 0 replies; 23+ messages in thread
From: george chan @ 2025-10-20 15:45 UTC (permalink / raw)
  To: Guillaume La Roque
  Cc: Tom Rini, Mattijs Korpershoek, Julien Masson, u-boot, Simon Glass,
	Nicolas Belin, Neil Armstrong, Andrew Goodbody, Aaron Kling,
	Sam Day, Jerome Forissier, Maxime Fournier

Dear Guillaume,


在 2025年10月20日週一 21:58,Guillaume La Roque <glaroque@baylibre.com> 寫道:

> Hi George,
>
>
> Le 18/10/2025 à 08:07, george chan a écrit :
>
> Dear Guillaume,
>
> Thx for your patch.
>
> 在 2025年10月17日週五 21:19,Guillaume La Roque (TI.com) <glaroque@baylibre.com>
> 寫道:
>
>> This patchset add support of android bootconfig partition[1] in u-boot.
>> With Android boot image v4, all androidboot.* arguments must be
>> passed via bootconfig instead of using the kernel commandline.
>>
>
> it looks like the above add logic handled bootargs well.
>
> is this logic support the use case of appending existing bootargs from env
> and handle the one mentioned in
> [1] for simulation of vendor bootloader behavior to append some
> androidboot.* bootcmd to formulate a new bootargs? Or is this series
> complementary to [1] so as aimed to "move" androidboot.* only to
> bootconfig? If this [1] user case is covered then I am very happy to stop
> [1] if this series can have same result.
>
> Btw, I am wondering if this series assumed Androidboot v4 only, so kernel
> ver must >= 5.4 and enabled with bootconfig. Since then bootconfig can be
> unlimited to it's length. So all predefined androidboot.* from bootloader,
> can now move out, and no need of default bootargs in env file any more.
>
> And how about those Androidboot v2 case?
>
> [1] https://lists.denx.de/pipermail/u-boot/2025-October/599708.html
>
> in TI project we have this patch
> https://git.ti.com/cgit/ti-u-boot/ti-u-boot/commit/?h=ti-u-boot-2024.04-next&id=9d802d798ac143e06ffe545606aa657a6c32cc63
> , we forgot to upstream it but i'll plan to do it if it's not a problem for
> you. let me know if it's ok for you and i send it this week. Normaly this
> patch resolve your issue, it's not mandatory for bootconfig support but
> needed to not lost all other bootargs no link to android in bootargs when
> you use bootmeth_android.
>
thanks to confirm. even through i dont have any idea of your internal repo,
I believe you will handle this issue well. I feel some resistance on
working with my proposed patch for months so, and better let go now and
stop it here.

>
> Except if i do some error in code, boot config code was only do when you
> have android image version 4, code take all androidboot.* param in bootarg,
> remove it in booatarg and put it in bootconfig partition before booting
> android.
>

Sure. and i interested to know what appened when bootflow select and later
with printenv, and how the bootargs looks like. if you are going to do
submit next round, would you mind showing this result as well?

> some arg was adding in bootargs in bootargs automatically(serial, avb arg,
> slot etc etc) so instead of check where it's done version of android boot
> image we have  we prefer to do it just before booting.
>
> for fastboot boot i never test it with TI board.
>
Ok then lets wait for some other dev to fix it then.

Thanks again for follow this up.

Regards,
George

>
> Guillaume
>
>
> Regards
> George
>
>>
>> [1]
>> https://source.android.com/docs/core/architecture/bootloader/implementing-bootconfig
>>
>> Signed-off-by: Guillaume La Roque (TI.com) <glaroque@baylibre.com>
>> ---
>> Changes in v2:
>> - Add test
>> - Add new command to be able to load and read bootconfig before booting
>> - Somes fixes to works with sandbox test
>> - Link to v1:
>> https://lore.kernel.org/all/20241128-bootconfig-v1-0-0e63a5dae82c@baylibre.com/
>>
>> ---
>> Guillaume La Roque (TI.com) (4):
>>       boot: android: Add sandbox memory mapping support
>>       boot: android: Add bootconfig support
>>       cmd: abootimg: Add 'get ramdisk' command
>>       test: abootimg: Add test for bootconfig handling
>>
>> Mattijs Korpershoek (TI.com) (1):
>>       boot: android: import addBootConfigParameters() from AOSP
>>
>>  boot/image-android.c                        | 180
>> ++++++++++++++++++++++++----
>>  cmd/abootimg.c                              |  35 +++++-
>>  test/py/tests/test_android/test_abootimg.py | 108 +++++++++++++++--
>>  3 files changed, 292 insertions(+), 31 deletions(-)
>> ---
>> base-commit: 2ba64e303b2706e5c42a6bf982326d632342ca66
>> change-id: 20241128-bootconfig-276e247be992
>>
>> Best regards,
>> --
>> Guillaume La Roque (TI.com) <glaroque@baylibre.com>
>>
>>
>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 5/5] test: abootimg: Add test for bootconfig handling
  2025-10-20  5:18       ` Simon Glass
@ 2025-10-24 15:09         ` Guillaume La Roque
  2025-10-24 15:20           ` Tom Rini
  0 siblings, 1 reply; 23+ messages in thread
From: Guillaume La Roque @ 2025-10-24 15:09 UTC (permalink / raw)
  To: Simon Glass, Tom Rini
  Cc: Mattijs Korpershoek, Julien Masson, u-boot, Nicolas Belin,
	Neil Armstrong, Andrew Goodbody, Aaron Kling, George Chan,
	Sam Day, Jerome Forissier, Maxime Fournier

Le 20/10/2025 à 07:18, Simon Glass a écrit :
> Hi,
>
> On Sun, 19 Oct 2025 at 17:01, Tom Rini <trini@konsulko.com> wrote:
>> On Sun, Oct 19, 2025 at 02:06:05PM +0100, Simon Glass wrote:
>>> Hi Guillaume,
>>>
>>> On Fri, 17 Oct 2025 at 14:19, Guillaume La Roque (TI.com)
>>> <glaroque@baylibre.com> wrote:
>>>> Add test to verify that androidboot.* parameters are correctly extracted
>>>> from bootargs and appended to the bootconfig section when using
>>>> 'abootimg get ramdisk' with boot image v4 and vendor_boot image.
>>>>
>>>> The test verifies:
>>>> - androidboot.* parameters are removed from bootargs
>>>> - They are appended to the bootconfig section in the ramdisk
>>>> - Non-androidboot parameters remain in bootargs
>>>> - The bootconfig trailer is properly updated
>>>>
>>>> Signed-off-by: Guillaume La Roque (TI.com) <glaroque@baylibre.com>
>>>> ---
>>>>   test/py/tests/test_android/test_abootimg.py | 108 +++++++++++++++++++++++++---
>>>>   1 file changed, 99 insertions(+), 9 deletions(-)
>>>>
>>>> diff --git a/test/py/tests/test_android/test_abootimg.py b/test/py/tests/test_android/test_abootimg.py
>>>> index 2aadb692b30..bd5fb992a7d 100644
>>>> --- a/test/py/tests/test_android/test_abootimg.py
>>>> +++ b/test/py/tests/test_android/test_abootimg.py
>>>> @@ -69,15 +69,33 @@ e5bddc8a7b792d8e8788c896ce9b88d32ebe6c971e7ddd3543cae734cd01
>>>>   c0ffc84c0000b0766d1a87d4e5afeadd3dab7a6f10000000f84163d5d7cd
>>>>   d43a000000000000000060c53e7544995700400000"""
>>>>
>>>> -# vendor boot image v4 hex dump
>>>> -vboot_img_hex = """1f8b0808baaecd63020376626f6f742e696d6700edd8310b824018c6f1b3
>>>> -222a08f41b3436b4280dcdd19c11d16ee9109d18d59042d047ec8b04cd0d
>>>> -d19d5a4345534bf6ffc173ef29272f38e93b1d0ec67dd79d548462aa1cd2
>>>> -d5d20b0000f8438678f90c18d584b8a4bbb3a557991ecb2a0000f80d6b2f
>>>> -f4179b656be5c532f2fc066f040000000080e23936af2755f62a3d918df1
>>>> -db2a7ab67f9ffdeb7df7cda3465ecb79c4ce7e5c577562bb9364b74449a5
>>>> -1e467e20c53c0a57de763193c1779b3b4fcd9d4ee27c6a0e00000000c0ff
>>>> -309ffea7010000000040f1dc004129855400400000"""
>>>> +# vendor boot image v4 hex dump (contains initial bootconfig: androidboot.hardware=test)
>>>> +vboot_img_hex = """1f8b08000000000002ffeddb316a02411806d009a49040606d3d84374823a9a348b095
>>>> +915951b2c9caee8690ce237a91406a0b497603e215dcbc577cf3334cf5350303b3787a
>>>> +9c4fa6d3e7dbf02b6b63dfc6b01b0180ffe726644d5e37975bb34108c76efa1eb65974
>>>> +c7fed691c600e02a64e7ab3e8494afe37bd128050000007ae6707ffad202000000f45b
>>>> +155fd3b67e59eee26751c674a711000000e89ff896aa729b5665d98c37b14a1fb1ca1f
>>>> +da4f7f5e02000000a0377e0040ab5ba000500000"""
>>>> +
>>>> +# bootable boot image v4 hex dump (contains actual bootable kernel)
>>>> +boot_bootable_img_hex = """1f8b08081663ee6802ff626f6f745f626f6f7461626c655f76342e696d67
>>>> +00edd1c14ac3401485e159b80a083ec24dba4f117c81d8140c6dad24ee25
>>>> +4da6e9d07452321305dfca37d4d4ec5cb954fe6f37ccb967606ef298e6db
>>>> +2c0d3f94526feae25adda81fae140000000000f8ab66e17c67ecdc1d025d
>>>> +1d3a89125bf79da9e5beebbc64a7b2d1f27a27cfda7959e9deea369a8263
>>>> +a0eaecde34e2c75b375495766e3fb46114cca430a7a12dbd96e3654a7663
>>>> +dfb9f4feeb383514beecbdb1cd1489e3380a5cabf5596ea7c4f78b62acf1
>>>> +a66ccdbbaea380950100000000f06b79b249b362f5f2b44e16cb87ed3a5d
>>>> +e67c0a0000000000ffcc27ba944c7e00300000"""
>>>> +
>>>> +# bootable vendor boot image v4 hex dump (contains actual bootable ramdisk)
>>>> +vendor_boot_bootable_img_hex = """1f8b08081663ee6802ff76656e646f725f626f6f745f626f6f7461626c65
>>>> +5f76342e696d6700edd8b10a02310cc6f10c0e7220f8080737b8b93ab9a8
>>>> +282e571171959e0d787058a84557f5c96ddd7d80c3ff0f92217c5396408e
>>>> +f56abf30e63090649c9b3c53bd050000fcab57d45b3c35de47db749a06bb
>>>> +e1eff08c7d0100d00bf6ea826f5dbef0d38b0dee618396f3f27bf69ddedb
>>>> +b316558a4d462255fe132c4dbdde6e0a160700000000408f7c0027597569
>>>> +00200000"""
>>>>
>>>>   # Expected response for "abootimg dtb_dump" command
>>>>   dtb_dump_resp="""## DTB area contents (concat format):
>>>> @@ -179,6 +197,24 @@ def abootimgv4_disk_image_boot(ubman):
>>>>           gtdi3 = AbootimgTestDiskImage(ubman, 'bootv4.img', boot_img_hex)
>>>>       return gtdi3
>>>>
>>>> +gtdi4 = None
>>>> +@pytest.fixture(scope='function')
>>>> +def abootimgv4_bootable_disk_image_boot(ubman):
>>>> +    """pytest fixture to provide bootable boot image v4."""
>>>> +    global gtdi4
>>>> +    if not gtdi4:
>>>> +        gtdi4 = AbootimgTestDiskImage(ubman, 'boot_bootable_v4.img', boot_bootable_img_hex)
>>>> +    return gtdi4
>>>> +
>>>> +gtdi5 = None
>>>> +@pytest.fixture(scope='function')
>>>> +def abootimgv4_bootable_disk_image_vboot(ubman):
>>>> +    """pytest fixture to provide bootable vendor boot image v4."""
>>>> +    global gtdi5
>>>> +    if not gtdi5:
>>>> +        gtdi5 = AbootimgTestDiskImage(ubman, 'vendor_boot_bootable_v4.img', vendor_boot_bootable_img_hex)
>>>> +    return gtdi5
>>>> +
>>>>   @pytest.mark.boardspec('sandbox')
>>>>   @pytest.mark.buildconfigspec('android_boot_image')
>>>>   @pytest.mark.buildconfigspec('cmd_abootimg')
>>>> @@ -266,3 +302,57 @@ def test_abootimgv4(abootimgv4_disk_image_vboot, abootimgv4_disk_image_boot, ubm
>>>>       ubman.run_command('fdt get value v / model')
>>>>       response = ubman.run_command('env print v')
>>>>       assert response == 'v=x2'
>>>> +
>>>> +@pytest.mark.boardspec('sandbox')
>>>> +@pytest.mark.buildconfigspec('android_boot_image')
>>>> +@pytest.mark.buildconfigspec('cmd_abootimg')
>>>> +@pytest.mark.requiredtool('xxd')
>>>> +@pytest.mark.requiredtool('gunzip')
>>>> +def test_abootimg_bootconfig(abootimgv4_disk_image_vboot,
>>>> +                              abootimgv4_disk_image_boot,
>>>> +                              ubman):
>>>> +    """Test bootconfig handling with boot image v4.
>>>> +
>>>> +    Verifies that androidboot.* parameters from bootargs are appended to the
>>>> +    bootconfig section in vendor_boot image in memory, and that non-androidboot
>>>> +    parameters remain in bootargs.
>>>> +    """
>>>> +
>>>> +    # Setup addresses
>>>> +    ram_base = utils.find_ram_base(ubman)
>>>> +    ramdisk_addr_r = ram_base + 0x4000000
>>>> +    ubman.run_command('setenv ramdisk_addr_r 0x%x' % ramdisk_addr_r)
>>>> +    ubman.run_command('setenv loadaddr 0x%x' % loadaddr)
>>>> +    ubman.run_command('setenv vloadaddr 0x%x' % vloadaddr)
>>>> +
>>>> +    # Set bootargs with androidboot.* parameters
>>>> +    ubman.run_command('setenv bootargs "androidboot.serialno=ABC123 androidboot.mode=recovery console=ttyS0"')
>>>> +
>>>> +    # Load images
>>>> +    ubman.run_command('host load hostfs - 0x%x %s' % (vloadaddr,
>>>> +        abootimgv4_disk_image_vboot.path))
>>>> +    ubman.run_command('host load hostfs - 0x%x %s' % (loadaddr,
>>>> +        abootimgv4_disk_image_boot.path))
>>>> +    ubman.run_command('abootimg addr 0x%x 0x%x' % (loadaddr, vloadaddr))
>>>> +
>>>> +    # Extract ramdisk (triggers bootconfig append)
>>>> +    ubman.run_command('abootimg get ramdisk ramdisk_addr ramdisk_size')
>>>> +
>>>> +    # Get ramdisk address
>>>> +    response = ubman.run_command('env print ramdisk_addr')
>>>> +    ramdisk_start = int(response.split('=')[1], 16)
>>>> +
>>>> +    # Verify androidboot.* parameters were removed from bootargs
>>>> +    response = ubman.run_command('env print bootargs')
>>>> +    assert 'androidboot.' not in response
>>>> +    assert 'console=ttyS0' in response
>>>> +
>>>> +    # Get ramdisk size and verify BOOTCONFIG magic at the end
>>>> +    response = ubman.run_command('env print ramdisk_size')
>>>> +    ramdisk_size = int(response.split('=')[1], 16)
>>>> +
>>>> +    # Dump the end of the ramdisk where BOOTCONFIG trailer should be
>>>> +    response = ubman.run_command('md.b 0x%x 96' % (ramdisk_start))
>>>> +
>>>> +    # Verify BOOTCONFIG magic is present
>>>> +    assert 'BOOTCONFIG' in response or 'BOOTCON' in response
>>>>
>>> It looks like this test could be written in C?
>> But this is just extending existing tests, and so this is fine. Looking
>> at
>> https://source.denx.de/u-boot/u-boot/-/pipelines/27943/test_report?job_name=sandbox%20test.py%3A%20%5Bamd64%5D
>> we can see these tests are currently under 400ms each, FYI.
> Yes, OK. The python tests are ~100x slower though, so we really should
> use C where possible. Part of this is being hidden by the overhead of
> individually running the C tests from Python. I suppose we could
> improve that by running the tests in batches, but I haven't looked at
> it.
>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Hi simon,

I will plan to migrate all tests link to android in C after this series.


Guillaume
>
> Regards,
> Simon



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 5/5] test: abootimg: Add test for bootconfig handling
  2025-10-24 15:09         ` Guillaume La Roque
@ 2025-10-24 15:20           ` Tom Rini
  0 siblings, 0 replies; 23+ messages in thread
From: Tom Rini @ 2025-10-24 15:20 UTC (permalink / raw)
  To: Guillaume La Roque
  Cc: Simon Glass, Mattijs Korpershoek, Julien Masson, u-boot,
	Nicolas Belin, Neil Armstrong, Andrew Goodbody, Aaron Kling,
	George Chan, Sam Day, Jerome Forissier, Maxime Fournier

[-- Attachment #1: Type: text/plain, Size: 9992 bytes --]

On Fri, Oct 24, 2025 at 05:09:07PM +0200, Guillaume La Roque wrote:
> Le 20/10/2025 à 07:18, Simon Glass a écrit :
> > Hi,
> > 
> > On Sun, 19 Oct 2025 at 17:01, Tom Rini <trini@konsulko.com> wrote:
> > > On Sun, Oct 19, 2025 at 02:06:05PM +0100, Simon Glass wrote:
> > > > Hi Guillaume,
> > > > 
> > > > On Fri, 17 Oct 2025 at 14:19, Guillaume La Roque (TI.com)
> > > > <glaroque@baylibre.com> wrote:
> > > > > Add test to verify that androidboot.* parameters are correctly extracted
> > > > > from bootargs and appended to the bootconfig section when using
> > > > > 'abootimg get ramdisk' with boot image v4 and vendor_boot image.
> > > > > 
> > > > > The test verifies:
> > > > > - androidboot.* parameters are removed from bootargs
> > > > > - They are appended to the bootconfig section in the ramdisk
> > > > > - Non-androidboot parameters remain in bootargs
> > > > > - The bootconfig trailer is properly updated
> > > > > 
> > > > > Signed-off-by: Guillaume La Roque (TI.com) <glaroque@baylibre.com>
> > > > > ---
> > > > >   test/py/tests/test_android/test_abootimg.py | 108 +++++++++++++++++++++++++---
> > > > >   1 file changed, 99 insertions(+), 9 deletions(-)
> > > > > 
> > > > > diff --git a/test/py/tests/test_android/test_abootimg.py b/test/py/tests/test_android/test_abootimg.py
> > > > > index 2aadb692b30..bd5fb992a7d 100644
> > > > > --- a/test/py/tests/test_android/test_abootimg.py
> > > > > +++ b/test/py/tests/test_android/test_abootimg.py
> > > > > @@ -69,15 +69,33 @@ e5bddc8a7b792d8e8788c896ce9b88d32ebe6c971e7ddd3543cae734cd01
> > > > >   c0ffc84c0000b0766d1a87d4e5afeadd3dab7a6f10000000f84163d5d7cd
> > > > >   d43a000000000000000060c53e7544995700400000"""
> > > > > 
> > > > > -# vendor boot image v4 hex dump
> > > > > -vboot_img_hex = """1f8b0808baaecd63020376626f6f742e696d6700edd8310b824018c6f1b3
> > > > > -222a08f41b3436b4280dcdd19c11d16ee9109d18d59042d047ec8b04cd0d
> > > > > -d19d5a4345534bf6ffc173ef29272f38e93b1d0ec67dd79d548462aa1cd2
> > > > > -d5d20b0000f8438678f90c18d584b8a4bbb3a557991ecb2a0000f80d6b2f
> > > > > -f4179b656be5c532f2fc066f040000000080e23936af2755f62a3d918df1
> > > > > -db2a7ab67f9ffdeb7df7cda3465ecb79c4ce7e5c577562bb9364b74449a5
> > > > > -1e467e20c53c0a57de763193c1779b3b4fcd9d4ee27c6a0e00000000c0ff
> > > > > -309ffea7010000000040f1dc004129855400400000"""
> > > > > +# vendor boot image v4 hex dump (contains initial bootconfig: androidboot.hardware=test)
> > > > > +vboot_img_hex = """1f8b08000000000002ffeddb316a02411806d009a49040606d3d84374823a9a348b095
> > > > > +915951b2c9caee8690ce237a91406a0b497603e215dcbc577cf3334cf5350303b3787a
> > > > > +9c4fa6d3e7dbf02b6b63dfc6b01b0180ffe726644d5e37975bb34108c76efa1eb65974
> > > > > +c7fed691c600e02a64e7ab3e8494afe37bd128050000007ae6707ffad202000000f45b
> > > > > +155fd3b67e59eee26751c674a711000000e89ff896aa729b5665d98c37b14a1fb1ca1f
> > > > > +da4f7f5e02000000a0377e0040ab5ba000500000"""
> > > > > +
> > > > > +# bootable boot image v4 hex dump (contains actual bootable kernel)
> > > > > +boot_bootable_img_hex = """1f8b08081663ee6802ff626f6f745f626f6f7461626c655f76342e696d67
> > > > > +00edd1c14ac3401485e159b80a083ec24dba4f117c81d8140c6dad24ee25
> > > > > +4da6e9d07452321305dfca37d4d4ec5cb954fe6f37ccb967606ef298e6db
> > > > > +2c0d3f94526feae25adda81fae140000000000f8ab66e17c67ecdc1d025d
> > > > > +1d3a89125bf79da9e5beebbc64a7b2d1f27a27cfda7959e9deea369a8263
> > > > > +a0eaecde34e2c75b375495766e3fb46114cca430a7a12dbd96e3654a7663
> > > > > +dfb9f4feeb383514beecbdb1cd1489e3380a5cabf5596ea7c4f78b62acf1
> > > > > +a66ccdbbaea380950100000000f06b79b249b362f5f2b44e16cb87ed3a5d
> > > > > +e67c0a0000000000ffcc27ba944c7e00300000"""
> > > > > +
> > > > > +# bootable vendor boot image v4 hex dump (contains actual bootable ramdisk)
> > > > > +vendor_boot_bootable_img_hex = """1f8b08081663ee6802ff76656e646f725f626f6f745f626f6f7461626c65
> > > > > +5f76342e696d6700edd8b10a02310cc6f10c0e7220f8080737b8b93ab9a8
> > > > > +282e571171959e0d787058a84557f5c96ddd7d80c3ff0f92217c5396408e
> > > > > +f56abf30e63090649c9b3c53bd050000fcab57d45b3c35de47db749a06bb
> > > > > +e1eff08c7d0100d00bf6ea826f5dbef0d38b0dee618396f3f27bf69ddedb
> > > > > +b316558a4d462255fe132c4dbdde6e0a160700000000408f7c0027597569
> > > > > +00200000"""
> > > > > 
> > > > >   # Expected response for "abootimg dtb_dump" command
> > > > >   dtb_dump_resp="""## DTB area contents (concat format):
> > > > > @@ -179,6 +197,24 @@ def abootimgv4_disk_image_boot(ubman):
> > > > >           gtdi3 = AbootimgTestDiskImage(ubman, 'bootv4.img', boot_img_hex)
> > > > >       return gtdi3
> > > > > 
> > > > > +gtdi4 = None
> > > > > +@pytest.fixture(scope='function')
> > > > > +def abootimgv4_bootable_disk_image_boot(ubman):
> > > > > +    """pytest fixture to provide bootable boot image v4."""
> > > > > +    global gtdi4
> > > > > +    if not gtdi4:
> > > > > +        gtdi4 = AbootimgTestDiskImage(ubman, 'boot_bootable_v4.img', boot_bootable_img_hex)
> > > > > +    return gtdi4
> > > > > +
> > > > > +gtdi5 = None
> > > > > +@pytest.fixture(scope='function')
> > > > > +def abootimgv4_bootable_disk_image_vboot(ubman):
> > > > > +    """pytest fixture to provide bootable vendor boot image v4."""
> > > > > +    global gtdi5
> > > > > +    if not gtdi5:
> > > > > +        gtdi5 = AbootimgTestDiskImage(ubman, 'vendor_boot_bootable_v4.img', vendor_boot_bootable_img_hex)
> > > > > +    return gtdi5
> > > > > +
> > > > >   @pytest.mark.boardspec('sandbox')
> > > > >   @pytest.mark.buildconfigspec('android_boot_image')
> > > > >   @pytest.mark.buildconfigspec('cmd_abootimg')
> > > > > @@ -266,3 +302,57 @@ def test_abootimgv4(abootimgv4_disk_image_vboot, abootimgv4_disk_image_boot, ubm
> > > > >       ubman.run_command('fdt get value v / model')
> > > > >       response = ubman.run_command('env print v')
> > > > >       assert response == 'v=x2'
> > > > > +
> > > > > +@pytest.mark.boardspec('sandbox')
> > > > > +@pytest.mark.buildconfigspec('android_boot_image')
> > > > > +@pytest.mark.buildconfigspec('cmd_abootimg')
> > > > > +@pytest.mark.requiredtool('xxd')
> > > > > +@pytest.mark.requiredtool('gunzip')
> > > > > +def test_abootimg_bootconfig(abootimgv4_disk_image_vboot,
> > > > > +                              abootimgv4_disk_image_boot,
> > > > > +                              ubman):
> > > > > +    """Test bootconfig handling with boot image v4.
> > > > > +
> > > > > +    Verifies that androidboot.* parameters from bootargs are appended to the
> > > > > +    bootconfig section in vendor_boot image in memory, and that non-androidboot
> > > > > +    parameters remain in bootargs.
> > > > > +    """
> > > > > +
> > > > > +    # Setup addresses
> > > > > +    ram_base = utils.find_ram_base(ubman)
> > > > > +    ramdisk_addr_r = ram_base + 0x4000000
> > > > > +    ubman.run_command('setenv ramdisk_addr_r 0x%x' % ramdisk_addr_r)
> > > > > +    ubman.run_command('setenv loadaddr 0x%x' % loadaddr)
> > > > > +    ubman.run_command('setenv vloadaddr 0x%x' % vloadaddr)
> > > > > +
> > > > > +    # Set bootargs with androidboot.* parameters
> > > > > +    ubman.run_command('setenv bootargs "androidboot.serialno=ABC123 androidboot.mode=recovery console=ttyS0"')
> > > > > +
> > > > > +    # Load images
> > > > > +    ubman.run_command('host load hostfs - 0x%x %s' % (vloadaddr,
> > > > > +        abootimgv4_disk_image_vboot.path))
> > > > > +    ubman.run_command('host load hostfs - 0x%x %s' % (loadaddr,
> > > > > +        abootimgv4_disk_image_boot.path))
> > > > > +    ubman.run_command('abootimg addr 0x%x 0x%x' % (loadaddr, vloadaddr))
> > > > > +
> > > > > +    # Extract ramdisk (triggers bootconfig append)
> > > > > +    ubman.run_command('abootimg get ramdisk ramdisk_addr ramdisk_size')
> > > > > +
> > > > > +    # Get ramdisk address
> > > > > +    response = ubman.run_command('env print ramdisk_addr')
> > > > > +    ramdisk_start = int(response.split('=')[1], 16)
> > > > > +
> > > > > +    # Verify androidboot.* parameters were removed from bootargs
> > > > > +    response = ubman.run_command('env print bootargs')
> > > > > +    assert 'androidboot.' not in response
> > > > > +    assert 'console=ttyS0' in response
> > > > > +
> > > > > +    # Get ramdisk size and verify BOOTCONFIG magic at the end
> > > > > +    response = ubman.run_command('env print ramdisk_size')
> > > > > +    ramdisk_size = int(response.split('=')[1], 16)
> > > > > +
> > > > > +    # Dump the end of the ramdisk where BOOTCONFIG trailer should be
> > > > > +    response = ubman.run_command('md.b 0x%x 96' % (ramdisk_start))
> > > > > +
> > > > > +    # Verify BOOTCONFIG magic is present
> > > > > +    assert 'BOOTCONFIG' in response or 'BOOTCON' in response
> > > > > 
> > > > It looks like this test could be written in C?
> > > But this is just extending existing tests, and so this is fine. Looking
> > > at
> > > https://source.denx.de/u-boot/u-boot/-/pipelines/27943/test_report?job_name=sandbox%20test.py%3A%20%5Bamd64%5D
> > > we can see these tests are currently under 400ms each, FYI.
> > Yes, OK. The python tests are ~100x slower though, so we really should
> > use C where possible. Part of this is being hidden by the overhead of
> > individually running the C tests from Python. I suppose we could
> > improve that by running the tests in batches, but I haven't looked at
> > it.
> > 
> > Reviewed-by: Simon Glass <sjg@chromium.org>
> 
> Hi simon,
> 
> I will plan to migrate all tests link to android in C after this series.

As we've been talking recently in other threads, running tests reliably
outside of the python framework itself is also difficult to have be
reliable. Please don't worry about converting these tests as a priority.
I pointed out the time they take currently as a reminder that even if
they're "100x slower" it's very much a micro-optimization.

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 1/5] boot: android: import addBootConfigParameters() from AOSP
  2025-10-17 13:19 ` [PATCH v2 1/5] boot: android: import addBootConfigParameters() from AOSP Guillaume La Roque (TI.com)
@ 2025-10-31 15:39   ` Mattijs Korpershoek
  0 siblings, 0 replies; 23+ messages in thread
From: Mattijs Korpershoek @ 2025-10-31 15:39 UTC (permalink / raw)
  To: Guillaume La Roque (TI.com), Tom Rini, Mattijs Korpershoek
  Cc: Julien Masson, Guillaume La Roque, u-boot, Simon Glass,
	Nicolas Belin, Neil Armstrong, Andrew Goodbody, Aaron Kling,
	George Chan, Sam Day, Jerome Forissier, Maxime Fournier

Hi Guillaume,

Thank you for the patch.

On Fri, Oct 17, 2025 at 15:19, "Guillaume La Roque (TI.com)" <glaroque@baylibre.com> wrote:

> From: "Mattijs Korpershoek (TI.com)" <mkorpershoek@kernel.org>
>
> To properly implement Android boot image v4, U-Boot must be able to
> add additional entries to the bootconfig.
>
> Add `add_bootconfig_parameters()` to do so.
>
> This has been imported from Google's U-Boot source[1]
> The variables/function names have been reworked to be
> compliant with U-Boot's coding style.
>
> [1] https://android.googlesource.com/platform/external/u-boot/+/7af0a0506d4de6f5ea147d10fb0664a8af07d326
> Signed-off-by: Mattijs Korpershoek (TI.com) <mkorpershoek@kernel.org>
> Signed-off-by: Guillaume La Roque (TI.com) <glaroque@baylibre.com>

Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>

> ---
>  boot/image-android.c | 38 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 38 insertions(+)
>
> diff --git a/boot/image-android.c b/boot/image-android.c
> index e46dee0d9b3..3a0a934acc7 100644
> --- a/boot/image-android.c
> +++ b/boot/image-android.c
> @@ -57,6 +57,44 @@ static ulong add_trailer(ulong bootconfig_start_addr, ulong bootconfig_size)
>  	return BOOTCONFIG_TRAILER_SIZE;
>  }
>  
> +/*
> + * Add a string of boot config parameters to memory appended by the trailer.
> + * NOTE: This function expects bootconfig_start_addr to be already mapped.
> + *       It works directly with the mapped pointer, not a physical address.
> + */
> +u32 add_bootconfig_parameters(char *params, ulong params_size,
> +			      ulong bootconfig_start_addr, u32 bootconfig_size)
> +{
> +	if (!params || !bootconfig_start_addr)
> +		return -1;
> +
> +	if (params_size == 0)
> +		return 0;
> +
> +	u32 applied_bytes = 0;
> +	u32 new_size = 0;
> +	ulong end = bootconfig_start_addr + bootconfig_size;
> +
> +	if (is_trailer_present(end)) {
> +		end -= BOOTCONFIG_TRAILER_SIZE;
> +		applied_bytes -= BOOTCONFIG_TRAILER_SIZE;
> +		memcpy(&new_size, (void *)end, BOOTCONFIG_SIZE_SIZE);
> +	} else {
> +		/*
> +		 * When no trailer is present, the bootconfig_size includes the actual content.
> +		 * We should write new parameters right after the existing content.
> +		 */
> +		end = bootconfig_start_addr + bootconfig_size;
> +		new_size = bootconfig_size;
> +	}
> +
> +	memcpy((void *)end, params, params_size);
> +	applied_bytes += params_size;
> +	applied_bytes += add_trailer(bootconfig_start_addr,
> +				     bootconfig_size + applied_bytes);
> +	return applied_bytes;
> +}
> +
>  __weak ulong get_avendor_bootimg_addr(void)
>  {
>  	return -1;
>
> -- 
> 2.34.1

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 2/5] boot: android: Add sandbox memory mapping support
  2025-10-17 13:19 ` [PATCH v2 2/5] boot: android: Add sandbox memory mapping support Guillaume La Roque (TI.com)
@ 2025-10-31 15:49   ` Mattijs Korpershoek
  0 siblings, 0 replies; 23+ messages in thread
From: Mattijs Korpershoek @ 2025-10-31 15:49 UTC (permalink / raw)
  To: Guillaume La Roque (TI.com), Tom Rini, Mattijs Korpershoek
  Cc: Julien Masson, Guillaume La Roque, u-boot, Simon Glass,
	Nicolas Belin, Neil Armstrong, Andrew Goodbody, Aaron Kling,
	George Chan, Sam Day, Jerome Forissier, Maxime Fournier

Hi Guillaume,

Thank you for the patch.

On Fri, Oct 17, 2025 at 15:19, "Guillaume La Roque (TI.com)" <glaroque@baylibre.com> wrote:

> Use map_to_sysmem() to convert header pointers to physical addresses
> in parse_hdr functions, and add proper map_sysmem()/unmap_sysmem()
> calls in android_image_get_data() for sandbox compatibility.
>
> Signed-off-by: Guillaume La Roque (TI.com) <glaroque@baylibre.com>

Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>

> ---
>  boot/image-android.c | 41 ++++++++++++++++++++++++++++-------------
>  1 file changed, 28 insertions(+), 13 deletions(-)
>
> -- 
> 2.34.1

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 3/5] boot: android: Add bootconfig support
  2025-10-17 13:19 ` [PATCH v2 3/5] boot: android: Add bootconfig support Guillaume La Roque (TI.com)
@ 2025-10-31 15:58   ` Mattijs Korpershoek
  2025-11-03 18:52     ` Guillaume La Roque
  0 siblings, 1 reply; 23+ messages in thread
From: Mattijs Korpershoek @ 2025-10-31 15:58 UTC (permalink / raw)
  To: Guillaume La Roque (TI.com), Tom Rini, Mattijs Korpershoek
  Cc: Julien Masson, Guillaume La Roque, u-boot, Simon Glass,
	Nicolas Belin, Neil Armstrong, Andrew Goodbody, Aaron Kling,
	George Chan, Sam Day, Jerome Forissier, Maxime Fournier

Hi Guillaume,

Thank you for the patch.

On Fri, Oct 17, 2025 at 15:19, "Guillaume La Roque (TI.com)" <glaroque@baylibre.com> wrote:

> For android vendor boot image version 4 bootconfig is mandatory.[1]

There seems to be a link "[1]" here but it's not part of the commit
message.
Can you add it please?

>
> In the android_image_get_ramdisk function, after copying both vendor and
> boot ramdisks, we extract all androidboot.* entries from the kernel
> command line. These entries are added to the bootconfig section.
> We then update the sizes of the ramdisk and bootconfig.
> Finally, all androidboot.* entries are removed from the kernel command
> line.
>
> Signed-off-by: Guillaume La Roque (TI.com) <glaroque@baylibre.com>
> ---
>  boot/image-android.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 93 insertions(+), 8 deletions(-)
>
> diff --git a/boot/image-android.c b/boot/image-android.c
> index 613f2aa4b9e..cf038a4a62f 100644
> --- a/boot/image-android.c
> +++ b/boot/image-android.c
> @@ -534,17 +534,102 @@ int android_image_get_ramdisk(const void *hdr, const void *vendor_boot_img,
>  			ramdisk_ptr = img_data.ramdisk_addr;
>  		}
>  		*rd_data = ramdisk_ptr;
> -		memcpy((void *)(ramdisk_ptr), (void *)img_data.vendor_ramdisk_ptr,
> +
> +		/* Extract androidboot.* parameters from bootargs */
> +		const char *bootargs = env_get("bootargs");
> +		char *androidboot_params = NULL;
> +		char *new_bootargs = NULL;
> +		size_t androidboot_params_len = 0;
> +
> +		if (bootargs && img_data.bootconfig_size) {
> +			size_t len = strlen(bootargs);
> +
> +			androidboot_params = malloc(len + 1);
> +			new_bootargs = malloc(len + 1);
> +			if (!androidboot_params || !new_bootargs) {
> +				free(androidboot_params);
> +				free(new_bootargs);
> +				printf("Error: malloc failed\n");
> +				return -ENOMEM;
> +			}
> +
> +			/* Extract androidboot.* and build new bootargs in one pass */
> +			const char *src = bootargs;
> +			char *bc_dst = androidboot_params;
> +			char *args_dst = new_bootargs;
> +
> +			while (*src) {
> +				/* Skip leading spaces */
> +				while (*src == ' ')
> +					src++;
> +				if (!*src)
> +					break;
> +
> +				/* Check if this param starts with androidboot. */
> +				if (strncmp(src, "androidboot.", 12) == 0) {
> +					/* Copy to bootconfig (add newline if not first) */
> +					if (bc_dst != androidboot_params)
> +						*bc_dst++ = '\n';
> +					while (*src && *src != ' ')
> +						*bc_dst++ = *src++;
> +				} else {
> +					/* Copy to new bootargs (add space if not first) */
> +					if (args_dst != new_bootargs)
> +						*args_dst++ = ' ';
> +					while (*src && *src != ' ')
> +						*args_dst++ = *src++;
> +				}
> +			}
> +
> +			*bc_dst++ = '\n';  /* Final newline for bootconfig */
> +			*bc_dst = '\0';
> +			*args_dst = '\0';
> +			androidboot_params_len = bc_dst - androidboot_params;
> +
> +			/* Update bootargs if we extracted any androidboot params */
> +			if (androidboot_params_len > 1)
> +				env_set("bootargs", new_bootargs);
> +		}
> +
> +		/* Map addresses for memcpy operations */
> +		void *ramdisk_dest = map_sysmem(ramdisk_ptr, img_data.ramdisk_size);
> +		void *vendor_ramdisk_src = map_sysmem(img_data.vendor_ramdisk_ptr,
> +						      img_data.vendor_ramdisk_size);
> +		void *boot_ramdisk_src = map_sysmem(img_data.ramdisk_ptr,
> +						    img_data.boot_ramdisk_size);
> +
> +		memcpy(ramdisk_dest, vendor_ramdisk_src,
>  		       img_data.vendor_ramdisk_size);
> -		ramdisk_ptr += img_data.vendor_ramdisk_size;
> -		memcpy((void *)(ramdisk_ptr), (void *)img_data.ramdisk_ptr,
> -		       img_data.boot_ramdisk_size);
> -		ramdisk_ptr += img_data.boot_ramdisk_size;
> +		memcpy((char *)ramdisk_dest + img_data.vendor_ramdisk_size,
> +		       boot_ramdisk_src, img_data.boot_ramdisk_size);
> +
>  		if (img_data.bootconfig_size) {
> -			memcpy((void *)
> -			       (ramdisk_ptr), (void *)img_data.bootconfig_addr,
> -			       img_data.bootconfig_size);
> +			void *bootconfig_src = map_sysmem(img_data.bootconfig_addr,
> +							  img_data.bootconfig_size);
> +			memcpy((char *)ramdisk_dest + img_data.vendor_ramdisk_size +
> +			       img_data.boot_ramdisk_size,
> +			       bootconfig_src, img_data.bootconfig_size);
> +			unmap_sysmem(bootconfig_src);
> +
> +			/* Add androidboot.* parameters to bootconfig */
> +			if (androidboot_params && androidboot_params_len > 1) {
> +				ulong bootconfig_ptr = (ulong)ramdisk_dest +
> +						       img_data.vendor_ramdisk_size +
> +						       img_data.boot_ramdisk_size;
> +				img_data.ramdisk_size +=
> +					add_bootconfig_parameters(androidboot_params,
> +								  androidboot_params_len,
> +								  bootconfig_ptr,
> +								  img_data.bootconfig_size);
> +			}
>  		}
> +
> +		free(androidboot_params);
> +		free(new_bootargs);
> +
> +		unmap_sysmem(boot_ramdisk_src);
> +		unmap_sysmem(vendor_ramdisk_src);
> +		unmap_sysmem(ramdisk_dest);

We are here in the "if (img_data.header_version > 2) {" block.
What about boot image v3? Why are we forcing bootconfig upon them?

Also, please move this to a seperate function. It makes
android_image_get_ramdisk() quite long and difficult to read otherwise.

Finally, what happens if a kernel does not have bootconfig enabled ?
I imagine that everything will crash due to this change. Even if
bootconfig is mandatory for boot image v4, I believe we should make this
behaviour optional to avoid breaking existing kernels.

>  	} else {
>  		/* Ramdisk can be used in-place, use current ptr */
>  		if (img_data.ramdisk_addr == 0 ||
>
> -- 
> 2.34.1

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 4/5] cmd: abootimg: Add 'get ramdisk' command
  2025-10-17 13:19 ` [PATCH v2 4/5] cmd: abootimg: Add 'get ramdisk' command Guillaume La Roque (TI.com)
@ 2025-10-31 16:13   ` Mattijs Korpershoek
  0 siblings, 0 replies; 23+ messages in thread
From: Mattijs Korpershoek @ 2025-10-31 16:13 UTC (permalink / raw)
  To: Guillaume La Roque (TI.com), Tom Rini, Mattijs Korpershoek
  Cc: Julien Masson, Guillaume La Roque, u-boot, Simon Glass,
	Nicolas Belin, Neil Armstrong, Andrew Goodbody, Aaron Kling,
	George Chan, Sam Day, Jerome Forissier, Maxime Fournier

Hi Guillaume,

Thank you for the patch.

On Fri, Oct 17, 2025 at 15:19, "Guillaume La Roque (TI.com)" <glaroque@baylibre.com> wrote:

> Add support for retrieving ramdisk address and size from Android boot
> images. This command allows users to extract the ramdisk information
> for boot image v3+ which combines vendor ramdisk, boot ramdisk and
> bootconfig sections.
>
> Signed-off-by: Guillaume La Roque (TI.com) <glaroque@baylibre.com>

Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>

> ---
> 2.34.1

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 5/5] test: abootimg: Add test for bootconfig handling
  2025-10-17 13:19 ` [PATCH v2 5/5] test: abootimg: Add test for bootconfig handling Guillaume La Roque (TI.com)
  2025-10-19 13:06   ` Simon Glass
@ 2025-10-31 16:27   ` Mattijs Korpershoek
  2025-11-05 18:14     ` Guillaume La Roque
  1 sibling, 1 reply; 23+ messages in thread
From: Mattijs Korpershoek @ 2025-10-31 16:27 UTC (permalink / raw)
  To: Guillaume La Roque (TI.com), Tom Rini, Mattijs Korpershoek
  Cc: Julien Masson, Guillaume La Roque, u-boot, Simon Glass,
	Nicolas Belin, Neil Armstrong, Andrew Goodbody, Aaron Kling,
	George Chan, Sam Day, Jerome Forissier, Maxime Fournier

Hi Guillaume,

Thank you for the patch.

On Fri, Oct 17, 2025 at 15:19, "Guillaume La Roque (TI.com)" <glaroque@baylibre.com> wrote:

> Add test to verify that androidboot.* parameters are correctly extracted
> from bootargs and appended to the bootconfig section when using
> 'abootimg get ramdisk' with boot image v4 and vendor_boot image.
>
> The test verifies:
> - androidboot.* parameters are removed from bootargs
> - They are appended to the bootconfig section in the ramdisk
> - Non-androidboot parameters remain in bootargs
> - The bootconfig trailer is properly updated
>
> Signed-off-by: Guillaume La Roque (TI.com) <glaroque@baylibre.com>
> ---
>  test/py/tests/test_android/test_abootimg.py | 108 +++++++++++++++++++++++++---
>  1 file changed, 99 insertions(+), 9 deletions(-)
>
> diff --git a/test/py/tests/test_android/test_abootimg.py b/test/py/tests/test_android/test_abootimg.py
> index 2aadb692b30..bd5fb992a7d 100644
> --- a/test/py/tests/test_android/test_abootimg.py
> +++ b/test/py/tests/test_android/test_abootimg.py
> @@ -69,15 +69,33 @@ e5bddc8a7b792d8e8788c896ce9b88d32ebe6c971e7ddd3543cae734cd01
>  c0ffc84c0000b0766d1a87d4e5afeadd3dab7a6f10000000f84163d5d7cd
>  d43a000000000000000060c53e7544995700400000"""
>  
> -# vendor boot image v4 hex dump
> -vboot_img_hex = """1f8b0808baaecd63020376626f6f742e696d6700edd8310b824018c6f1b3
> -222a08f41b3436b4280dcdd19c11d16ee9109d18d59042d047ec8b04cd0d
> -d19d5a4345534bf6ffc173ef29272f38e93b1d0ec67dd79d548462aa1cd2
> -d5d20b0000f8438678f90c18d584b8a4bbb3a557991ecb2a0000f80d6b2f
> -f4179b656be5c532f2fc066f040000000080e23936af2755f62a3d918df1
> -db2a7ab67f9ffdeb7df7cda3465ecb79c4ce7e5c577562bb9364b74449a5
> -1e467e20c53c0a57de763193c1779b3b4fcd9d4ee27c6a0e00000000c0ff
> -309ffea7010000000040f1dc004129855400400000"""
> +# vendor boot image v4 hex dump (contains initial bootconfig: androidboot.hardware=test)
> +vboot_img_hex = """1f8b08000000000002ffeddb316a02411806d009a49040606d3d84374823a9a348b095
> +915951b2c9caee8690ce237a91406a0b497603e215dcbc577cf3334cf5350303b3787a
> +9c4fa6d3e7dbf02b6b63dfc6b01b0180ffe726644d5e37975bb34108c76efa1eb65974
> +c7fed691c600e02a64e7ab3e8494afe37bd128050000007ae6707ffad202000000f45b
> +155fd3b67e59eee26751c674a711000000e89ff896aa729b5665d98c37b14a1fb1ca1f
> +da4f7f5e02000000a0377e0040ab5ba000500000"""
> +
> +# bootable boot image v4 hex dump (contains actual bootable kernel)
> +boot_bootable_img_hex = """1f8b08081663ee6802ff626f6f745f626f6f7461626c655f76342e696d67
> +00edd1c14ac3401485e159b80a083ec24dba4f117c81d8140c6dad24ee25
> +4da6e9d07452321305dfca37d4d4ec5cb954fe6f37ccb967606ef298e6db
> +2c0d3f94526feae25adda81fae140000000000f8ab66e17c67ecdc1d025d
> +1d3a89125bf79da9e5beebbc64a7b2d1f27a27cfda7959e9deea369a8263
> +a0eaecde34e2c75b375495766e3fb46114cca430a7a12dbd96e3654a7663
> +dfb9f4feeb383514beecbdb1cd1489e3380a5cabf5596ea7c4f78b62acf1
> +a66ccdbbaea380950100000000f06b79b249b362f5f2b44e16cb87ed3a5d
> +e67c0a0000000000ffcc27ba944c7e00300000"""
> +
> +# bootable vendor boot image v4 hex dump (contains actual bootable ramdisk)
> +vendor_boot_bootable_img_hex = """1f8b08081663ee6802ff76656e646f725f626f6f745f626f6f7461626c65
> +5f76342e696d6700edd8b10a02310cc6f10c0e7220f8080737b8b93ab9a8
> +282e571171959e0d787058a84557f5c96ddd7d80c3ff0f92217c5396408e
> +f56abf30e63090649c9b3c53bd050000fcab57d45b3c35de47db749a06bb
> +e1eff08c7d0100d00bf6ea826f5dbef0d38b0dee618396f3f27bf69ddedb
> +b316558a4d462255fe132c4dbdde6e0a160700000000408f7c0027597569
> +00200000"""
>  
>  # Expected response for "abootimg dtb_dump" command
>  dtb_dump_resp="""## DTB area contents (concat format):
> @@ -179,6 +197,24 @@ def abootimgv4_disk_image_boot(ubman):
>          gtdi3 = AbootimgTestDiskImage(ubman, 'bootv4.img', boot_img_hex)
>      return gtdi3
>  
> +gtdi4 = None
> +@pytest.fixture(scope='function')
> +def abootimgv4_bootable_disk_image_boot(ubman):
> +    """pytest fixture to provide bootable boot image v4."""
> +    global gtdi4
> +    if not gtdi4:
> +        gtdi4 = AbootimgTestDiskImage(ubman, 'boot_bootable_v4.img', boot_bootable_img_hex)
> +    return gtdi4
> +
> +gtdi5 = None
> +@pytest.fixture(scope='function')
> +def abootimgv4_bootable_disk_image_vboot(ubman):
> +    """pytest fixture to provide bootable vendor boot image v4."""
> +    global gtdi5
> +    if not gtdi5:
> +        gtdi5 = AbootimgTestDiskImage(ubman, 'vendor_boot_bootable_v4.img', vendor_boot_bootable_img_hex)
> +    return gtdi5
> +
>  @pytest.mark.boardspec('sandbox')
>  @pytest.mark.buildconfigspec('android_boot_image')
>  @pytest.mark.buildconfigspec('cmd_abootimg')
> @@ -266,3 +302,57 @@ def test_abootimgv4(abootimgv4_disk_image_vboot, abootimgv4_disk_image_boot, ubm
>      ubman.run_command('fdt get value v / model')
>      response = ubman.run_command('env print v')
>      assert response == 'v=x2'
> +
> +@pytest.mark.boardspec('sandbox')
> +@pytest.mark.buildconfigspec('android_boot_image')
> +@pytest.mark.buildconfigspec('cmd_abootimg')
> +@pytest.mark.requiredtool('xxd')
> +@pytest.mark.requiredtool('gunzip')

We use the md command below so I think you should also add something in
the line of

    @pytest.mark.buildconfigspec('cmd_md')

Note: I have not tested this.

> +def test_abootimg_bootconfig(abootimgv4_disk_image_vboot,
> +                              abootimgv4_disk_image_boot,
> +                              ubman):

Nit: this seems weirdly indented. Should be:

+def test_abootimg_bootconfig(abootimgv4_disk_image_vboot,
+                             abootimgv4_disk_image_boot,
+                             ubman):


> +    """Test bootconfig handling with boot image v4.
> +
> +    Verifies that androidboot.* parameters from bootargs are appended to the
> +    bootconfig section in vendor_boot image in memory, and that non-androidboot
> +    parameters remain in bootargs.
> +    """
> +
> +    # Setup addresses
> +    ram_base = utils.find_ram_base(ubman)
> +    ramdisk_addr_r = ram_base + 0x4000000
> +    ubman.run_command('setenv ramdisk_addr_r 0x%x' % ramdisk_addr_r)
> +    ubman.run_command('setenv loadaddr 0x%x' % loadaddr)
> +    ubman.run_command('setenv vloadaddr 0x%x' % vloadaddr)
> +
> +    # Set bootargs with androidboot.* parameters
> +    ubman.run_command('setenv bootargs "androidboot.serialno=ABC123 androidboot.mode=recovery console=ttyS0"')
> +
> +    # Load images
> +    ubman.run_command('host load hostfs - 0x%x %s' % (vloadaddr,
> +        abootimgv4_disk_image_vboot.path))
> +    ubman.run_command('host load hostfs - 0x%x %s' % (loadaddr,
> +        abootimgv4_disk_image_boot.path))
> +    ubman.run_command('abootimg addr 0x%x 0x%x' % (loadaddr, vloadaddr))
> +
> +    # Extract ramdisk (triggers bootconfig append)
> +    ubman.run_command('abootimg get ramdisk ramdisk_addr ramdisk_size')
> +
> +    # Get ramdisk address
> +    response = ubman.run_command('env print ramdisk_addr')
> +    ramdisk_start = int(response.split('=')[1], 16)
> +
> +    # Verify androidboot.* parameters were removed from bootargs
> +    response = ubman.run_command('env print bootargs')
> +    assert 'androidboot.' not in response
> +    assert 'console=ttyS0' in response
> +
> +    # Get ramdisk size and verify BOOTCONFIG magic at the end
> +    response = ubman.run_command('env print ramdisk_size')
> +    ramdisk_size = int(response.split('=')[1], 16)
> +
> +    # Dump the end of the ramdisk where BOOTCONFIG trailer should be
> +    response = ubman.run_command('md.b 0x%x 96' % (ramdisk_start))
> +
> +    # Verify BOOTCONFIG magic is present
> +    assert 'BOOTCONFIG' in response or 'BOOTCON' in response

Can we explain why it's either BOOTCONFIG or BOOTCON? why would the
magic be truncated ?

>
> -- 
> 2.34.1

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 3/5] boot: android: Add bootconfig support
  2025-10-31 15:58   ` Mattijs Korpershoek
@ 2025-11-03 18:52     ` Guillaume La Roque
  2025-11-07 14:52       ` Mattijs Korpershoek
  0 siblings, 1 reply; 23+ messages in thread
From: Guillaume La Roque @ 2025-11-03 18:52 UTC (permalink / raw)
  To: Mattijs Korpershoek, Tom Rini
  Cc: Julien Masson, u-boot, Simon Glass, Nicolas Belin, Neil Armstrong,
	Andrew Goodbody, Aaron Kling, George Chan, Sam Day,
	Jerome Forissier, Maxime Fournier

Hi,


Le 31/10/2025 à 16:58, Mattijs Korpershoek a écrit :
> Hi Guillaume,
>
> Thank you for the patch.
>
> On Fri, Oct 17, 2025 at 15:19, "Guillaume La Roque (TI.com)"<glaroque@baylibre.com> wrote:
>
>> For android vendor boot image version 4 bootconfig is mandatory.[1]
> There seems to be a link "[1]" here but it's not part of the commit
> message.
> Can you add it please?
yes of course ,
>> In the android_image_get_ramdisk function, after copying both vendor and
>> boot ramdisks, we extract all androidboot.* entries from the kernel
>> command line. These entries are added to the bootconfig section.
>> We then update the sizes of the ramdisk and bootconfig.
>> Finally, all androidboot.* entries are removed from the kernel command
>> line.
>>
>> Signed-off-by: Guillaume La Roque (TI.com)<glaroque@baylibre.com>
>> ---
>>   boot/image-android.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++----
>>   1 file changed, 93 insertions(+), 8 deletions(-)
>>
>> diff --git a/boot/image-android.c b/boot/image-android.c
>> index 613f2aa4b9e..cf038a4a62f 100644
>> --- a/boot/image-android.c
>> +++ b/boot/image-android.c
>> @@ -534,17 +534,102 @@ int android_image_get_ramdisk(const void *hdr, const void *vendor_boot_img,
>>   			ramdisk_ptr = img_data.ramdisk_addr;
>>   		}
>>   		*rd_data = ramdisk_ptr;
>> -		memcpy((void *)(ramdisk_ptr), (void *)img_data.vendor_ramdisk_ptr,
>> +
>> +		/* Extract androidboot.* parameters from bootargs */
>> +		const char *bootargs = env_get("bootargs");
>> +		char *androidboot_params = NULL;
>> +		char *new_bootargs = NULL;
>> +		size_t androidboot_params_len = 0;
>> +
>> +		if (bootargs && img_data.bootconfig_size) {
>> +			size_t len = strlen(bootargs);
>> +
>> +			androidboot_params = malloc(len + 1);
>> +			new_bootargs = malloc(len + 1);
>> +			if (!androidboot_params || !new_bootargs) {
>> +				free(androidboot_params);
>> +				free(new_bootargs);
>> +				printf("Error: malloc failed\n");
>> +				return -ENOMEM;
>> +			}
>> +
>> +			/* Extract androidboot.* and build new bootargs in one pass */
>> +			const char *src = bootargs;
>> +			char *bc_dst = androidboot_params;
>> +			char *args_dst = new_bootargs;
>> +
>> +			while (*src) {
>> +				/* Skip leading spaces */
>> +				while (*src == ' ')
>> +					src++;
>> +				if (!*src)
>> +					break;
>> +
>> +				/* Check if this param starts with androidboot. */
>> +				if (strncmp(src, "androidboot.", 12) == 0) {
>> +					/* Copy to bootconfig (add newline if not first) */
>> +					if (bc_dst != androidboot_params)
>> +						*bc_dst++ = '\n';
>> +					while (*src && *src != ' ')
>> +						*bc_dst++ = *src++;
>> +				} else {
>> +					/* Copy to new bootargs (add space if not first) */
>> +					if (args_dst != new_bootargs)
>> +						*args_dst++ = ' ';
>> +					while (*src && *src != ' ')
>> +						*args_dst++ = *src++;
>> +				}
>> +			}
>> +
>> +			*bc_dst++ = '\n';  /* Final newline for bootconfig */
>> +			*bc_dst = '\0';
>> +			*args_dst = '\0';
>> +			androidboot_params_len = bc_dst - androidboot_params;
>> +
>> +			/* Update bootargs if we extracted any androidboot params */
>> +			if (androidboot_params_len > 1)
>> +				env_set("bootargs", new_bootargs);
>> +		}
>> +
>> +		/* Map addresses for memcpy operations */
>> +		void *ramdisk_dest = map_sysmem(ramdisk_ptr, img_data.ramdisk_size);
>> +		void *vendor_ramdisk_src = map_sysmem(img_data.vendor_ramdisk_ptr,
>> +						      img_data.vendor_ramdisk_size);
>> +		void *boot_ramdisk_src = map_sysmem(img_data.ramdisk_ptr,
>> +						    img_data.boot_ramdisk_size);
>> +
>> +		memcpy(ramdisk_dest, vendor_ramdisk_src,
>>   		       img_data.vendor_ramdisk_size);
>> -		ramdisk_ptr += img_data.vendor_ramdisk_size;
>> -		memcpy((void *)(ramdisk_ptr), (void *)img_data.ramdisk_ptr,
>> -		       img_data.boot_ramdisk_size);
>> -		ramdisk_ptr += img_data.boot_ramdisk_size;
>> +		memcpy((char *)ramdisk_dest + img_data.vendor_ramdisk_size,
>> +		       boot_ramdisk_src, img_data.boot_ramdisk_size);
>> +
>>   		if (img_data.bootconfig_size) {
>> -			memcpy((void *)
>> -			       (ramdisk_ptr), (void *)img_data.bootconfig_addr,
>> -			       img_data.bootconfig_size);
>> +			void *bootconfig_src = map_sysmem(img_data.bootconfig_addr,
>> +							  img_data.bootconfig_size);
>> +			memcpy((char *)ramdisk_dest + img_data.vendor_ramdisk_size +
>> +			       img_data.boot_ramdisk_size,
>> +			       bootconfig_src, img_data.bootconfig_size);
>> +			unmap_sysmem(bootconfig_src);
>> +
>> +			/* Add androidboot.* parameters to bootconfig */
>> +			if (androidboot_params && androidboot_params_len > 1) {
>> +				ulong bootconfig_ptr = (ulong)ramdisk_dest +
>> +						       img_data.vendor_ramdisk_size +
>> +						       img_data.boot_ramdisk_size;
>> +				img_data.ramdisk_size +=
>> +					add_bootconfig_parameters(androidboot_params,
>> +								  androidboot_params_len,
>> +								  bootconfig_ptr,
>> +								  img_data.bootconfig_size);
>> +			}
>>   		}
>> +
>> +		free(androidboot_params);
>> +		free(new_bootargs);
>> +
>> +		unmap_sysmem(boot_ramdisk_src);
>> +		unmap_sysmem(vendor_ramdisk_src);
>> +		unmap_sysmem(ramdisk_dest);
> We are here in the "if (img_data.header_version > 2) {" block.
> What about boot image v3? Why are we forcing bootconfig upon them?

our right it's not good bootconfig come with version 4 i will fix it in v3.

>
> Also, please move this to a seperate function. It makes
> android_image_get_ramdisk() quite long and difficult to read otherwise.
i will.
>
> Finally, what happens if a kernel does not have bootconfig enabled ?
> I imagine that everything will crash due to this change. Even if
> bootconfig is mandatory for boot image v4, I believe we should make this
> behaviour optional to avoid breaking existing kernels.

it's enable in android kernel since android-12-5.4.xx so if you enable 
boot image version 4 and move androidboot.x in booconfig instead of 
kernelcmdline it's because you decide to enable it with 
BOARD_KERNEL_CMDLINE += bootconfig and you support android boot image 
version 4. it's explained in aosp doc 
:https://source.android.com/docs/core/architecture/bootloader/implementing-bootconfig 


>
>>   	} else {
>>   		/* Ramdisk can be used in-place, use current ptr */
>>   		if (img_data.ramdisk_addr == 0 ||
>>
>> -- 
>> 2.34.1


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 5/5] test: abootimg: Add test for bootconfig handling
  2025-10-31 16:27   ` Mattijs Korpershoek
@ 2025-11-05 18:14     ` Guillaume La Roque
  2025-11-07 14:52       ` Mattijs Korpershoek
  0 siblings, 1 reply; 23+ messages in thread
From: Guillaume La Roque @ 2025-11-05 18:14 UTC (permalink / raw)
  To: Mattijs Korpershoek, Tom Rini
  Cc: Julien Masson, u-boot, Simon Glass, Nicolas Belin, Neil Armstrong,
	Andrew Goodbody, Aaron Kling, George Chan, Sam Day,
	Jerome Forissier, Maxime Fournier

Le 31/10/2025 à 17:27, Mattijs Korpershoek a écrit :
> Hi Guillaume,
>
> Thank you for the patch.
>
> On Fri, Oct 17, 2025 at 15:19, "Guillaume La Roque (TI.com)" <glaroque@baylibre.com> wrote:
>
>> Add test to verify that androidboot.* parameters are correctly extracted
>> from bootargs and appended to the bootconfig section when using
>> 'abootimg get ramdisk' with boot image v4 and vendor_boot image.
>>
>> The test verifies:
>> - androidboot.* parameters are removed from bootargs
>> - They are appended to the bootconfig section in the ramdisk
>> - Non-androidboot parameters remain in bootargs
>> - The bootconfig trailer is properly updated
>>
>> Signed-off-by: Guillaume La Roque (TI.com) <glaroque@baylibre.com>
>> ---
>>   test/py/tests/test_android/test_abootimg.py | 108 +++++++++++++++++++++++++---
>>   1 file changed, 99 insertions(+), 9 deletions(-)
>>
>> diff --git a/test/py/tests/test_android/test_abootimg.py b/test/py/tests/test_android/test_abootimg.py
>> index 2aadb692b30..bd5fb992a7d 100644
>> --- a/test/py/tests/test_android/test_abootimg.py
>> +++ b/test/py/tests/test_android/test_abootimg.py
>> @@ -69,15 +69,33 @@ e5bddc8a7b792d8e8788c896ce9b88d32ebe6c971e7ddd3543cae734cd01
>>   c0ffc84c0000b0766d1a87d4e5afeadd3dab7a6f10000000f84163d5d7cd
>>   d43a000000000000000060c53e7544995700400000"""
>>   
>> -# vendor boot image v4 hex dump
>> -vboot_img_hex = """1f8b0808baaecd63020376626f6f742e696d6700edd8310b824018c6f1b3
>> -222a08f41b3436b4280dcdd19c11d16ee9109d18d59042d047ec8b04cd0d
>> -d19d5a4345534bf6ffc173ef29272f38e93b1d0ec67dd79d548462aa1cd2
>> -d5d20b0000f8438678f90c18d584b8a4bbb3a557991ecb2a0000f80d6b2f
>> -f4179b656be5c532f2fc066f040000000080e23936af2755f62a3d918df1
>> -db2a7ab67f9ffdeb7df7cda3465ecb79c4ce7e5c577562bb9364b74449a5
>> -1e467e20c53c0a57de763193c1779b3b4fcd9d4ee27c6a0e00000000c0ff
>> -309ffea7010000000040f1dc004129855400400000"""
>> +# vendor boot image v4 hex dump (contains initial bootconfig: androidboot.hardware=test)
>> +vboot_img_hex = """1f8b08000000000002ffeddb316a02411806d009a49040606d3d84374823a9a348b095
>> +915951b2c9caee8690ce237a91406a0b497603e215dcbc577cf3334cf5350303b3787a
>> +9c4fa6d3e7dbf02b6b63dfc6b01b0180ffe726644d5e37975bb34108c76efa1eb65974
>> +c7fed691c600e02a64e7ab3e8494afe37bd128050000007ae6707ffad202000000f45b
>> +155fd3b67e59eee26751c674a711000000e89ff896aa729b5665d98c37b14a1fb1ca1f
>> +da4f7f5e02000000a0377e0040ab5ba000500000"""
>> +
>> +# bootable boot image v4 hex dump (contains actual bootable kernel)
>> +boot_bootable_img_hex = """1f8b08081663ee6802ff626f6f745f626f6f7461626c655f76342e696d67
>> +00edd1c14ac3401485e159b80a083ec24dba4f117c81d8140c6dad24ee25
>> +4da6e9d07452321305dfca37d4d4ec5cb954fe6f37ccb967606ef298e6db
>> +2c0d3f94526feae25adda81fae140000000000f8ab66e17c67ecdc1d025d
>> +1d3a89125bf79da9e5beebbc64a7b2d1f27a27cfda7959e9deea369a8263
>> +a0eaecde34e2c75b375495766e3fb46114cca430a7a12dbd96e3654a7663
>> +dfb9f4feeb383514beecbdb1cd1489e3380a5cabf5596ea7c4f78b62acf1
>> +a66ccdbbaea380950100000000f06b79b249b362f5f2b44e16cb87ed3a5d
>> +e67c0a0000000000ffcc27ba944c7e00300000"""
>> +
>> +# bootable vendor boot image v4 hex dump (contains actual bootable ramdisk)
>> +vendor_boot_bootable_img_hex = """1f8b08081663ee6802ff76656e646f725f626f6f745f626f6f7461626c65
>> +5f76342e696d6700edd8b10a02310cc6f10c0e7220f8080737b8b93ab9a8
>> +282e571171959e0d787058a84557f5c96ddd7d80c3ff0f92217c5396408e
>> +f56abf30e63090649c9b3c53bd050000fcab57d45b3c35de47db749a06bb
>> +e1eff08c7d0100d00bf6ea826f5dbef0d38b0dee618396f3f27bf69ddedb
>> +b316558a4d462255fe132c4dbdde6e0a160700000000408f7c0027597569
>> +00200000"""
>>   
>>   # Expected response for "abootimg dtb_dump" command
>>   dtb_dump_resp="""## DTB area contents (concat format):
>> @@ -179,6 +197,24 @@ def abootimgv4_disk_image_boot(ubman):
>>           gtdi3 = AbootimgTestDiskImage(ubman, 'bootv4.img', boot_img_hex)
>>       return gtdi3
>>   
>> +gtdi4 = None
>> +@pytest.fixture(scope='function')
>> +def abootimgv4_bootable_disk_image_boot(ubman):
>> +    """pytest fixture to provide bootable boot image v4."""
>> +    global gtdi4
>> +    if not gtdi4:
>> +        gtdi4 = AbootimgTestDiskImage(ubman, 'boot_bootable_v4.img', boot_bootable_img_hex)
>> +    return gtdi4
>> +
>> +gtdi5 = None
>> +@pytest.fixture(scope='function')
>> +def abootimgv4_bootable_disk_image_vboot(ubman):
>> +    """pytest fixture to provide bootable vendor boot image v4."""
>> +    global gtdi5
>> +    if not gtdi5:
>> +        gtdi5 = AbootimgTestDiskImage(ubman, 'vendor_boot_bootable_v4.img', vendor_boot_bootable_img_hex)
>> +    return gtdi5
>> +
>>   @pytest.mark.boardspec('sandbox')
>>   @pytest.mark.buildconfigspec('android_boot_image')
>>   @pytest.mark.buildconfigspec('cmd_abootimg')
>> @@ -266,3 +302,57 @@ def test_abootimgv4(abootimgv4_disk_image_vboot, abootimgv4_disk_image_boot, ubm
>>       ubman.run_command('fdt get value v / model')
>>       response = ubman.run_command('env print v')
>>       assert response == 'v=x2'
>> +
>> +@pytest.mark.boardspec('sandbox')
>> +@pytest.mark.buildconfigspec('android_boot_image')
>> +@pytest.mark.buildconfigspec('cmd_abootimg')
>> +@pytest.mark.requiredtool('xxd')
>> +@pytest.mark.requiredtool('gunzip')
> We use the md command below so I think you should also add something in
> the line of
>
>      @pytest.mark.buildconfigspec('cmd_md')
>
> Note: I have not tested this.
>
>> +def test_abootimg_bootconfig(abootimgv4_disk_image_vboot,
>> +                              abootimgv4_disk_image_boot,
>> +                              ubman):
> Nit: this seems weirdly indented. Should be:
>
> +def test_abootimg_bootconfig(abootimgv4_disk_image_vboot,
> +                             abootimgv4_disk_image_boot,
> +                             ubman):
will fix in v3
>
>> +    """Test bootconfig handling with boot image v4.
>> +
>> +    Verifies that androidboot.* parameters from bootargs are appended to the
>> +    bootconfig section in vendor_boot image in memory, and that non-androidboot
>> +    parameters remain in bootargs.
>> +    """
>> +
>> +    # Setup addresses
>> +    ram_base = utils.find_ram_base(ubman)
>> +    ramdisk_addr_r = ram_base + 0x4000000
>> +    ubman.run_command('setenv ramdisk_addr_r 0x%x' % ramdisk_addr_r)
>> +    ubman.run_command('setenv loadaddr 0x%x' % loadaddr)
>> +    ubman.run_command('setenv vloadaddr 0x%x' % vloadaddr)
>> +
>> +    # Set bootargs with androidboot.* parameters
>> +    ubman.run_command('setenv bootargs "androidboot.serialno=ABC123 androidboot.mode=recovery console=ttyS0"')
>> +
>> +    # Load images
>> +    ubman.run_command('host load hostfs - 0x%x %s' % (vloadaddr,
>> +        abootimgv4_disk_image_vboot.path))
>> +    ubman.run_command('host load hostfs - 0x%x %s' % (loadaddr,
>> +        abootimgv4_disk_image_boot.path))
>> +    ubman.run_command('abootimg addr 0x%x 0x%x' % (loadaddr, vloadaddr))
>> +
>> +    # Extract ramdisk (triggers bootconfig append)
>> +    ubman.run_command('abootimg get ramdisk ramdisk_addr ramdisk_size')
>> +
>> +    # Get ramdisk address
>> +    response = ubman.run_command('env print ramdisk_addr')
>> +    ramdisk_start = int(response.split('=')[1], 16)
>> +
>> +    # Verify androidboot.* parameters were removed from bootargs
>> +    response = ubman.run_command('env print bootargs')
>> +    assert 'androidboot.' not in response
>> +    assert 'console=ttyS0' in response
>> +
>> +    # Get ramdisk size and verify BOOTCONFIG magic at the end
>> +    response = ubman.run_command('env print ramdisk_size')
>> +    ramdisk_size = int(response.split('=')[1], 16)
>> +
>> +    # Dump the end of the ramdisk where BOOTCONFIG trailer should be
>> +    response = ubman.run_command('md.b 0x%x 96' % (ramdisk_start))
>> +
>> +    # Verify BOOTCONFIG magic is present
>> +    assert 'BOOTCONFIG' in response or 'BOOTCON' in response
> Can we explain why it's either BOOTCONFIG or BOOTCON? why would the
> magic be truncated ?
no reason error from me
>> -- 
>> 2.34.1



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 3/5] boot: android: Add bootconfig support
  2025-11-03 18:52     ` Guillaume La Roque
@ 2025-11-07 14:52       ` Mattijs Korpershoek
  0 siblings, 0 replies; 23+ messages in thread
From: Mattijs Korpershoek @ 2025-11-07 14:52 UTC (permalink / raw)
  To: Guillaume La Roque, Mattijs Korpershoek, Tom Rini
  Cc: Julien Masson, u-boot, Simon Glass, Nicolas Belin, Neil Armstrong,
	Andrew Goodbody, Aaron Kling, George Chan, Sam Day,
	Jerome Forissier, Maxime Fournier

On Mon, Nov 03, 2025 at 19:52, Guillaume La Roque <glaroque@baylibre.com> wrote:

> Hi,
>

[...]

>>> +		unmap_sysmem(ramdisk_dest);
>> We are here in the "if (img_data.header_version > 2) {" block.
>> What about boot image v3? Why are we forcing bootconfig upon them?
>
> our right it's not good bootconfig come with version 4 i will fix it in v3.
>
>>
>> Also, please move this to a seperate function. It makes
>> android_image_get_ramdisk() quite long and difficult to read otherwise.
> i will.
>>
>> Finally, what happens if a kernel does not have bootconfig enabled ?
>> I imagine that everything will crash due to this change. Even if
>> bootconfig is mandatory for boot image v4, I believe we should make this
>> behaviour optional to avoid breaking existing kernels.
>
> it's enable in android kernel since android-12-5.4.xx so if you enable 
> boot image version 4 and move androidboot.x in booconfig instead of 
> kernelcmdline it's because you decide to enable it with 
> BOARD_KERNEL_CMDLINE += bootconfig and you support android boot image 
> version 4. it's explained in aosp doc 
> :https://source.android.com/docs/core/architecture/bootloader/implementing-bootconfig 

Ok, so if I understand correctly, boot image v4 without bootconfig
enabled is not a supported use-case.

>
>
>>
>>>   	} else {
>>>   		/* Ramdisk can be used in-place, use current ptr */
>>>   		if (img_data.ramdisk_addr == 0 ||
>>>
>>> -- 
>>> 2.34.1

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v2 5/5] test: abootimg: Add test for bootconfig handling
  2025-11-05 18:14     ` Guillaume La Roque
@ 2025-11-07 14:52       ` Mattijs Korpershoek
  0 siblings, 0 replies; 23+ messages in thread
From: Mattijs Korpershoek @ 2025-11-07 14:52 UTC (permalink / raw)
  To: Guillaume La Roque, Mattijs Korpershoek, Tom Rini
  Cc: Julien Masson, u-boot, Simon Glass, Nicolas Belin, Neil Armstrong,
	Andrew Goodbody, Aaron Kling, George Chan, Sam Day,
	Jerome Forissier, Maxime Fournier

On Wed, Nov 05, 2025 at 19:14, Guillaume La Roque <glaroque@baylibre.com> wrote:

[...]

>>> +
>>> +    # Verify BOOTCONFIG magic is present
>>> +    assert 'BOOTCONFIG' in response or 'BOOTCON' in response
>> Can we explain why it's either BOOTCONFIG or BOOTCON? why would the
>> magic be truncated ?
> no reason error from me

Ok, please fix in v3!

>>> -- 
>>> 2.34.1

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2025-11-07 14:53 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-17 13:19 [PATCH v2 0/5] android: add bootconfig support Guillaume La Roque (TI.com)
2025-10-17 13:19 ` [PATCH v2 1/5] boot: android: import addBootConfigParameters() from AOSP Guillaume La Roque (TI.com)
2025-10-31 15:39   ` Mattijs Korpershoek
2025-10-17 13:19 ` [PATCH v2 2/5] boot: android: Add sandbox memory mapping support Guillaume La Roque (TI.com)
2025-10-31 15:49   ` Mattijs Korpershoek
2025-10-17 13:19 ` [PATCH v2 3/5] boot: android: Add bootconfig support Guillaume La Roque (TI.com)
2025-10-31 15:58   ` Mattijs Korpershoek
2025-11-03 18:52     ` Guillaume La Roque
2025-11-07 14:52       ` Mattijs Korpershoek
2025-10-17 13:19 ` [PATCH v2 4/5] cmd: abootimg: Add 'get ramdisk' command Guillaume La Roque (TI.com)
2025-10-31 16:13   ` Mattijs Korpershoek
2025-10-17 13:19 ` [PATCH v2 5/5] test: abootimg: Add test for bootconfig handling Guillaume La Roque (TI.com)
2025-10-19 13:06   ` Simon Glass
2025-10-19 16:01     ` Tom Rini
2025-10-20  5:18       ` Simon Glass
2025-10-24 15:09         ` Guillaume La Roque
2025-10-24 15:20           ` Tom Rini
2025-10-31 16:27   ` Mattijs Korpershoek
2025-11-05 18:14     ` Guillaume La Roque
2025-11-07 14:52       ` Mattijs Korpershoek
2025-10-18  6:07 ` [PATCH v2 0/5] android: add bootconfig support george chan
2025-10-20 13:58   ` Guillaume La Roque
2025-10-20 15:45     ` george chan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox