Skip to content

Commit de8e059

Browse files
committed
tgl: Fix PD controller version
On TGL we modified the base version, not the app version. `-version` would show the incorrect version. `--pd-info` shows both. ``` FS1:\> framework_tool.efi --versions UEFI BIOS Version: 03.19 Release Date: 05/29/2023 EC Firmware Build version: "hx20_v0.0.1-f6d6b92 2023-05-26 00:03:59 runner@fv-az504-734" RO Version: "hx20_v0.0.1-f6d6b92" RW Version: "hx20_v0.0.1-f6d6b92" Current image: RO PD Controllers Right (01) Main: 3.4.0.2575 (Active) Backup: 3.4.0.2575 Left (23) Main: 3.4.0.2575 (Active) Backup: 3.4.0.2575 Retimers Left: 0xCF (207) Right: 0xCF (207) ``` Signed-off-by: Daniel Schaefer <[email protected]>
1 parent 2e30627 commit de8e059

File tree

4 files changed

+67
-25
lines changed

4 files changed

+67
-25
lines changed

framework_lib/src/ccgx/device.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,9 @@ impl PdController {
283283
Ok((fw_mode, flash_row_size))
284284
}
285285
pub fn get_fw_versions(&self) -> EcResult<ControllerFirmwares> {
286+
let (active_fw, _row_size) = self.get_device_info()?;
286287
Ok(ControllerFirmwares {
288+
active_fw,
287289
bootloader: self.get_single_fw_ver(FwMode::BootLoader)?,
288290
backup_fw: self.get_single_fw_ver(FwMode::BackupFw)?,
289291
main_fw: self.get_single_fw_ver(FwMode::MainFw)?,

framework_lib/src/ccgx/mod.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::fmt;
77

88
use crate::chromium_ec::{CrosEc, EcResult};
99

10-
use self::device::{PdController, PdPort};
10+
use self::device::{FwMode, PdController, PdPort};
1111

1212
pub mod binary;
1313
pub mod device;
@@ -159,11 +159,7 @@ pub struct AppVersion {
159159

160160
impl fmt::Display for AppVersion {
161161
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
162-
write!(
163-
f,
164-
"{}.{}.{:0>2} ({:?})",
165-
self.major, self.minor, self.circuit, self.application
166-
)
162+
write!(f, "{}.{}.{:0>2}", self.major, self.minor, self.circuit)
167163
}
168164
}
169165

@@ -197,6 +193,7 @@ pub struct ControllerVersion {
197193

198194
#[derive(Debug, PartialEq)]
199195
pub struct ControllerFirmwares {
196+
pub active_fw: FwMode,
200197
pub bootloader: ControllerVersion,
201198
pub backup_fw: ControllerVersion,
202199
pub main_fw: ControllerVersion,

framework_lib/src/commandline/mod.rs

Lines changed: 61 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use crate::capsule;
2626
use crate::capsule_content::{
2727
find_bios_version, find_ec_in_bios_cap, find_pd_in_bios_cap, find_retimer_version,
2828
};
29-
use crate::ccgx::device::{PdController, PdPort};
29+
use crate::ccgx::device::{FwMode, PdController, PdPort};
3030
#[cfg(feature = "hidapi")]
3131
use crate::ccgx::hid::{check_ccg_fw_version, find_devices, DP_CARD_PID, HDMI_CARD_PID};
3232
use crate::ccgx::{self, SiliconId::*};
@@ -47,7 +47,7 @@ use crate::smbios::{dmidecode_string_val, get_smbios, is_framework};
4747
#[cfg(feature = "uefi")]
4848
use crate::uefi::enable_page_break;
4949
use crate::util;
50-
use crate::util::Config;
50+
use crate::util::{Config, Platform};
5151
#[cfg(feature = "hidapi")]
5252
use hidapi::HidApi;
5353
use sha2::{Digest, Sha256, Sha384, Sha512};
@@ -289,6 +289,14 @@ fn flash_dp_hdmi_card(pd_bin_path: &str) {
289289
}
290290
}
291291

292+
fn active_mode(mode: &FwMode, reference: FwMode) -> &'static str {
293+
if mode == &reference {
294+
" (Active)"
295+
} else {
296+
""
297+
}
298+
}
299+
292300
fn print_versions(ec: &CrosEc) {
293301
println!("UEFI BIOS");
294302
if let Some(smbios) = get_smbios() {
@@ -322,24 +330,57 @@ fn print_versions(ec: &CrosEc) {
322330
println!("PD Controllers");
323331

324332
if let Ok(pd_versions) = ccgx::get_pd_controller_versions(ec) {
333+
let right = &pd_versions.controller01;
334+
let left = &pd_versions.controller23;
325335
println!(" Right (01)");
326-
println!(
327-
" Main App: {}",
328-
pd_versions.controller01.main_fw.app
329-
);
330-
println!(
331-
" Backup App: {}",
332-
pd_versions.controller01.backup_fw.app
333-
);
336+
// let active_mode =
337+
if let Some(Platform::IntelGen11) = smbios::get_platform() {
338+
println!(
339+
" Main: {}{}",
340+
right.main_fw.base,
341+
active_mode(&right.active_fw, FwMode::MainFw)
342+
);
343+
println!(
344+
" Backup: {}{}",
345+
right.backup_fw.base,
346+
active_mode(&right.active_fw, FwMode::BackupFw)
347+
);
348+
} else {
349+
println!(
350+
" Main: {}{}",
351+
right.main_fw.app,
352+
active_mode(&right.active_fw, FwMode::MainFw)
353+
);
354+
println!(
355+
" Backup: {}{}",
356+
right.backup_fw.app,
357+
active_mode(&right.active_fw, FwMode::BackupFw)
358+
);
359+
}
334360
println!(" Left (23)");
335-
println!(
336-
" Main App: {}",
337-
pd_versions.controller23.main_fw.app
338-
);
339-
println!(
340-
" Backup App: {}",
341-
pd_versions.controller23.backup_fw.app
342-
);
361+
if let Some(Platform::IntelGen11) = smbios::get_platform() {
362+
println!(
363+
" Main: {}{}",
364+
left.main_fw.base,
365+
active_mode(&left.active_fw, FwMode::MainFw)
366+
);
367+
println!(
368+
" Backup: {}{}",
369+
left.backup_fw.base,
370+
active_mode(&left.active_fw, FwMode::BackupFw)
371+
);
372+
} else {
373+
println!(
374+
" Main: {}{}",
375+
left.main_fw.app,
376+
active_mode(&left.active_fw, FwMode::MainFw)
377+
);
378+
println!(
379+
" Backup: {}{}",
380+
left.backup_fw.app,
381+
active_mode(&left.active_fw, FwMode::BackupFw)
382+
);
383+
}
343384
} else if let Ok(pd_versions) = power::read_pd_version(ec) {
344385
// As fallback try to get it from the EC. But not all EC versions have this command
345386
println!(" Right (01): {}", pd_versions.controller01.app);
@@ -486,7 +527,7 @@ pub fn run_with_args(args: &Cli, _allupdate: bool) -> i32 {
486527

487528
// Must be run before any application code to set the config
488529
if args.pd_addrs.is_some() && args.pd_ports.is_some() && args.has_mec.is_some() {
489-
let platform = util::Platform::GenericFramework(
530+
let platform = Platform::GenericFramework(
490531
args.pd_addrs.unwrap(),
491532
args.pd_ports.unwrap(),
492533
args.has_mec.unwrap(),
@@ -898,6 +939,7 @@ fn selftest(ec: &CrosEc) -> Option<()> {
898939
println!(" Getting AC info from EC");
899940
// All our laptops have at least 4 PD ports so far
900941
if power::get_pd_info(ec, 4).iter().any(|x| x.is_err()) {
942+
println!(" Failed to get PD Info from EC");
901943
return None;
902944
}
903945

framework_lib/src/power.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,7 @@ fn parse_pd_ver(data: &[u8; 8]) -> ControllerVersion {
582582
}
583583

584584
// NOTE: Only works on ADL at the moment!
585+
// TODO: Not on TGL, need to check if RPL and later have it.
585586
pub fn read_pd_version(ec: &CrosEc) -> EcResult<MainPdVersions> {
586587
let info = EcRequestReadPdVersion {}.send_command(ec)?;
587588

0 commit comments

Comments
 (0)