Skip to content
Open
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
path: target/debug/framework_tool

- name: Build Linux tool (Release)
run: cargo build -p framework_tool --release
run: cargo build -p framework_tool --release --features nvidia

- name: Upload Linux App
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -134,7 +134,7 @@ jobs:
- name: Build Windows tool
run: |
cargo build -p framework_tool
cargo build -p framework_tool --release
cargo build -p framework_tool --release --features nvidia

- name: Check if Windows tool can start
run: cargo run -- --help --release
Expand Down
123 changes: 121 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions framework_lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ readonly = [ ]
rusb = ["dep:rusb"]
hidapi = ["dep:hidapi"]
uefi = [ "lazy_static/spin_no_std" ]
nvidia = ["dep:nvml-wrapper"]

[build-dependencies]
built = { version = "0.5", features = ["chrono", "git2"] }
Expand Down Expand Up @@ -52,6 +53,7 @@ clap-num = { version = "1.2.0" }
clap-verbosity-flag = { version = "2.2.1" }
windows-version = "0.1.4"
winreg = "0.55.0"
nvml-wrapper = { version = "0.11.0", optional = true }

[target.'cfg(unix)'.dependencies]
libc = "0.2.155"
Expand All @@ -62,6 +64,7 @@ env_logger = "0.11"
clap = { version = "4.5", features = ["derive", "cargo"] }
clap-num = { version = "1.2.0" }
clap-verbosity-flag = { version = "2.2.1" }
nvml-wrapper = { version = "0.11.0", optional = true }

[target.'cfg(windows)'.dependencies.windows]
version = "0.59.0"
Expand Down
85 changes: 85 additions & 0 deletions framework_lib/src/commandline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ use sha2::{Digest, Sha256, Sha384, Sha512};
//use smbioslib::*;
use smbioslib::{DefinedStruct, SMBiosInformation};

#[cfg(feature = "nvidia")]
use nvml_wrapper::{enum_wrappers::device::TemperatureSensor, Nvml};

use crate::chromium_ec::{CrosEc, CrosEcDriverType, HardwareDeviceType};

#[cfg(feature = "uefi")]
Expand Down Expand Up @@ -756,6 +759,88 @@ fn print_versions(ec: &CrosEc) {
}
}
}

#[cfg(feature = "nvidia")]
print_nvidia_details();
}

#[cfg(feature = "nvidia")]
fn print_nvidia_details() {
let nvml = match Nvml::init() {
Ok(nvml) => nvml,
Err(err) => {
debug!("Nvidia, library init fail: {:?}", err);
return;
}
};
// Get the first `Device` (GPU) in the system
let device = match nvml.device_by_index(0) {
Ok(device) => device,
Err(err) => {
debug!("Nvidia, device not found: {:?}", err);
return;
}
};

println!("NVIDIA GPU");
// GeForce
info!(" BRAND: {:?}", device.brand());
println!(
" Name: {}",
device.name().unwrap_or("Unknown".to_string())
);
println!(" Architecture: {:?}", device.architecture());
println!(
" VBIOS Version: {}",
device.vbios_version().unwrap_or("Unknown".to_string())
);
println!(
" INFO ROM Ver: {}",
device
.info_rom_image_version()
.unwrap_or("Unknown".to_string())
);
println!(" PCI Info: {:X?}", device.pci_info());
println!(" Performance State:{:?}", device.performance_state());
println!(
" Pwr Mgmt Limit Df:{:?}mW",
device.power_management_limit_default()
);
// NotSupported
println!(
" Pwr Mgmt Limit: {:?}mW",
device.power_management_limit()
);
println!(
" Pwr Mgmt Limit Cs:{:?}",
device.power_management_limit_constraints()
);
println!(" Pwr Usage: {:?}mW", device.power_usage());
println!(
" Total Energy: {:?}mJ",
device.total_energy_consumption()
);
// 0/NotSupported right now
println!(" Serialnum: {:?}", device.serial());
println!(
" Throttle Reason: {:?}",
device.current_throttle_reasons()
);
println!(
" Temperature: {:?}C",
device.temperature(TemperatureSensor::Gpu)
);
//println!(" Temperature Thres:{:?}C", device.temperature_threshold());
println!(" Util Rate: {:?}", device.utilization_rates());
println!(" Memory Info: {:?}", device.memory_info());
// Not supported
println!(" Part Number: {:?}", device.board_part_number());
println!(" Board ID: {:?}", device.board_id());
// 0
println!(" Num Fans: {:?}", device.num_fans());
// Works
println!(" Display Active?: {:?}", device.is_display_active());
println!(" Display Conn?: {:?}", device.is_display_connected());
}

fn print_esrt() {
Expand Down
1 change: 1 addition & 0 deletions framework_tool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ path = "src/main.rs"
[features]
default = [ ]
readonly = [ "framework_lib/readonly" ]
nvidia = [ "framework_lib/nvidia" ]

[dependencies.framework_lib]
path = "../framework_lib"
Expand Down
Loading