| Crates.io | elinux-hwdetect |
| lib.rs | elinux-hwdetect |
| version | 0.1.1 |
| created_at | 2026-01-02 10:51:04.786456+00 |
| updated_at | 2026-01-02 11:10:47.689485+00 |
| description | A production-ready Rust crate for Embedded Linux hardware detection using read-only /proc and /sys interfaces. |
| homepage | |
| repository | https://github.com/ma7moud111/elinux-hwdetect |
| max_upload_size | |
| id | 2018307 |
| size | 38,035 |
A production-ready Rust crate for non-intrusive hardware and system information detection on Embedded Linux devices. It is designed to be robust, minimal, and work on systems with limited resources and minimal root filesystems like BusyBox.
/proc/device-tree/model, /proc/device-tree/compatible)./proc/cpuinfo and /sys./dev for common embedded peripherals:
/dev/gpiochip*)/dev/i2c-*)/dev/spidev*)/dev/ttyS*, /dev/ttyAMA*, /dev/ttyUSB*)uname -r) and distribution name from /etc/os-release.The crate is primarily targeted at:
The crate uses read-only Linux interfaces (/proc, /sys, /dev) and does not require any special kernel modules or root privileges for its core functionality.
No special permissions are required. The crate only performs read operations on world-readable system files and device nodes.
Add elinux-hwdetect to your Cargo.toml:
[dependencies]
elinux-hwdetect = "0.1" # Use the latest version
Then, use the HardwareInfo::detect() function in your Rust code:
use elinux_hwdetect::HardwareInfo;
fn main() {
match HardwareInfo::detect() {
Ok(info) => {
println!("Board Model: {:?}", info.board.model);
println!("CPU Cores: {}", info.cpu.core_count);
println!("Kernel Version: {}", info.os.kernel_version);
// ... and so on
},
Err(e) => {
eprintln!("Hardware detection failed: {}", e);
}
}
}
The output will vary based on the host system. On a typical x86_64 development environment (like the one used for testing), the output will look similar to this:
--- Hardware Detection Successful ---
HardwareInfo {
board: BoardInfo {
model: None,
vendor: None,
compatible_strings: [],
},
cpu: CpuInfo {
architecture: "x86_64",
core_count: 6,
frequency_mhz: None,
},
peripherals: PeripheralInfo {
gpio: GpioInfo {
chip_count: 0,
chip_names: [],
},
i2c: I2cInfo {
bus_count: 0,
bus_names: [],
},
spi: SpiInfo {
device_count: 0,
device_names: [],
},
uart: UartInfo {
device_count: 1,
device_names: [
"ttyS0",
],
},
},
os: OsInfo {
kernel_version: "6.1.102",
distribution: Some(
"Ubuntu 22.04.5 LTS",
),
},
}
On an actual Embedded Linux device with a device tree, the board and peripherals fields will be populated with more specific information.
When integrating elinux-hwdetect into a Yocto or Buildroot project, ensure that the target system's kernel configuration includes support for:
/proc and /sys filesystems: Essential for CPU and OS information./dev/gpiochip*, /dev/i2c-*, etc.) are created by your system's udev or mdev setup.Since this crate has minimal dependencies (only thiserror), it should integrate smoothly into most minimal Embedded Linux environments.
This project is licensed under the MIT OR Apache-2.0 License.