From patchwork Wed Sep 3 13:36:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 202 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756906654; bh=3j0tVx3UO4hO5QBroqq1R11uGrattIhkuxoyxeM3Z7I=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=T7Z+oUPyvJnd6pg7fB9UTn3MUAOL8wRQXjp61KkC6T+ekA1+8rUY6nBm3NHcXhCBg z+z1t9LnxbVC1zKvEu0wA9Q2G+/vEqQmq/4FZdh+UrPuBMk9d8WnSLbAGhwxg1xLbA Tvz5sOfbMzCwUTtxSCeKrqutsQnf/fsa85CrS48mkIpfa2AtuZH4IcHDjzfg99e421 TZhfZvkDxrYx+dfXySz6FZpejwn0BcOqitbvnroFdmkD+ko0hrThH4a1S+I0xmzlEu 5x6d7sHLfLgjBSDlsS5t7koTx1ygSWKBs3m++5XzTFuqD+qMKX8nx9fC4MNjuWc4O8 R9hGl4OhnsdRg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5187767915 for ; Wed, 3 Sep 2025 07:37:34 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id mvjUKfnb4IkL for ; Wed, 3 Sep 2025 07:37:34 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756906654; bh=3j0tVx3UO4hO5QBroqq1R11uGrattIhkuxoyxeM3Z7I=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=T7Z+oUPyvJnd6pg7fB9UTn3MUAOL8wRQXjp61KkC6T+ekA1+8rUY6nBm3NHcXhCBg z+z1t9LnxbVC1zKvEu0wA9Q2G+/vEqQmq/4FZdh+UrPuBMk9d8WnSLbAGhwxg1xLbA Tvz5sOfbMzCwUTtxSCeKrqutsQnf/fsa85CrS48mkIpfa2AtuZH4IcHDjzfg99e421 TZhfZvkDxrYx+dfXySz6FZpejwn0BcOqitbvnroFdmkD+ko0hrThH4a1S+I0xmzlEu 5x6d7sHLfLgjBSDlsS5t7koTx1ygSWKBs3m++5XzTFuqD+qMKX8nx9fC4MNjuWc4O8 R9hGl4OhnsdRg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3E53967922 for ; Wed, 3 Sep 2025 07:37:34 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756906651; bh=fTLvSVHCG1QBPoyhEJz/eZIA02dthi4Ac6YgPntpgsM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uiG3K9qKVctJUZkWhZJHQhd1lQbKDQqTmZGwCYL8cZZOe5U4aLVYDZOa0V/jDr1xN Nbgbvzr2gzpfWOISB5G3VUm4QkFKq7Kpv3uZ79NJAuB1bPCURXi5Nz6aOZ8qXdb4in YghWBiRqzKV6C2B3TpW80XylxQ532c19iOe7AitLkZk7o1clGAW4rhRwofRVayep4Q iXlQWLlF826T1G6FyB81VCcEzrQ2N95PKl0h6i2L+eJkbf41x3H0qvmt5pIwXZZxB4 /mCf57c8xzGFNdkLGonKh7lweP2P4Y64V/uWJ+H4W2J0dcpBZ4+QqZqiQq3WQSWHoP HskBstVyGYMbg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4265C5FE1B; Wed, 3 Sep 2025 07:37:31 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id SMwCALVXqF2c; Wed, 3 Sep 2025 07:37:31 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756906650; bh=cO3gHa72+hyb1X+jwtcPF6rc2P5NLyb6VmeD7VqOSic=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GPAf5yoqmLeg3/WIC7rGk9K7HxLdfHCKeOR+rlwxEIWoKCgo4QT8co1e7+6MyIDg6 Ii/ICIwXsowRWO0c7yjCKw3mFHq8CUTCbFknlVFBewJFF6VtNRC3EKLQiCklI4lDOp 4iDq0mEjvX3Zim0Hh4FJ/Y/Sbq0tXj9qbaceS3oFpPQnFNWp5AtXSTp3u/aa3iILAL 9IPAwQ2nOUSzkw9FnKXLxSzcClKGrBgwPeW0IalckLw+e59qhy1ujp9GIfB+mu6OHa kDQzsU4Bh8/ycx8mOq1PSoV4kw7UOaX6u0g+8uOexOMI9BNy5kOl88CaMGhbMHdb1G 8agxspcDpH3Og== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 7F6C1678B2; Wed, 3 Sep 2025 07:37:30 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 3 Sep 2025 07:36:14 -0600 Message-ID: <20250903133639.3235920-15-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250903133639.3235920-1-sjg@u-boot.org> References: <20250903133639.3235920-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: VHJ53IHWNBGVGLYM66DQY3CQ3BRUCYPI X-Message-ID-Hash: VHJ53IHWNBGVGLYM66DQY3CQ3BRUCYPI X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 14/25] chid: Provide a command to access chid features List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Provide a simple command which supports showing the information which goes into calculating a CHID. The information is obtained entirely from SMBIOS tables at present. Co-developed-by: Claude Signed-off-by: Simon Glass --- cmd/Kconfig | 10 +++++++ cmd/Makefile | 1 + cmd/chid.c | 43 +++++++++++++++++++++++++++ doc/usage/cmd/chid.rst | 67 ++++++++++++++++++++++++++++++++++++++++++ doc/usage/index.rst | 1 + test/cmd/Makefile | 1 + test/cmd/chid.c | 45 ++++++++++++++++++++++++++++ 7 files changed, 168 insertions(+) create mode 100644 cmd/chid.c create mode 100644 doc/usage/cmd/chid.rst create mode 100644 test/cmd/chid.c diff --git a/cmd/Kconfig b/cmd/Kconfig index 8126821ffdc..8037827930b 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -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" diff --git a/cmd/Makefile b/cmd/Makefile index bc381905729..75ef9fab922 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -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 diff --git a/cmd/chid.c b/cmd/chid.c new file mode 100644 index 00000000000..096f88e3c44 --- /dev/null +++ b/cmd/chid.c @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Command for Computer Hardware Identifiers (Windows CHID) + * + * Copyright 2025 Simon Glass + */ + +#include +#include +#include + +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)); diff --git a/doc/usage/cmd/chid.rst b/doc/usage/cmd/chid.rst new file mode 100644 index 00000000000..d24f213df0f --- /dev/null +++ b/doc/usage/cmd/chid.rst @@ -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 table information diff --git a/doc/usage/index.rst b/doc/usage/index.rst index 89341349d12..eeda632b1a0 100644 --- a/doc/usage/index.rst +++ b/doc/usage/index.rst @@ -49,6 +49,7 @@ Shell commands cmd/cbcmos cmd/cbsysinfo cmd/cedit + cmd/chid cmd/cli cmd/cls cmd/cmp diff --git a/test/cmd/Makefile b/test/cmd/Makefile index ec39bd46e76..5fe6ac7bb3e 100644 --- a/test/cmd/Makefile +++ b/test/cmd/Makefile @@ -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 diff --git a/test/cmd/chid.c b/test/cmd/chid.c new file mode 100644 index 00000000000..4b28db2abde --- /dev/null +++ b/test/cmd/chid.c @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Test for chid command + * + * Copyright 2025 Simon Glass + */ + +#include +#include +#include +#include +#include + +/* 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);