Skip to content

Commit 0a6f8a7

Browse files
committed
chromium_ec: Erase EC in sections
Erasing a big section takes too long sometimes and the linux kernel driver times out, so split it up into chunks. One chunk is 1/8 of EC ROM size. Found while flashing RW on lotus: `framework_tool --flash-rw-ec ec.bin` Signed-off-by: Daniel Schaefer <[email protected]>
1 parent 3a96295 commit 0a6f8a7

File tree

1 file changed

+24
-1
lines changed
  • framework_lib/src/chromium_ec

1 file changed

+24
-1
lines changed

framework_lib/src/chromium_ec/mod.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,30 @@ impl CrosEc {
832832
}
833833

834834
fn erase_ec_flash(&self, offset: u32, size: u32) -> EcResult<()> {
835-
EcRequestFlashErase { offset, size }.send_command(self)
835+
// Erasing a big section takes too long sometimes and the linux kernel driver times out, so
836+
// split it up into chunks. One chunk is 1/8 of EC ROM size.
837+
let chunk_size = 0x10000;
838+
let mut cur_offset = offset;
839+
840+
while cur_offset < offset + size {
841+
let rem_size = offset + size - cur_offset;
842+
let cur_size = if rem_size < chunk_size {
843+
rem_size
844+
} else {
845+
chunk_size
846+
};
847+
debug!(
848+
"EcRequestFlashErase (0x{:05X}, 0x{:05X})",
849+
cur_offset, cur_size
850+
);
851+
EcRequestFlashErase {
852+
offset: cur_offset,
853+
size: cur_size,
854+
}
855+
.send_command(self)?;
856+
cur_offset += chunk_size;
857+
}
858+
Ok(())
836859
}
837860

838861
pub fn flash_notify(&self, flag: MecFlashNotify) -> EcResult<()> {

0 commit comments

Comments
 (0)