Skip to content

Commit f8a80ad

Browse files
committed
capsule: Fix EC version detection for Zephyr based
Now it can work for both legacy and zephyr based ECs. Tested on Intel 12th gen, AMD Ryzen 7040, AMD Ryzen AI 300, Framework Desktop. ``` > framework_tool --h2o-capsule Framework_Laptop_13_Ryzen7040_capsule_signed_allsku_3.08.cap [...] EC Type: RO Version: azalea_v3.4.113382-ec:ec916d,os RollbackVer: 0 Platform: azalea Version: 3.4.113382 Commit: ec916d Size: 258048 B Size: 252 KB EC Type: RW Version: azalea_v3.4.113382-ec:ec916d,os RollbackVer: 0 Platform: azalea Version: 3.4.113382 Commit: ec916d Size: 258048 B Size: 252 KB [...] ``` Signed-off-by: Daniel Schaefer <dhs@frame.work>
1 parent 721a938 commit f8a80ad

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

framework_lib/src/capsule_content.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,10 @@ pub fn find_bios_version(data: &[u8]) -> Option<BiosCapsule> {
4444
}
4545

4646
pub fn find_ec_in_bios_cap(data: &[u8]) -> Option<&[u8]> {
47-
let needle = b"_IFLASH_EC_IMG_";
48-
let found_iflash = util::find_sequence(data, needle)?;
49-
// The actual EC binary is a few bytes after `_IFLASH_EC_IMG_`.
50-
// Just earch for the first 4 bytes that seem to appear in all EC images.
51-
let found = util::find_sequence(&data[found_iflash..], &[0x10, 0x00, 0x00, 0xf7])?;
52-
Some(&data[found_iflash + found..found_iflash + found + EC_LEN])
47+
let needle = b"$_IFLASH_EC_IMG_";
48+
let found = util::find_sequence(data, needle)?;
49+
let ec_offset = found + 0x9 + needle.len() - 1;
50+
Some(&data[ec_offset..ec_offset + EC_LEN])
5351
}
5452

5553
pub fn find_pd_in_bios_cap(data: &[u8]) -> Option<&[u8]> {

0 commit comments

Comments
 (0)