Grzegorz Bernacki has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/74266 )
Change subject: amdfwtool: Add --fsp-version option ......................................................................
amdfwtool: Add --fsp-version option
This version tells amdfwtool to create a text file which contains versions of following blobs: PSP bootloader (type 0x01), SMU firmware (type 0x08), AGESA bootloader 0 (type 0x30).
BUG=b:224780134 TEST=Tested on Skyrim device
Change-Id: Idaa3a02ace524f44cfa656e34308bd896016dff6 Signed-off-by: Grzegorz Bernacki bernacki@google.com --- M util/amdfwtool/amdfwtool.c M util/amdfwtool/amdfwtool.h 2 files changed, 68 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/66/74266/1
diff --git a/util/amdfwtool/amdfwtool.c b/util/amdfwtool/amdfwtool.c index 4d821bd..fba9ff2 100644 --- a/util/amdfwtool/amdfwtool.c +++ b/util/amdfwtool/amdfwtool.c @@ -211,6 +211,7 @@ printf("--sharedmem Location of PSP/FW shared memory\n"); printf("--sharedmem-size Maximum size of the PSP/FW shared memory\n"); printf(" area\n"); + printf("--fsp-version <FILE> Stores version of FSP blobs in the file\n"); printf("\nEmbedded Firmware Structure options used by the PSP:\n"); printf("--spi-speed <HEX_VAL> SPI fast speed to place in EFS Table\n"); printf(" 0x0 66.66Mhz\n"); @@ -842,6 +843,42 @@ } }
+static void dump_fsp_version(char *fsp_file, amd_fw_entry *fw_table) +{ + struct amd_fw_header hdr; + amd_fw_entry *index; + FILE *version_file; + int blob_fd; + + version_file = fopen(fsp_file, "w"); + if (version_file == NULL) { + fprintf(stderr, "Error: Creating fsp version file failed\n"); + return; + } + + for (index = fw_table; index->type != AMD_FW_INVALID; index++) { + if (!(index->filename)) + continue; + + switch (index->type) { + case AMD_FW_PSP_BOOTLOADER: + case AMD_FW_PSP_SMU_FIRMWARE: + case AMD_ABL0: + blob_fd = open(index->filename, O_RDONLY); + read(blob_fd, &hdr, sizeof(hdr)); + fprintf(version_file, "type: 0x%02x ver:%02x.%02x.%02x.%02x\n", + index->type, hdr.version[3], hdr.version[2], + hdr.version[1], hdr.version[0]); + close(blob_fd); + break; + default: + break; + } + } + + fclose(version_file); +} + /* For debugging */ static void dump_psp_firmwares(amd_fw_entry *fw_table) { @@ -1469,6 +1506,7 @@ AMDFW_OPT_SPL_TABLE, AMDFW_OPT_VERSTAGE, AMDFW_OPT_VERSTAGE_SIG, + AMDFW_OPT_FSP_VERSION_SIG,
AMDFW_OPT_INSTANCE, AMDFW_OPT_APCB, @@ -1526,6 +1564,7 @@ {"spl-table", required_argument, 0, AMDFW_OPT_SPL_TABLE }, {"verstage", required_argument, 0, AMDFW_OPT_VERSTAGE }, {"verstage_sig", required_argument, 0, AMDFW_OPT_VERSTAGE_SIG }, + {"fsp-version", required_argument, 0, AMDFW_OPT_FSP_VERSION_SIG }, /* BIOS Directory Table items */ {"instance", required_argument, 0, AMDFW_OPT_INSTANCE }, {"apcb", required_argument, 0, AMDFW_OPT_APCB }, @@ -1857,6 +1896,7 @@
amd_cb_config cb_config = { 0 }; int debug = 0; + char *fsp_file = NULL;
ctx.current_pointer_saved = 0xFFFFFFFF;
@@ -2003,6 +2043,9 @@ register_fw_filename(AMD_FW_VERSTAGE_SIG, sub, optarg); sub = instance = 0; break; + case AMDFW_OPT_FSP_VERSION_SIG: + fsp_file = optarg; + break; case AMDFW_OPT_SIGNED_OUTPUT: signed_output_file = optarg; sub = instance = 0; @@ -2099,6 +2142,9 @@
open_process_config(config, &cb_config, debug);
+ if (fsp_file) { + dump_fsp_version(fsp_file, amd_psp_fw_table); + } if (!fuse_defined) register_fw_fuse(DEFAULT_SOFT_FUSE_CHAIN);
diff --git a/util/amdfwtool/amdfwtool.h b/util/amdfwtool/amdfwtool.h index 03cc056..ee5f874 100644 --- a/util/amdfwtool/amdfwtool.h +++ b/util/amdfwtool/amdfwtool.h @@ -375,7 +375,9 @@ uint32_t comp_size; /* Starting MDN fw_id is populated instead of fw_type. */ uint16_t fw_id; - uint8_t reserved_5a[18]; + uint8_t reserved_5a[6]; + uint8_t version[4]; + uint8_t reserved_64[8]; uint32_t size_total; uint8_t reserved_70[12]; /* Starting MDN fw_id is populated instead of fw_type. fw_type will still be around