diff options
author | Edward O'Callaghan <quasisec@google.com> | 2023-04-05 11:03:10 +1000 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-04-13 10:05:41 +0000 |
commit | f28c9d7a5b2485b7346a19763aa4db004480d08d (patch) | |
tree | 38965a504f60ea493efeac41691afa02cfddfa77 /futility/cmd_flash_util.c | |
parent | 35f50c3154e58821cc027bf13be2b949bc4c90f3 (diff) | |
download | vboot-f28c9d7a5b2485b7346a19763aa4db004480d08d.tar.gz |
futility/: host/lib: Add flash chip info subcommand support
The AP RO verification tooling requires a understanding of the
underlying flashchip information. Provision support in the
flash subcommand to report back this data from the flashrom
driver.
BUG=b:276981092
BRANCH=none
TEST=on Nissa ```
localhost ~ # futility flash --flash-i{nfo}
Warning: Setting BIOS Control at 0xdc from 0x8b to 0x89 failed.
New value is 0x8b.
Flash vendor: Winbond
Flash name: W25Q256JV_M
Flash vid-pid: 0xef00007019
Flash size: 0x02000000
```.
Cq-Depend: chromium:4401775, chromium:4401776
Change-Id: I58e818f06def4904693f61c6967d70b16c62fa37
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4402370
Auto-Submit: Edward O'Callaghan <quasisec@chromium.org>
Tested-by: Edward O'Callaghan <quasisec@chromium.org>
Commit-Queue: Jakub Czapiga <czapiga@google.com>
Reviewed-by: Nikolai Artemiev <nartemiev@google.com>
Diffstat (limited to 'futility/cmd_flash_util.c')
-rw-r--r-- | futility/cmd_flash_util.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/futility/cmd_flash_util.c b/futility/cmd_flash_util.c index 783a595e..41554597 100644 --- a/futility/cmd_flash_util.c +++ b/futility/cmd_flash_util.c @@ -7,6 +7,7 @@ #include <stdio.h> #include <stdlib.h> #include <getopt.h> +#include <inttypes.h> #include "fmap.h" #include "futility.h" @@ -27,6 +28,32 @@ static int print_flash_size(struct updater_config *cfg) return 0; } +static int print_flash_info(struct updater_config *cfg) +{ + char *vendor; + char *name; + uint32_t vid; + uint32_t pid; + uint32_t flash_size; + if (flashrom_get_info(cfg->image.programmer, + &vendor, &name, + &vid, &pid, + &flash_size, + cfg->verbosity + 1)) { + ERROR("%s failed.\n", __func__); + return -1; + } + + printf("Flash vendor: %s\n", vendor); + free(vendor); + printf("Flash name: %s\n", name); + free(name); + const uint64_t vidpid = (uint64_t) vid << 32 | pid; + printf("Flash vid-pid: 0x%" PRIx64 "\n", vidpid); + printf("Flash size: %#010x\n", flash_size); + return 0; +} + static int get_ro_range(struct updater_config *cfg, uint32_t *start, uint32_t *len) { @@ -118,6 +145,7 @@ static struct option const long_opts[] = { {"wp-status", 0, NULL, 's'}, {"wp-enable", 0, NULL, 'e'}, {"wp-disable", 0, NULL, 'd'}, + {"flash-info", 0, NULL, 'i'}, {"flash-size", 0, NULL, 'z'}, {NULL, 0, NULL, 0}, }; @@ -135,6 +163,7 @@ static void print_help(int argc, char *argv[]) " --wp-enable \tEnable protection for the RO image section.\n" " --wp-disable \tDisable all write protection.\n" " --flash-size \tGet flash size.\n" + " --flash-info \tGet flash info.\n" "\n" SHARED_FLASH_ARGS_HELP, argv[0]); @@ -150,6 +179,7 @@ static int do_flash(int argc, char *argv[]) bool disable_wp = false; bool get_wp_status = false; bool get_size = false; + bool get_info = false; struct updater_config *cfg = updater_new_config(); assert(cfg); @@ -172,6 +202,9 @@ static int do_flash(int argc, char *argv[]) case 'd': disable_wp = true; break; + case 'i': + get_info = true; + break; case 'z': get_size = true; break; @@ -198,7 +231,7 @@ static int do_flash(int argc, char *argv[]) ERROR("Unexpected arguments.\n"); } - if (!get_size && !enable_wp && !disable_wp && !get_wp_status) { + if (!get_size && !get_info && !enable_wp && !disable_wp && !get_wp_status) { print_help(argc, argv); goto out_free; } @@ -225,6 +258,9 @@ static int do_flash(int argc, char *argv[]) ret = updater_setup_config(cfg, &args, &update_needed); prepare_servo_control(prepare_ctrl_name, 1); + if (!ret && get_info) + ret = print_flash_info(cfg); + if (!ret && get_size) ret = print_flash_size(cfg); |