Skip to content

Commit 3ad09a7

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. Signed-off-by: Daniel Schaefer <[email protected]>
1 parent 3a96295 commit 3ad09a7

File tree

1 file changed

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

1 file changed

+20
-1
lines changed

framework_lib/src/chromium_ec/mod.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,26 @@ 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_off = 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+
EcRequestFlashErase {
848+
cur_offset,
849+
cur_size,
850+
}
851+
.send_command(self)?;
852+
cur_offset += chunk_size;
853+
}
854+
Ok(())
836855
}
837856

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

0 commit comments

Comments
 (0)