Skip to content

Commit ffdc29f

Browse files
committed
--thermal: Remove hardcoded names
We can figure them out from EC_CMD_TEMP_SENSOR_GET_INFO Signed-off-by: Daniel Schaefer <dhs@frame.work>
1 parent 32f4f43 commit ffdc29f

2 files changed

Lines changed: 47 additions & 106 deletions

File tree

‎EXAMPLES.md‎

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -481,13 +481,16 @@ Board IDs
481481
Example on one system, note that different systems have different thermal
482482
sensors and number of fans, so your output may look different:
483483

484+
The sensor names are reported by the EC firmware:
485+
484486
```
485487
> sudo framework_tool --thermal
486-
F75303_Local: 43 C
487-
F75303_CPU: 44 C
488-
F75303_DDR: 39 C
489-
APU: 62 C
490-
API Fan: 0 RPM
488+
local_f75397@4c: 36 C
489+
cpu_f75303@4d: 37 C
490+
battery_temp@b: 32 C
491+
ddr_f75303@4d: 35 C
492+
peci-temp: 42 C
493+
APU Fan: 0 RPM
491494
```
492495

493496
## Check thermal thresholds
@@ -568,30 +571,33 @@ Accelerometers:
568571
> sudo framework_tool --fansetduty 100
569572
> sudo framework_tool --fansetduty 0 100
570573
> sudo framework_tool --thermal
571-
F75303_Local: 40 C
572-
F75303_CPU: 41 C
573-
F75303_DDR: 37 C
574-
APU: 42 C
575-
APU Fan: 7281 RPM
574+
local_f75397@4c: 40 C
575+
cpu_f75303@4d: 41 C
576+
battery_temp@b: 32 C
577+
ddr_f75303@4d: 37 C
578+
peci-temp: 42 C
579+
APU Fan: 7281 RPM
576580
577581
# Set a target RPM (all or just fan ID=0)
578582
> sudo framework_tool --fansetrpm 3141
579583
> sudo framework_tool --fansetrpm 0 3141
580584
> sudo framework_tool --thermal
581-
F75303_Local: 41 C
582-
F75303_CPU: 42 C
583-
F75303_DDR: 37 C
584-
APU: 44 C
585-
APU Fan: 3171 RPM
585+
local_f75397@4c: 41 C
586+
cpu_f75303@4d: 42 C
587+
battery_temp@b: 32 C
588+
ddr_f75303@4d: 37 C
589+
peci-temp: 44 C
590+
APU Fan: 3171 RPM
586591
587592
# And back to normal
588593
> sudo framework_tool --autofanctrl
589594
> sudo framework_tool --thermal
590-
F75303_Local: 40 C
591-
F75303_CPU: 40 C
592-
F75303_DDR: 38 C
593-
APU: 42 C
594-
APU Fan: 0 RPM
595+
local_f75397@4c: 40 C
596+
cpu_f75303@4d: 40 C
597+
battery_temp@b: 32 C
598+
ddr_f75303@4d: 38 C
599+
peci-temp: 42 C
600+
APU Fan: 0 RPM
595601
596602
# Or just for a specific fan (e.g. on Framework Desktop)
597603
> sudo framework_tool --autofanctrl 0

‎framework_lib/src/power.rs‎

Lines changed: 21 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::chromium_ec::command::EcRequestRaw;
1414
use crate::chromium_ec::commands::*;
1515
use crate::chromium_ec::*;
1616
use crate::smbios;
17-
use crate::util::{Platform, PlatformFamily};
17+
use crate::util::PlatformFamily;
1818

