]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
bootstd: cros: Add ARM support
authorSimon Glass <sjg@chromium.org>
Sun, 30 Jul 2023 17:17:02 +0000 (11:17 -0600)
committerSimon Glass <sjg@chromium.org>
Fri, 11 Aug 2023 13:33:40 +0000 (07:33 -0600)
Support booting ChromiumOS on ARM devices using FIT. Add an entry into the
boot implementation which does not require a command line. This can be
expanded over time as the bootm code is refactored.

Signed-off-by: Simon Glass <sjg@chromium.org>
boot/Kconfig
boot/bootm.c
boot/bootmeth_cros.c
include/bootm.h

index b00d7a8d11ece62d18748a284e5c5b233f3c4003..5e2d4286aeaa921745e276ae75e6c3e954de6ec6 100644 (file)
@@ -464,8 +464,8 @@ config BOOTMETH_GLOBAL
 
 config BOOTMETH_CROS
        bool "Bootdev support for Chromium OS"
-       depends on X86 || SANDBOX
-       default y
+       depends on X86 || ARM || SANDBOX
+       default y if !ARM
        help
          Enables support for booting Chromium OS using bootdevs. This uses the
          kernel A slot and obtains the kernel command line from the parameters
index 75f0b4a9af8a04bf6c2268cc4f6bf32b75478cbd..b1c3afe0a3adafbce9ec99b734befa464633c5f2 100644 (file)
@@ -823,6 +823,43 @@ err:
        return ret;
 }
 
+int bootm_boot_start(ulong addr, const char *cmdline)
+{
+       static struct cmd_tbl cmd = {"bootm"};
+       char addr_str[30];
+       char *argv[] = {addr_str, NULL};
+       int states;
+       int ret;
+
+       /*
+        * TODO(sjg@chromium.org): This uses the command-line interface, but
+        * should not. To clean this up, the various bootm states need to be
+        * passed an info structure instead of cmdline flags. Then this can
+        * set up the required info and move through the states without needing
+        * the command line.
+        */
+       states = BOOTM_STATE_START | BOOTM_STATE_FINDOS | BOOTM_STATE_PRE_LOAD |
+               BOOTM_STATE_FINDOTHER | BOOTM_STATE_LOADOS |
+               BOOTM_STATE_OS_PREP | BOOTM_STATE_OS_FAKE_GO |
+               BOOTM_STATE_OS_GO;
+       if (IS_ENABLED(CONFIG_SYS_BOOT_RAMDISK_HIGH))
+               states |= BOOTM_STATE_RAMDISK;
+       if (IS_ENABLED(CONFIG_PPC) || IS_ENABLED(CONFIG_MIPS))
+               states |= BOOTM_STATE_OS_CMDLINE;
+       images.state |= states;
+
+       snprintf(addr_str, sizeof(addr_str), "%lx", addr);
+
+       ret = env_set("bootargs", cmdline);
+       if (ret) {
+               printf("Failed to set cmdline\n");
+               return ret;
+       }
+       ret = do_bootm_states(&cmd, 0, 1, argv, states, &images, 1);
+
+       return ret;
+}
+
 #if CONFIG_IS_ENABLED(LEGACY_IMAGE_FORMAT)
 /**
  * image_get_kernel - verify legacy format kernel image
index 6c28feb34fe045633ab0f8b34965808c4e0de1c1..1776fb1838c6c81e27ace2d452469830620eec03 100644 (file)
@@ -419,13 +419,17 @@ static int cros_boot(struct udevice *dev, struct bootflow *bflow)
                if (ret)
                        return log_msg_ret("rd", ret);
        }
-#ifdef CONFIG_X86
-       zboot_start(map_to_sysmem(bflow->buf), bflow->size, 0, 0,
-                   map_to_sysmem(bflow->x86_setup),
-                   bflow->cmdline);
-#endif
 
-       return log_msg_ret("go", -EFAULT);
+       if (IS_ENABLED(CONFIG_X86)) {
+               ret = zboot_start(map_to_sysmem(bflow->buf), bflow->size, 0, 0,
+                                 map_to_sysmem(bflow->x86_setup),
+                                 bflow->cmdline);
+       } else {
+               ret = bootm_boot_start(map_to_sysmem(bflow->buf),
+                                      bflow->cmdline);
+       }
+
+       return log_msg_ret("go", ret);
 }
 
 static int cros_bootmeth_bind(struct udevice *dev)
index 92870ff1a206a787847502c0c855e5492982be69..c3c7336207b166a8fea6ea477a707ba3b282d647 100644 (file)
@@ -163,4 +163,12 @@ const char *zimage_get_kernel_version(struct boot_params *params,
  */
 void zimage_dump(struct boot_params *base_ptr, bool show_cmdline);
 
+/*
+ * bootm_boot_start() - Boot an image at the given address
+ *
+ * @addr: Image address
+ * @cmdline: Command line to set
+ */
+int bootm_boot_start(ulong addr, const char *cmdline);
+
 #endif