diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 32037c69..20cb7692 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 diff --git a/Cargo.lock b/Cargo.lock index be5f5f4d..b1f289ca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -331,6 +331,41 @@ dependencies = [ "syn 2.0.98", ] +[[package]] +name = "darling" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.98", +] + +[[package]] +name = "darling_macro" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.98", +] + [[package]] name = "derive_more" version = "0.99.17" @@ -397,6 +432,12 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + [[package]] name = "form_urlencoded" version = "1.1.0" @@ -425,6 +466,7 @@ dependencies = [ "num", "num-derive", "num-traits", + "nvml-wrapper", "plain", "redox_hwio", "regex", @@ -646,6 +688,12 @@ dependencies = [ "cxx-build", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "idna" version = "0.3.0" @@ -733,6 +781,16 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "libloading" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07033963ba89ebaf1584d767badaa2e8fcec21aedea6b8c0346d487d49c28667" +dependencies = [ + "cfg-if", + "windows-targets 0.53.0", +] + [[package]] name = "libusb1-sys" version = "0.7.0" @@ -921,6 +979,29 @@ dependencies = [ "autocfg", ] +[[package]] +name = "nvml-wrapper" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d5c6c0ef9702176a570f06ad94f3198bc29c524c8b498f1b9346e1b1bdcbb3a" +dependencies = [ + "bitflags 2.6.0", + "libloading", + "nvml-wrapper-sys", + "static_assertions", + "thiserror 1.0.69", + "wrapcenum-derive", +] + +[[package]] +name = "nvml-wrapper-sys" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd23dbe2eb8d8335d2bce0299e0a07d6a63c089243d626ca75b770a962ff49e6" +dependencies = [ + "libloading", +] + [[package]] name = "once_cell" version = "1.16.0" @@ -1170,6 +1251,12 @@ dependencies = [ "lock_api", ] +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "static_vcruntime" version = "2.0.0" @@ -1213,13 +1300,33 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + [[package]] name = "thiserror" version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" dependencies = [ - "thiserror-impl", + "thiserror-impl 2.0.11", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", ] [[package]] @@ -1856,7 +1963,19 @@ dependencies = [ "futures", "log", "serde", - "thiserror", + "thiserror 2.0.11", "windows 0.59.0", "windows-core", ] + +[[package]] +name = "wrapcenum-derive" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a76ff259533532054cfbaefb115c613203c73707017459206380f03b3b3f266e" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.98", +] diff --git a/framework_lib/Cargo.toml b/framework_lib/Cargo.toml index 162538f4..4213b22c 100644 --- a/framework_lib/Cargo.toml +++ b/framework_lib/Cargo.toml @@ -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"] } @@ -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" @@ -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" diff --git a/framework_lib/src/commandline/mod.rs b/framework_lib/src/commandline/mod.rs index dab66c02..1f6ab50b 100644 --- a/framework_lib/src/commandline/mod.rs +++ b/framework_lib/src/commandline/mod.rs @@ -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")] @@ -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() { diff --git a/framework_tool/Cargo.toml b/framework_tool/Cargo.toml index 6dceeabb..27c3c034 100644 --- a/framework_tool/Cargo.toml +++ b/framework_tool/Cargo.toml @@ -15,6 +15,7 @@ path = "src/main.rs" [features] default = [ ] readonly = [ "framework_lib/readonly" ] +nvidia = [ "framework_lib/nvidia" ] [dependencies.framework_lib] path = "../framework_lib"