@@ -280,6 +280,16 @@ config CMD_SMBIOS
help
Display the SMBIOS information.
+config CMD_CHID
+ bool "chid"
+ depends on CHID
+ default y
+ help
+ Computer Hardware ID (CHID) utilities. This provides commands to
+ extract hardware identification data from SMBIOS tables according
+ to the Microsoft CHID specification. This is used by Windows Update
+ and fwupd for hardware identification and firmware updates.
+
endmenu
menu "Boot commands"
@@ -46,6 +46,7 @@ obj-$(CONFIG_CMD_CAT) += cat.o
obj-$(CONFIG_CMD_CACHE) += cache.o
obj-$(CONFIG_CMD_CBFS) += cbfs.o
obj-$(CONFIG_CMD_CEDIT) += cedit.o
+obj-$(CONFIG_CMD_CHID) += chid.o
obj-$(CONFIG_CMD_CLK) += clk.o
obj-$(CONFIG_CMD_CLS) += cls.o
obj-$(CONFIG_CMD_CONFIG) += config.o
new file mode 100644
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Command for Computer Hardware Identifiers (Windows CHID)
+ *
+ * Copyright 2025 Simon Glass <sjg@chromium.org>
+ */
+
+#include <chid.h>
+#include <command.h>
+#include <vsprintf.h>
+
+static int do_chid_show(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ struct chid_data chid;
+ int ret;
+
+ ret = chid_from_smbios(&chid);
+ if (ret) {
+ printf("Failed to get CHID data from SMBIOS (err=%dE)\n", ret);
+ return CMD_RET_FAILURE;
+ }
+
+ printf("Manufacturer: %s\n", chid.manuf);
+ printf("Family: %s\n", chid.family);
+ printf("Product Name: %s\n", chid.product_name);
+ printf("Product SKU: %s\n", chid.product_sku);
+ printf("Baseboard Manuf: %s\n", chid.board_manuf);
+ printf("Baseboard Product: %s\n", chid.board_product);
+ printf("BIOS Vendor: %s\n", chid.bios_vendor);
+ printf("BIOS Version: %s\n", chid.bios_version);
+ printf("BIOS Major: %u\n", chid.bios_major);
+ printf("BIOS Minor: %u\n", chid.bios_minor);
+ printf("Enclosure Type: %u\n", chid.enclosure_type);
+
+ return 0;
+}
+
+U_BOOT_LONGHELP(chid,
+ "show - Show CHID data extracted from SMBIOS");
+
+U_BOOT_CMD_WITH_SUBCMDS(chid, "Computer Hardware ID utilities", chid_help_text,
+ U_BOOT_SUBCMD_MKENT(show, 1, 1, do_chid_show));
new file mode 100644
@@ -0,0 +1,67 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+chid command
+============
+
+Synopsis
+--------
+
+::
+
+ chid show
+
+Description
+-----------
+
+The chid command provides access to Computer Hardware IDs (CHIDs) generated from
+SMBIOS data. CHIDs are used by Windows Update and fwupd for hardware
+identification and firmware-update targeting.
+
+CHIDs are generated according to Microsoft's specification, which defines 15
+different hardware ID variants (HardwareID-00 through HardwareID-14), each
+using different combinations of SMBIOS fields. The variants range from most
+specific (including all identifying fields) to least specific (manufacturer
+only).
+
+Subcommands
+-----------
+
+show
+ Show the relevant SMBIOS values for the current board. These are used to
+ calculate CHIDs.
+
+
+Examples
+--------
+
+::
+
+ => chid show
+ Manufacturer: Sandbox Corp
+ Family: Sandbox_Family
+ Product Name: Sandbox Computer
+ Product SKU: SANDBOX-SKU
+ Baseboard Manuf: Sandbox Boards
+ Baseboard Product: Sandbox Motherboard
+ BIOS Vendor: U-Boot
+ BIOS Version: 2025.08-g167811e037b5-dirty
+ BIOS Major: 25
+ BIOS Minor: 8
+ Enclosure Type: 2
+ =>
+
+
+Configuration
+-------------
+
+The chid command is available when `CONFIG_CMD_CHID` is enabled.
+
+Return value
+------------
+
+The return value $? is 0 (true) on success, 1 (false) on failure.
+
+See also
+--------
+
+* :doc:`smbios <smbios>` - SMBIOS table information
@@ -49,6 +49,7 @@ Shell commands
cmd/cbcmos
cmd/cbsysinfo
cmd/cedit
+ cmd/chid
cmd/cli
cmd/cls
cmd/cmp
@@ -14,6 +14,7 @@ obj-y += exit.o
obj-$(CONFIG_X86) += cpuid.o msr.o
obj-$(CONFIG_CMD_ADDRMAP) += addrmap.o
obj-$(CONFIG_CMD_BDI) += bdinfo.o
+obj-$(CONFIG_CMD_CHID) += chid.o
obj-$(CONFIG_COREBOOT_SYSINFO) += coreboot.o
obj-$(CONFIG_CMD_FDT) += fdt.o
ifdef CONFIG_SANDBOX
new file mode 100644
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Test for chid command
+ *
+ * Copyright 2025 Simon Glass <sjg@chromium.org>
+ */
+
+#include <command.h>
+#include <console.h>
+#include <test/cmd.h>
+#include <test/ut.h>
+#include <version.h>
+
+/* Test the 'chid show' command */
+static int cmd_chid_show_test(struct unit_test_state *uts)
+{
+ /* Test chid show command and verify expected output */
+ ut_assertok(run_command("chid show", 0));
+
+ ut_assert_nextline("Manufacturer: Sandbox Corp");
+ ut_assert_nextline("Family: Sandbox_Family");
+ ut_assert_nextline("Product Name: Sandbox Computer");
+ ut_assert_nextline("Product SKU: SANDBOX-SKU");
+ ut_assert_nextline("Baseboard Manuf: Sandbox Boards");
+ ut_assert_nextline("Baseboard Product: Sandbox Motherboard");
+ ut_assert_nextline("BIOS Vendor: U-Boot");
+ ut_assert_nextlinen("BIOS Version: " PLAIN_VERSION);
+ ut_assert_nextline("BIOS Major: %u", U_BOOT_VERSION_NUM % 100);
+ ut_assert_nextline("BIOS Minor: %u", U_BOOT_VERSION_NUM_PATCH);
+ ut_assert_nextline("Enclosure Type: 2");
+ ut_assert_console_end();
+
+ return 0;
+}
+CMD_TEST(cmd_chid_show_test, UTF_CONSOLE);
+
+/* Test invalid chid subcommand */
+static int cmd_chid_invalid_test(struct unit_test_state *uts)
+{
+ /* Test chid command with invalid arguments */
+ ut_asserteq(1, run_command("chid invalid", 0));
+
+ return 0;
+}
+CMD_TEST(cmd_chid_invalid_test, UTF_CONSOLE);