Patrick Rudolph has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/35484 )
Change subject: util/smc: Add and use new tool smcbiosinfo ......................................................................
util/smc: Add and use new tool smcbiosinfo
The BMC and tools interacting with it depend on metadata placed inside the ROM in order the flash the BIOS.
Add a new tool smcbiosinfo, integrate it into the build system, and generate a 128byte metadata file called smcbiosinfo.bin on build.
You need to provide the BoardID for every SMC mainboard through a new Kconfig symbol: SUPERMICRO_BOARDID
Some fields are unknown, but it's sufficient to flash it using SMC vendor tools.
Tested on Supermicro X11SSH: * Flashing using the WebUI works * Flashing using SMCIPMITool works
No further validation is done on the firmware.
Change-Id: Id608c2ce78614b45a2fd0b26d97d666f02223998 Signed-off-by: Patrick Rudolph patrick.rudolph@9elements.com --- M src/mainboard/supermicro/x11ssh/Kconfig M src/vendorcode/Makefile.inc A src/vendorcode/smc/Makefile.inc A util/smc/smcbiosinfo/Makefile A util/smc/smcbiosinfo/description.md A util/smc/smcbiosinfo/smcbiosinfo.c 6 files changed, 237 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/84/35484/1
diff --git a/src/mainboard/supermicro/x11ssh/Kconfig b/src/mainboard/supermicro/x11ssh/Kconfig index e6f342d..8ee47b8 100644 --- a/src/mainboard/supermicro/x11ssh/Kconfig +++ b/src/mainboard/supermicro/x11ssh/Kconfig @@ -76,4 +76,8 @@ int default 512
+config SUPERMICRO_BOARDID + string + default "089C" + endif # BOARD_SUPERMICRO_BASEBOARD_X11SSH diff --git a/src/vendorcode/Makefile.inc b/src/vendorcode/Makefile.inc index 8ccb0d0..d79fb0b 100644 --- a/src/vendorcode/Makefile.inc +++ b/src/vendorcode/Makefile.inc @@ -4,3 +4,4 @@ subdirs-y += siemens subdirs-y += cavium subdirs-y += eltan +subdirs-y += smc diff --git a/src/vendorcode/smc/Makefile.inc b/src/vendorcode/smc/Makefile.inc new file mode 100644 index 0000000..f1ac3a6 --- /dev/null +++ b/src/vendorcode/smc/Makefile.inc @@ -0,0 +1,19 @@ +ifeq ($(CONFIG_VENDOR_SUPERMICRO),y) +ifneq ($(CONFIG_SUPERMICRO_BOARDID), "") + +SMCBIOSINFOTOOL:=util/smc/smcbiosinfo/smcbiosinfo +cbfs-files-y += smcbiosinfo.bin + +smcbiosinfo.bin-file := $(obj)/mainboard/$(MAINBOARDDIR)/smcbiosinfo.bin +smcbiosinfo.bin-type := raw +smcbiosinfo.bin-compression := none + +$(SMCBIOSINFOTOOL): util/smc/smcbiosinfo/smcbiosinfo.c + printf " MAKE Creating SMCBIOSINFO tool\n" + $(MAKE) -C util/smc/smcbiosinfo + +$(obj)/mainboard/$(MAINBOARDDIR)/smcbiosinfo.bin: util/smc/smcbiosinfo/smcbiosinfo + printf " TOOL Creating SMC BIOSINFO metadata\n" + $(SMCBIOSINFOTOOL) -b $(CONFIG_SUPERMICRO_BOARDID) -o $(top)/$@ +endif +endif diff --git a/util/smc/smcbiosinfo/Makefile b/util/smc/smcbiosinfo/Makefile new file mode 100644 index 0000000..a0901bb --- /dev/null +++ b/util/smc/smcbiosinfo/Makefile @@ -0,0 +1,9 @@ +HOSTCC ?= cc + +smcbiosinfo: smcbiosinfo.c + $(HOSTCC) smcbiosinfo.c -I$(top)/$(obj)/ -o smcbiosinfo + +all: smcbiosinfo + +clean: + @rm -f smcbiosinfo diff --git a/util/smc/smcbiosinfo/description.md b/util/smc/smcbiosinfo/description.md new file mode 100644 index 0000000..21170eb --- /dev/null +++ b/util/smc/smcbiosinfo/description.md @@ -0,0 +1 @@ +Generates SMC biosinfo for BMC BIOS updates `C` diff --git a/util/smc/smcbiosinfo/smcbiosinfo.c b/util/smc/smcbiosinfo/smcbiosinfo.c new file mode 100644 index 0000000..a892b19 --- /dev/null +++ b/util/smc/smcbiosinfo/smcbiosinfo.c @@ -0,0 +1,203 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2019 9elements Agency GmbH patrick.rudolph@9elements.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <stdint.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <getopt.h> +#include <errno.h> +#include <stdarg.h> +#include "build.h" + +/* Place the following struct somewhere in the ROM: */ +struct SMC_BIOS_Update { + uint32_t magic0; // always 0xaa00b1ed + char magic1[4]; // always $FID + uint16_t magic2; // always 0x7804 + uint8_t space0; // always zero + // SMCinfotool doesn't care for the first letter + // The BMC webinterface does + char boardid[9]; // "100000000" + uint8_t space1[15]; // unknown data + uint8_t space2; // always 0x1f + char ukn_majorVer[2]; + uint8_t space3; // always zero + char ukn_minorVer[2]; + uint8_t space4; // always zero + char majorVer[3]; + char minorVer[2]; + uint8_t space5; // always zero + uint16_t year; + uint8_t month; + uint8_t day; + uint32_t space6; // unknown data + uint8_t space7; // all ones + char str[15]; // "SUPERMSMCI--MB1" + uint8_t space8[3]; // always zero + uint64_t space9[6]; // all ones +} __packed; + +// Unused values: CDEPqR +static const char *optstring = "o:b:h"; + +static struct option long_options[] = { + {"output", required_argument, 0, 'o' }, + {"boardid", required_argument, 0, 'b' }, + {"help", no_argument, 0, 'h' }, +}; + +static void usage(void) +{ + printf("smcbiosinfo: Create BIOSInfo for BMC BIOS updates\n"); + printf("Usage: smcbiosinfo [options] -b <boardid> -o <filename>\n"); + printf("-o | --output <FILE> The file to generate\n"); + printf("-b | --boardid <id> The board ID\n"); + printf("-h | --help Print this help\n"); +} + +static int bcd2int(int hex) +{ + return ((hex & 0xF0) >> 4) * 10 + (hex & 0x0F); +} + +int main(int argc, char **argv) +{ + int c; + int ret = 0; + char *boardid = NULL; + char *filename = NULL; + + while (1) { + int optindex = 0; + + c = getopt_long(argc, argv, optstring, long_options, &optindex); + + if (c == -1) + break; + + switch (c) { + case 'o': + filename = strdup(optarg); + break; + case 'b': + boardid = strdup(optarg); + break; + case 'h': + usage(); + goto out; + default: + break; + } + } + if (!filename) { + fprintf(stderr, "E: Must specify a destination filename\n"); + ret = 1; + goto out; + } + + if (!boardid) { + fprintf(stderr, "E: Must specify a board ID\n"); + ret = 1; + goto out; + } else if (strlen(boardid) > 8) { + fprintf(stderr, "E: Board ID must be less than 8 characters\n"); + ret = 1; + goto out; + } + + // generate the table + + struct SMC_BIOS_Update sbu = { + 0xaa00b1ed, + "$FID", + 0x7804, + 0, // space + "100000000", //boardid + {}, // unknown data + 0x1f, // space + "05", + 0, // zero + "06", + 0, // zero + "000", // major, MSB first + "00", // minor + 0, // zero + bcd2int(COREBOOT_BUILD_YEAR_BCD) + 2000, // year + bcd2int(COREBOOT_BUILD_MONTH_BCD), // month + bcd2int(COREBOOT_BUILD_DAY_BCD), //day + 0, // zero + 0xff, // space + "SUPERMSMCI--MB1", + {0, 0, 0}, // all zero + {~0, ~0, ~0, ~0, ~0, ~0}, // all ones + }; + + if (COREBOOT_MAJOR_VERSION < 999) { + char tmp[4]; + snprintf(tmp, sizeof(tmp), "%03d", COREBOOT_MAJOR_VERSION); + memcpy(&sbu.majorVer, &tmp, sizeof(sbu.majorVer)); + } else { + fprintf(stderr, "E: Unsupported coreboot major version\n"); + ret = 1; + goto out; + } + + if (COREBOOT_MINOR_VERSION < 99) { + char tmp[3]; + snprintf(tmp, sizeof(tmp), "%02d", COREBOOT_MINOR_VERSION); + memcpy(&sbu.minorVer, &tmp, sizeof(sbu.minorVer)); + } else { + fprintf(stderr, "E: Unsupported coreboot minor version\n"); + ret = 1; + goto out; + } + memcpy(&sbu.boardid[1], boardid, strlen(boardid)); + + // write the table + + FILE *fd = fopen(filename, "wb"); + + if (!fd) { + fprintf(stderr, "%s open failed: %s\n", filename, strerror(errno)); + ret = 1; + goto out; + } + + if (fwrite(&sbu, 1, sizeof(sbu), fd) != sizeof(sbu)) { + fprintf(stderr, "%s write failed: %s\n", filename, strerror(errno)); + fclose(fd); + ret = 1; + goto out; + } + + if (fclose(fd)) { + fprintf(stderr, "%s close failed: %s\n", filename, strerror(errno)); + ret = 1; + goto out; + } + +out: + if (boardid) + free(boardid); + if (filename) + free(filename); + + return ret; +}