Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions framework_lib/src/chromium_ec/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ pub enum EcCommands {
GetPdPortState = 0x3E23,
/// Read board ID of specific ADC channel
ReadBoardId = 0x3E26,
/// Move the STM32 keyboard controller into its ROM bootloader and back
KbdFlashStm32 = 0x3E2C,
}

pub trait EcRequest<R> {
Expand Down
29 changes: 29 additions & 0 deletions framework_lib/src/chromium_ec/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1999,3 +1999,32 @@ impl EcRequest<EcResponseGetApThrottleStatus> for EcRequestGetApThrottleStatus {
EcCommands::GetApThrottleStatus
}
}

/// Sub-commands of `EcCommands::KbdFlashStm32`.
///
/// The EC only drives BOOT0 and the power rail and keeps its own I2C-HID
/// driver off the bus. The bootloader protocol itself runs on the host over
/// I2C passthrough.
/// 1-3 were erase/write/read on the EC and have been removed.
#[repr(u8)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum KbdFlashStm32Subcmd {
/// Reset the STM32 into its ROM bootloader
Enter = 0,
/// Reset the STM32 into its application
Exit = 4,
}

#[repr(C, packed)]
pub struct EcRequestKbdFlashStm32 {
/// See KbdFlashStm32Subcmd
pub subcmd: u8,
}

/// No response on current EC firmware. EC firmware that still had the
/// flashing code returns 5 bytes for Enter, use send_command_vec and ignore them.
impl EcRequest<()> for EcRequestKbdFlashStm32 {
fn command_id() -> EcCommands {
EcCommands::KbdFlashStm32
}
}
Loading