diff options
author | Evan Benn <evanbenn@chromium.org> | 2022-08-05 14:17:00 +1000 |
---|---|---|
committer | Edward O'Callaghan <quasisec@chromium.org> | 2022-08-18 03:50:40 +0000 |
commit | 6c1b0acc4ccf4c1fa99b6a0a58fe1a7eb804ce59 (patch) | |
tree | ee9c553407addf8c98f5dcc69dea3d28849dff95 | |
parent | 41d0de0ad81e98fe9e9500bd71e6c0bfbef1b5b9 (diff) | |
download | flashrom-6c1b0acc4ccf4c1fa99b6a0a58fe1a7eb804ce59.tar.gz flashrom-6c1b0acc4ccf4c1fa99b6a0a58fe1a7eb804ce59.tar.bz2 flashrom-6c1b0acc4ccf4c1fa99b6a0a58fe1a7eb804ce59.zip |
flashrom_tester: Fix cmd read_region to read only the region
read_region for the CLI implementation was writing a file the size of
the whole flash, with only the region filled with real data. Now write
only the region to the file. This fixes the Coreboot_ELOG_sanity test
which regressed in 4342cc0f14e2945d7642e75e44346c13ca23089b.
BUG=b:241486407
BRANCH=None
TEST=flashrom_tester /usr/sbin/flashrom host Coreboot_ELOG_sanity
Change-Id: I97ff8c71861f1d0282a7d6173e196e3d0b41d746
Signed-off-by: Evan Benn <evanbenn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/flashrom/+/3812722
Tested-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66588
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
-rw-r--r-- | util/flashrom_tester/flashrom/src/cmd.rs | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/util/flashrom_tester/flashrom/src/cmd.rs b/util/flashrom_tester/flashrom/src/cmd.rs index b5aacf48..1fbb9444 100644 --- a/util/flashrom_tester/flashrom/src/cmd.rs +++ b/util/flashrom_tester/flashrom/src/cmd.rs @@ -60,11 +60,11 @@ pub struct WPOpt { #[derive(Default)] pub struct IOOpt<'a> { - pub read: Option<&'a str>, // -r <file> - pub write: Option<&'a str>, // -w <file> - pub verify: Option<&'a str>, // -v <file> - pub erase: bool, // -E - pub region: Option<&'a str>, // --image + pub read: Option<&'a str>, // -r <file> + pub write: Option<&'a str>, // -w <file> + pub verify: Option<&'a str>, // -v <file> + pub erase: bool, // -E + pub region: Option<(&'a str, &'a str)>, // --image } #[derive(PartialEq, Debug)] @@ -243,8 +243,7 @@ impl crate::Flashrom for FlashromCmd { fn read_region(&self, path: &str, region: &str) -> Result<(), FlashromError> { let opts = FlashromOpt { io_opt: IOOpt { - read: Some(path), - region: Some(region), + region: Some((region, path)), ..Default::default() }, ..Default::default() @@ -322,11 +321,11 @@ fn flashrom_decode_opts(opts: FlashromOpt) -> Vec<String> { } // io_opt - if let Some(region) = opts.io_opt.region { + if let Some((region, path)) = opts.io_opt.region { params.push("--image".to_string()); - params.push(region.to_string()); - } - if opts.io_opt.read.is_some() { + params.push(format!("{}:{}", region, path)); + params.push("-r".to_string()); + } else if opts.io_opt.read.is_some() { params.push("-r".to_string()); params.push(opts.io_opt.read.unwrap().to_string()); } else if opts.io_opt.write.is_some() { |