From f2e761abd1f05bd90e3c31a38bf4a601ec7fdbcd Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Mon, 9 Mar 2026 00:39:14 +0800 Subject: [PATCH] Fix flash_version() leaving SPI mux unlocked, turning LED pink flash_version() sent EC_CMD_FLASH_NOTIFIED with AccessSpi (0x00) to unlock the SPI flash but never sent AccessSpiDone (0x03) to restore it. On hx30 (12th Gen), GPIO_0056 is shared between the SPI flash clock (function 2) and the right-side green charging LED PWM (function 1). When AccessSpi is sent, the EC switches GPIO_0056 to SPI mode and disables the LED driver (GPIO_TYPEC_G_DRV2_EN). Without the matching AccessSpiDone, the green channel stays dead while red and blue continue normally, turning the white charging LED pink (R+B without G). Send AccessSpiDone after reading the version to restore the mux, matching the pattern used by test_ec_flash_read() and get_entire_ec_flash(). Signed-off-by: Daniel Schaefer --- framework_lib/src/chromium_ec/mod.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/framework_lib/src/chromium_ec/mod.rs b/framework_lib/src/chromium_ec/mod.rs index 94b8b93a..0a8514cc 100644 --- a/framework_lib/src/chromium_ec/mod.rs +++ b/framework_lib/src/chromium_ec/mod.rs @@ -335,11 +335,20 @@ impl CrosEc { pub fn flash_version(&self) -> Option<(String, String, EcCurrentImage)> { // Unlock SPI - // TODO: Lock flash again again - let _data = EcRequestFlashNotify { flags: 0 }.send_command(self).ok()?; + let _data = EcRequestFlashNotify { + flags: MecFlashNotify::AccessSpi as u8, + } + .send_command(self) + .ok()?; let v = EcRequestGetVersion {}.send_command(self).ok()?; + // Lock SPI + let _ = EcRequestFlashNotify { + flags: MecFlashNotify::AccessSpiDone as u8, + } + .send_command(self); + let curr = match v.current_image { 1 => EcCurrentImage::RO, 2 => EcCurrentImage::RW,