From 6c1b0acc4ccf4c1fa99b6a0a58fe1a7eb804ce59 Mon Sep 17 00:00:00 2001 From: Evan Benn Date: Fri, 5 Aug 2022 14:17:00 +1000 Subject: 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 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/flashrom/+/3812722 Tested-by: Edward O'Callaghan Reviewed-by: Edward O'Callaghan Reviewed-on: https://review.coreboot.org/c/flashrom/+/66588 Tested-by: build bot (Jenkins) Reviewed-by: Angel Pons --- util/flashrom_tester/flashrom/src/cmd.rs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'util/flashrom_tester') diff --git a/util/flashrom_tester/flashrom/src/cmd.rs b/util/flashrom_tester/flashrom/src/cmd.rs index b5aacf486..1fbb9444f 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 - pub write: Option<&'a str>, // -w - pub verify: Option<&'a str>, // -v - pub erase: bool, // -E - pub region: Option<&'a str>, // --image + pub read: Option<&'a str>, // -r + pub write: Option<&'a str>, // -w + pub verify: Option<&'a str>, // -v + 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 { } // 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() { -- cgit v1.2.3