Hi Simon,
Le 19/11/2025 à 14:17, Simon Glass a écrit :
Hi Guillaume,
On Fri, 14 Nov 2025 at 08:28, Guillaume La Roque (TI.com)
<[email protected]> 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.
Reviewed-by: Mattijs Korpershoek <[email protected]>
Signed-off-by: Guillaume La Roque (TI.com) <[email protected]>
---
cmd/abootimg.c | 35 ++++++++++++++++++++++++++++++++++-
1 file changed, 34 insertions(+), 1 deletion(-)
Reviewed-by: Simon Glass <[email protected]>
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(),
Casting an address to a pointer seems strange. Probably at some point
the API should be updated to have an address.
You can use nomap_sysmem() but that is more for things like ACPI
tables which embed addresses, so in this case I think an address would
be better.
i will do it in other patch after this series if it's ok for you
+ &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
Regards,
Simon
Regards,
Guillaume