Skip to content

Commit 9a1d630

Browse files
Merge pull request #146 from FrameworkComputer/version-cleanup
Cleanup --versions command to hide unnecessary details
2 parents f584a2b + 46114f9 commit 9a1d630

File tree

5 files changed

+143
-75
lines changed

5 files changed

+143
-75
lines changed

EXAMPLES.md

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,11 @@ UEFI BIOS
1515
Version: 03.00
1616
Release Date: 03/10/2025
1717
EC Firmware
18-
Build version: "lilac-3.0.0-1541dc6 2025-05-05 11:31:24 zoid@localhost"
19-
RO Version: "lilac-3.0.0-1541dc6"
20-
RW Version: "lilac-3.0.0-1541dc6"
18+
Build version: lilac-3.0.0-1541dc6 2025-05-05 11:31:24 zoid@localhost
2119
Current image: RO
2220
PD Controllers
23-
Right (01)
24-
Main: 0.0.0E (Active)
25-
Backup: 0.0.0E
26-
Left (23)
27-
Main: 0.0.0E (Active)
28-
Backup: 0.0.0E
21+
Right (01): 0.0.0E (MainFw)
22+
Left (23): 0.0.0E (MainFw)
2923
[...]
3024
```
3125

@@ -56,8 +50,7 @@ Laptop Webcam Module (2nd Gen)
5650
[...]
5751
Touchscreen
5852
Firmware Version: v7.0.0.5.0.0.0.0
59-
USI Protocol: false
60-
MPP Protocol: true
53+
Protocols: USI
6154
```
6255

6356
### Stylus (Framework 12)
@@ -79,7 +72,6 @@ Stylus
7972
> framework_tool --versions
8073
[...]
8174
Touchpad
82-
IC Type: 0239
8375
Firmware Version: v0E07
8476
```
8577

@@ -114,6 +106,35 @@ LED Matrix
114106
[...]
115107
```
116108

109+
### DisplayPort or HDMI Expansion Card
110+
111+
```
112+
> framework_tool --dp-hdmi-info
113+
DisplayPort Expansion Card
114+
Serial Number: 11AD1D0030123F17142C0B00
115+
Active Firmware: 101 (3.0.11.065)
116+
Inactive Firmware: 008 (3.0.11.008)
117+
Operating Mode: MainFw (#2)
118+
119+
# Or
120+
> framework_tool --versions
121+
[...]
122+
DisplayPort Expansion Card
123+
Active Firmware: 101 (3.0.11.065)
124+
Inactive Firmware: 008 (3.0.11.008)
125+
Operating Mode: MainFw (#2)
126+
```
127+
128+
### CSME Version (Linux on Intel systems)
129+
130+
```
131+
> framework_tool --versions
132+
[...]
133+
CSME
134+
Firmware Version: 0:16.1.32.2473
135+
[...]
136+
```
137+
117138
## Check input deck status
118139

119140
### On Framework 12

framework_lib/src/ccgx/hid.rs

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,10 @@ fn get_fw_info(device: &HidDevice) -> HidFirmwareInfo {
132132
decode_fw_info(&buf)
133133
}
134134