1919
/// Maximum length of strings in memmap
2020
const EC_MEMMAP_TEXT_MAX: u16 = 8;
@@ -475,92 +475,27 @@ pub fn print_thermal(ec: &CrosEc) {
475475
let temps = ec.read_memory(EC_MEMMAP_TEMP_SENSOR, 0x0F).unwrap();
476476
let fans = ec.read_memory(EC_MEMMAP_FAN, 0x08).unwrap();
477477

478-
let platform = smbios::get_platform();
479478
let family = smbios::get_family();
480-
let remaining_sensors = match platform {
481-
Some(Platform::IntelGen11) | Some(Platform::IntelGen12) | Some(Platform::IntelGen13) => {
482-
println!(" F75303_Local: {:>4}", TempSensor::from(temps[0]));
483-
println!(" F75303_CPU: {:>4}", TempSensor::from(temps[1]));
484-
println!(" F75303_DDR: {:>4}", TempSensor::from(temps[2]));
485-
println!(" Battery: {:>4}", TempSensor::from(temps[3]));
486-
println!(" PECI: {:>4}", TempSensor::from(temps[4]));
487-
if matches!(
488-
platform,
489-
Some(Platform::IntelGen12) | Some(Platform::IntelGen13)
490-
) {
491-
println!(" F57397_VCCGT: {:>4}", TempSensor::from(temps[5]));
492-
}
493-
2
494-
}
495-
496-
Some(Platform::IntelCoreUltra1) | Some(Platform::IntelCoreUltra3) => {
497-
println!(" F75303_Local: {:>4}", TempSensor::from(temps[0]));
498-
println!(" F75303_CPU: {:>4}", TempSensor::from(temps[1]));
499-
println!(" Battery: {:>4}", TempSensor::from(temps[2]));
500-
println!(" F75303_DDR: {:>4}", TempSensor::from(temps[3]));
501-
println!(" PECI: {:>4}", TempSensor::from(temps[4]));
502-
3
503-
}
504-
505-
Some(Platform::Framework12IntelGen13) => {
506-
println!(" F75303_CPU: {:>4}", TempSensor::from(temps[0]));
507-
println!(" F75303_Skin: {:>4}", TempSensor::from(temps[1]));
508-
println!(" F75303_Local: {:>4}", TempSensor::from(temps[2]));
509-
println!(" Battery: {:>4}", TempSensor::from(temps[3]));
510-
println!(" PECI: {:>4}", TempSensor::from(temps[4]));
511-
println!(" Charger IC {:>4}", TempSensor::from(temps[5]));
512-
2
513-
}
514-
515-
Some(
516-
Platform::Framework13Amd7080
517-
| Platform::Framework13AmdAi300
518-
| Platform::Framework16Amd7080
519-
| Platform::Framework16AmdAi300,
520-
) => {
521-
println!(" F75303_Local: {:>4}", TempSensor::from(temps[0]));
522-
println!(" F75303_CPU: {:>4}", TempSensor::from(temps[1]));
523-
println!(" F75303_DDR: {:>4}", TempSensor::from(temps[2]));
524-
println!(" APU: {:>4}", TempSensor::from(temps[3]));
525-
if family == Some(PlatformFamily::Framework16) {
526-
println!(" dGPU VR: {:>4}", TempSensor::from(temps[4]));
527-
println!(" dGPU VRAM: {:>4}", TempSensor::from(temps[5]));
528-
println!(" dGPU AMB: {:>4}", TempSensor::from(temps[6]));
529-
println!(" dGPU temp: {:>4}", TempSensor::from(temps[7]));
530-
0
531-
} else {
532-
4
533-
}
534-
}
535479

536-
Some(Platform::FrameworkDesktopAmdAiMax300) => {
537-
println!(" F75303_APU: {:>4}", TempSensor::from(temps[0]));
538-
println!(" F75303_DDR: {:>4}", TempSensor::from(temps[1]));
539-
println!(" F75303_AMB: {:>4}", TempSensor::from(temps[2]));
540-
println!(" APU: {:>4}", TempSensor::from(temps[3]));
541-
println!(" Virtual: {:>4}", TempSensor::from(temps[4]));
542-
3
543-
}
544-
545-
_ => {
546-
println!(" Temp 0: {:>4}", TempSensor::from(temps[0]));
547-
println!(" Temp 1: {:>4}", TempSensor::from(temps[1]));
548-
println!(" Temp 2: {:>4}", TempSensor::from(temps[2]));
549-
println!(" Temp 3: {:>4}", TempSensor::from(temps[3]));
550-
println!(" Temp 4: {:>4}", TempSensor::from(temps[4]));
551-
println!(" Temp 5: {:>4}", TempSensor::from(temps[5]));
552-
println!(" Temp 6: {:>4}", TempSensor::from(temps[6]));
553-
println!(" Temp 7: {:>4}", TempSensor::from(temps[7]));
554-
0
555-
}
556-
};
557-
558-
// Just in case EC has more sensors than we know about, print them
559-
for (i, temp) in temps.iter().enumerate().take(8).skip(8 - remaining_sensors) {
480+
let mut sensors = vec![];
481+
for (i, temp) in temps.iter().enumerate() {
560482
let temp = TempSensor::from(*temp);
561-
if temp != TempSensor::NotPresent {
562-
println!(" Temp {}: {:>4}", i, temp);
483+
if temp == TempSensor::NotPresent {
484+
continue;
563485
}
486+
// All our EC firmware supports reporting the sensor name
487+
let name = ec
488+
.get_temp_sensor_name(i as u8)
489+
.unwrap_or_else(|_| format!("Temp {}", i));
490+
sensors.push((name, temp));
491+
}
492+
let width = sensors
493+
.iter()
494+
.map(|(name, _)| name.len() + 1)
495+
.max()
496+
.unwrap_or(13);
497+
for (name, temp) in sensors {
498+
println!(" {:<width$} {:>4}", format!("{name}:"), temp);
564499
}
565500

566501
for i in 0..EC_FAN_SPEED_ENTRIES {
@@ -578,11 +513,11 @@ pub fn print_thermal(ec: &CrosEc) {
578513

579514
let fan = u16::from_le_bytes([fans[i * 2], fans[1 + i * 2]]);
580515
if fan == EC_FAN_SPEED_STALLED_DEPRECATED {
581-
println!(" {name:<11} {:>4} RPM (Stalled)", fan);
516+
println!(" {name:<width$} {:>4} RPM (Stalled)", fan);
582517
} else if fan == EC_FAN_SPEED_NOT_PRESENT {
583-
info!(" {name:<11} Not present");
518+
info!(" {name:<width$} Not present");
584519
} else {
585-
println!(" {name:<11} {:>4} RPM", fan);
520+
println!(" {name:<width$} {:>4} RPM", fan);
586521
}
587522
}
588523
}

0 commit comments

Comments
 (0)