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 <mkorpershoek@kernel.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Guillaume La Roque (TI.com) <glaroque@baylibre.com>
Link: https://lore.kernel.org/r/20260112-bootconfig-v5-4-79b242159ac7@baylibre.com
Signed-off-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
This commit is contained in:
Guillaume La Roque (TI.com)
2026-01-12 11:55:40 +01:00
committed by Mattijs Korpershoek
parent 733f5a6019
commit 892409d4fc

View File

@@ -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"
);