[PATCH v2 4/5] cmd: abootimg: Add 'get ramdisk' command
Guillaume La Roque (TI.com)
glaroque at baylibre.com
Fri Oct 17 15:19:20 CEST 2025
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 at 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
More information about the U-Boot
mailing list