]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
cmd: abootimg: Add 'get ramdisk' command
authorGuillaume La Roque (TI.com) <glaroque@baylibre.com>
Mon, 12 Jan 2026 10:55:40 +0000 (11:55 +0100)
committerMattijs Korpershoek <mkorpershoek@kernel.org>
Thu, 15 Jan 2026 13:00:55 +0000 (14:00 +0100)
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>
cmd/abootimg.c

index c488609a8f409a70fdb7272f6e420842b44c7e6f..eae3e643b60123b601c21ef561c2c09a4a828318 100644 (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"
 );