135-
pub fn check_ccg_fw_version(device: &HidDevice) {
135+
pub fn check_ccg_fw_version(device: &HidDevice, verbose: bool) {
136136
magic_unlock(device);
137137
let info = get_fw_info(device);
138-
print_fw_info(&info);
138+
print_fw_info(&info, verbose);
139139
}
140140

141141
fn decode_fw_info(buf: &[u8]) -> HidFirmwareInfo {
@@ -152,13 +152,13 @@ fn decode_fw_info(buf: &[u8]) -> HidFirmwareInfo {
152152
info
153153
}
154154

155-
fn print_fw_info(info: &HidFirmwareInfo) {
155+
fn print_fw_info(info: &HidFirmwareInfo, verbose: bool) {
156156
assert_eq!(info.report_id, ReportIdCmd::E0Read as u8);
157157

158158
info!(" Signature: {:X?}", info.signature);
159159
// Something's totally off if the signature is invalid
160160
if info.signature != [b'C', b'Y'] {
161-
println!("Firmware Signature is invalid.");
161+
error!("Firmware Signature is invalid.");
162162
return;
163163
}
164164

@@ -219,23 +219,33 @@ fn print_fw_info(info: &HidFirmwareInfo) {
219219
FwMode::BackupFw => (base_version_1, image_1_valid, base_version_2, image_2_valid),
220220
};
221221

222-
println!(
223-
" Active Firmware: {:03} ({}){}",
224-
active_ver.build_number,
225-
active_ver,
226-
if active_valid { "" } else { " - INVALID!" }
227-
);
228-
println!(
229-
" Inactive Firmware: {:03} ({}){}",
230-
inactive_ver.build_number,
231-
inactive_ver,
232-
if inactive_valid { "" } else { " - INVALID!" }
233-
);
234-
println!(
235-
" Operating Mode: {:?} (#{})",
236-
FwMode::try_from(info.operating_mode).unwrap(),
237-
info.operating_mode
238-
);
222+
if verbose || active_ver != inactive_ver {
223+
println!(
224+
" Active Firmware: {:03} ({}){}",
225+
active_ver.build_number,
226+
active_ver,
227+
if active_valid { "" } else { " - INVALID!" }
228+
);
229+
println!(
230+
" Inactive Firmware: {:03} ({}){}",
231+
inactive_ver.build_number,
232+
inactive_ver,
233+
if inactive_valid { "" } else { " - INVALID!" }
234+
);
235+
println!(
236+
" Operating Mode: {:?} (#{})",
237+
FwMode::try_from(info.operating_mode).unwrap(),
238+
info.operating_mode
239+
);
240+
} else {
241+
println!(
242+
" Active Firmware: {:03} ({}, {:?}){}",
243+
active_ver.build_number,
244+
active_ver,
245+
FwMode::try_from(info.operating_mode).unwrap(),
246+
if active_valid { "" } else { " - INVALID!" }
247+
);
248+
}
239249
}
240250

241251
/// Turn CCG3 Expansion Card VID/PID into their name
@@ -332,7 +342,7 @@ pub fn flash_firmware(fw_binary: &[u8]) {
332342
magic_unlock(&device);
333343
let info = get_fw_info(&device);
334344
println!("Before Updating");
335-
print_fw_info(&info);
345+
print_fw_info(&info, true);
336346

337347
println!("Updating...");
338348
match info.operating_mode {
@@ -369,7 +379,7 @@ pub fn flash_firmware(fw_binary: &[u8]) {
369379
wait_to_reappear(&mut api, &filter_devs, sn).expect("Device did not reappear");
370380

371381
println!("After Updating");
372-
print_fw_info(&info);
382+
print_fw_info(&info, true);
373383
}
374384
}
375385

framework_lib/src/commandline/mod.rs

Lines changed: 68 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ fn print_audio_card_details() {
247247
}
248248

249249
#[cfg(feature = "hidapi")]
250-
fn print_dp_hdmi_details() {
250+
fn print_dp_hdmi_details(verbose: bool) {
251251
match HidApi::new() {
252252
Ok(api) => {
253253
for dev_info in find_devices(&api, &[HDMI_CARD_PID, DP_CARD_PID], None) {
@@ -265,11 +265,11 @@ fn print_dp_hdmi_details() {
265265
dev_info.product_string().unwrap_or(NOT_SET)
266266
);
267267

268-
println!(
268+
debug!(
269269
" Serial Number: {}",
270270
dev_info.serial_number().unwrap_or(NOT_SET)
271271
);
272-
check_ccg_fw_version(&device);
272+
check_ccg_fw_version(&device, verbose);
273273
}
274274
}
275275
Err(e) => {
@@ -374,11 +374,13 @@ fn print_versions(ec: &CrosEc) {
374374

375375
println!("EC Firmware");
376376
let ver = print_err(ec.version_info()).unwrap_or_else(|| "UNKNOWN".to_string());
377-
println!(" Build version: {:?}", ver);
377+
println!(" Build version: {}", ver);
378378

379379
if let Some((ro, rw, curr)) = ec.flash_version() {
380-
println!(" RO Version: {:?}", ro);
381-
println!(" RW Version: {:?}", rw);
380+
if ro != rw || log_enabled!(Level::Info) {
381+
println!(" RO Version: {}", ro);
382+
println!(" RW Version: {}", rw);
383+
}
382384
print!(" Current image: ");
383385
if curr == chromium_ec::EcCurrentImage::RO {
384386
println!("RO");
@@ -398,53 +400,78 @@ fn print_versions(ec: &CrosEc) {
398400
if let Ok(pd_versions) = ccgx::get_pd_controller_versions(ec) {
399401
let right = &pd_versions.controller01;
400402
let left = &pd_versions.controller23;
401-
println!(" Right (01)");
402403
// let active_mode =
403404
if let Some(Platform::IntelGen11) = smbios::get_platform() {
405+
if right.main_fw.base != right.backup_fw.base {
406+
println!(" Right (01)");
407+
println!(
408+
" Main: {}{}",
409+
right.main_fw.base,
410+
active_mode(&right.active_fw, FwMode::MainFw)
411+
);
412+
println!(
413+
" Backup: {}{}",
414+
right.backup_fw.base,
415+
active_mode(&right.active_fw, FwMode::BackupFw)
416+
);
417+
} else {
418+
println!(
419+
" Right (01): {} ({:?})",
420+
right.main_fw.base, right.active_fw
421+
);
422+
}
423+
} else if right.main_fw.app != right.backup_fw.app {
404424
println!(
405-
" Main: {}{}",
406-
right.main_fw.base,
425+
" Main: {}{}",
426+
right.main_fw.app,
407427
active_mode(&right.active_fw, FwMode::MainFw)
408428
);
409429
println!(
410-
" Backup: {}{}",
411-
right.backup_fw.base,
430+
" Backup: {}{}",
431+
right.backup_fw.app,
412432
active_mode(&right.active_fw, FwMode::BackupFw)
413433
);
414434
} else {
415435
println!(
416-
" Main: {}{}",
417-
right.main_fw.app,
418-
active_mode(&right.active_fw, FwMode::MainFw)
419-
);
420-
println!(
421-
" Backup: {}{}",
422-
right.backup_fw.app,
423-
active_mode(&right.active_fw, FwMode::BackupFw)
436+
" Right (01): {} ({:?})",
437+
right.main_fw.app, right.active_fw
424438
);
425439
}
426-
println!(" Left (23)");
427440
if let Some(Platform::IntelGen11) = smbios::get_platform() {
441+
if left.main_fw.base != left.backup_fw.base {
442+
println!(" Left (23)");
443+
println!(
444+
" Main: {}{}",
445+
left.main_fw.base,
446+
active_mode(&left.active_fw, FwMode::MainFw)
447+
);
448+
println!(
449+
" Backup: {}{}",
450+
left.backup_fw.base,
451+
active_mode(&left.active_fw, FwMode::BackupFw)
452+
);
453+
} else {
454+
println!(
455+
" Left (23): {} ({:?})",
456+
left.main_fw.base, left.active_fw
457+
);
458+
}
459+
} else if left.main_fw.app != left.backup_fw.app {
460+
println!(" Left (23)");
428461
println!(
429-
" Main: {}{}",
430-
left.main_fw.base,
462+
" Main: {}{}",
463+
left.main_fw.app,
431464
active_mode(&left.active_fw, FwMode::MainFw)
432465
);
433466
println!(
434-
" Backup: {}{}",
435-
left.backup_fw.base,
467+
" Backup: {}{}",
468+
left.backup_fw.app,
436469
active_mode(&left.active_fw, FwMode::BackupFw)
437470
);
438471
} else {
439472
println!(
440-
" Main: {}{}",
441-
left.main_fw.app,
442-
active_mode(&left.active_fw, FwMode::MainFw)
443-
);
444-
println!(
445-
" Backup: {}{}",
446-
left.backup_fw.app,
447-
active_mode(&left.active_fw, FwMode::BackupFw)
473+
" Left (23): {} ({:?})",
474+
left.main_fw.app, left.active_fw
448475
);
449476
}
450477
} else if let Ok(pd_versions) = power::read_pd_version(ec) {
@@ -501,10 +528,12 @@ fn print_versions(ec: &CrosEc) {
501528
{
502529
println!("CSME");
503530
if let Ok(csme) = csme::csme_from_sysfs() {
504-
println!(" Enabled: {}", csme.enabled);
505-
println!(" Version: {}", csme.main_ver);
506-
println!(" Recovery Ver: {}", csme.recovery_ver);
507-
println!(" Original Ver: {}", csme.fitc_ver);
531+
info!(" Enabled: {}", csme.enabled);
532+
println!(" Firmware Version: {}", csme.main_ver);
533+
if csme.main_ver != csme.recovery_ver || csme.main_ver != csme.fitc_ver {
534+
println!(" Recovery Ver: {}", csme.recovery_ver);
535+
println!(" Original Ver: {}", csme.fitc_ver);
536+
}
508537
} else {
509538
println!(" Unknown");
510539
}
@@ -522,6 +551,8 @@ fn print_versions(ec: &CrosEc) {
522551
if let Some(Platform::Framework12IntelGen13) = smbios::get_platform() {
523552
let _ignore_err = touchscreen::print_fw_ver();
524553
}
554+
#[cfg(feature = "hidapi")]
555+
print_dp_hdmi_details(false);
525556
}
526557

527558
fn print_esrt() {
@@ -916,7 +947,7 @@ pub fn run_with_args(args: &Cli, _allupdate: bool) -> i32 {
916947
print_pd_details(&ec);
917948
} else if args.dp_hdmi_info {
918949
#[cfg(feature = "hidapi")]
919-
print_dp_hdmi_details();
950+
print_dp_hdmi_details(true);
920951
} else if let Some(pd_bin_path) = &args.dp_hdmi_update {
921952
#[cfg(feature = "hidapi")]
922953
flash_dp_hdmi_card(pd_bin_path);

framework_lib/src/touchpad.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub fn print_touchpad_fw_ver() -> Result<(), HidError> {
5959
let device = dev_info.open_device(&api).unwrap();
6060

6161
println!("Touchpad");
62-
println!(" IC Type: {:04X}", pid);
62+
info!(" IC Type: {:04X}", pid);
6363

6464
let ver = match pid {
6565
0x0239 => format!("{:04X}", read_239_ver(&device)?),

framework_lib/src/touchscreen.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,14 @@ pub trait TouchScreen {
207207
println!(" Firmware Version: v{}", ver);
208208

209209
let res = self.send_message(0x20, 16, vec![0])?;
210-
println!(" USI Protocol: {:?}", (res[15] & USI_BITMAP) > 0);
211-
println!(" MPP Protocol: {:?}", (res[15] & MPP_BITMAP) > 0);
210+
let mut protocols = vec![];
211+
if (res[15] & USI_BITMAP) > 0 {
212+
protocols.push("USI");
213+
}
214+
if (res[15] & MPP_BITMAP) > 0 {
215+
protocols.push("MPP");
216+
}
217+
println!(" Protocols: {}", protocols.join(", "));
212218

213219
Some(())
214220
}

0 commit comments

Comments
 (0)