summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume La Roque (TI.com) <[email protected]>2026-01-12 11:55:40 +0100
committerMattijs Korpershoek <[email protected]>2026-01-15 14:00:55 +0100
commit892409d4fc04d585fc974e33ef63b735d401e11a (patch)
treeaae7e1f99f807c1b098326b4542576682f43236d
parent733f5a601989f5404947c4b268d40724bac414f6 (diff)
cmd: abootimg: Add 'get ramdisk' command
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]> Reviewed-by: Simon Glass <[email protected]> Signed-off-by: Guillaume La Roque (TI.com) <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mattijs Korpershoek <[email protected]>
-rw-r--r--cmd/abootimg.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/cmd/abootimg.c b/cmd/abootimg.c
index c488609a8f4..eae3e643b60 100644
--- a/cmd/abootimg.c
+++ b/cmd/abootimg.c
@@ -222,6 +222,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[])
{
@@ -241,6 +268,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;
}
@@ -307,5 +336,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"
);