]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
imx8qx: misc: add command for getting boottype
authorHeiko Schocher <hs@nabladev.com>
Fri, 13 Feb 2026 05:15:07 +0000 (06:15 +0100)
committerFabio Estevam <festevam@gmail.com>
Sat, 28 Feb 2026 18:31:49 +0000 (15:31 -0300)
add boottype command, which saves the boot_type
primary (0) or fallback (1) in environment
variable "boottype". If argument "print" is
passed, it also prints the boottype on console.

Signed-off-by: Heiko Schocher <hs@nabladev.com>
Signed-off-by: Walter Schweizer <walter.schweizer@siemens.com>
arch/arm/mach-imx/imx8/misc.c

index c77104d0338fa6107ed8b7a08d70025a154ae367..22d6959f74f3759664368ec213324d53d7dd1151 100644 (file)
@@ -1,4 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
+#include <command.h>
+#include <env.h>
 #include <log.h>
 #include <firmware/imx/sci/sci.h>
 #include <asm/mach-imx/sys_proto.h>
@@ -62,3 +64,34 @@ void build_info(void)
        printf("Build: SCFW %08x, SECO-FW %08x, ATF %s\n",
               sc_commit, seco_commit, (char *)&atf_commit);
 }
+
+int do_boottype(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[])
+{
+       sc_misc_bt_t boot_type;
+
+       if (argc > 2)
+               return CMD_RET_USAGE;
+
+       if (sc_misc_get_boot_type(-1, &boot_type) != 0) {
+               puts("boottype cannot be retrieved\n");
+               return CMD_RET_FAILURE;
+       }
+
+       if (argc > 1)
+               printf("Boottype: %d\n", boot_type);
+
+       env_set_ulong("boottype", boot_type);
+
+       return CMD_RET_SUCCESS;
+}
+
+U_BOOT_CMD(boottype, CONFIG_SYS_MAXARGS, 2, do_boottype,
+          "save current boot-container in env variable 'boottype'",
+          "possible values for boottype:\n"
+          "0: SC_MISC_BT_PRIMARY\n"
+          "1: SC_MISC_BT_SECONDARY\n"
+          "2: SC_MISC_BT_RECOVERY\n"
+          "3: SC_MISC_BT_MANUFACTURE\n"
+          "4: SC_MISC_BT_SERIAL\n"
+          "[print] - print current boottype"
+);