Adding new sensors to an OpenBMC (Baseboard Management Controller) system is a critical task for enhancing hardware monitoring capabilities. This process allows for the collection of vital data such as temperature, voltage, fan speed, and more, which is essential for system health management, diagnostics, and alerting. Successfully integrating a sensor involves understanding OpenBMC's architecture, configuring the hardware at the kernel level, and ensuring the sensor data is correctly exposed and accessible through OpenBMC's management interfaces.
/xyz/openbmc_project/sensors/<type>/<label>
.phosphor-hwmon
or dbus-sensors
in conjunction with entity-manager
.OpenBMC employs a layered architecture for sensor management, designed for flexibility and compliance with Linux standards. At its core, OpenBMC leverages the Linux Hwmon subsystem, which provides a standardized way for kernel drivers to expose hardware monitoring capabilities through the sysfs filesystem (e.g., /sys/class/hwmon/hwmonX/
).
The data from Hwmon is then picked up by various OpenBMC daemons. These daemons are responsible for reading the raw sensor values, applying scaling or offsets if necessary, and exposing them as D-Bus objects. D-Bus acts as the central inter-process communication (IPC) mechanism in OpenBMC. Sensors are typically represented on D-Bus under the path /xyz/openbmc_project/sensors/
, categorized by type (e.g., temperature
, voltage
, fan_tach
) and a unique label.
Key D-Bus interfaces for sensors include:
xyz.openbmc_project.Sensor.Value
: Exposes the current sensor reading.xyz.openbmc_project.Sensor.Threshold
interfaces (e.g., Warning
, Critical
): Define and manage threshold levels.When a sensor's value changes or a threshold is crossed, a PropertiesChanged
signal is broadcast on D-Bus. This allows other OpenBMC services (like those providing Redfish or IPMI interfaces) and external monitoring tools to react to these events in real-time.
A conceptual diagram illustrating how sensors integrate into the OpenBMC ecosystem, interacting with the host system and management interfaces like REST APIs.
Adding a new sensor to OpenBMC involves several distinct stages, ensuring the hardware is recognized, configured, and its data made available through the management stack.
The first step is to ensure your sensor hardware is correctly connected to the system (e.g., via an I2C bus, SPI, or ADC input). The Linux kernel needs to be aware of this new hardware. This is typically achieved by adding an entry to the system's Device Tree Source (DTS) file. The DTS describes the hardware present on the board to the kernel.
For example, to add an LM75 temperature sensor connected to an I2C bus at address 0x48
, you might add the following to your DTS file:
&i2c1 { /* Assuming the sensor is on I2C bus 1 */
status = "okay";
temp_sensor: lm75@48 {
compatible = "national,lm75"; /* Or appropriate compatible string */
reg = <0x48>;
status = "okay";
};
};
After modifying the DTS, you'll need to recompile the kernel and device tree, then update your OpenBMC image.
Once the kernel recognizes the sensor and exposes it via Hwmon (e.g., in /sys/class/hwmon/hwmonX/
), you need to configure OpenBMC to read and interpret this data. There are two primary approaches:
Using phosphor-hwmon
:
This daemon is suitable for sensors directly exposed via Hwmon sysfs entries. It reads these entries and creates corresponding D-Bus objects. Configuration typically involves creating or modifying files in directories like /etc/default/obmc/hwmon/
or within your machine-specific Yocto layer.
These configuration files define properties like sensor type, D-Bus path, scaling factors, and thresholds. Some systems might use a Machine Readable Workbook (MRW) to define sensors, which phosphor-hwmon
can then process.
Using entity-manager
and dbus-sensors
:
This combination offers more flexibility, especially for dynamic sensor discovery or more complex sensor types (e.g., ADC sensors, external sensors). The entity-manager
parses JSON or YAML configuration files that describe system components, including sensors. Based on these configurations, dbus-sensors
and its associated applications (like adcsensor
, cpusensor
) dynamically create D-Bus sensor objects. Configuration files for entity-manager
are typically located within the OpenBMC source tree (e.g., meta-yourmachine/recipes-phosphor/sensors/
or openbmc/entity-manager/config/
).
An example JSON configuration for an external temperature sensor managed by dbus-sensors
might look like:
{
"Name": "AmbientTempFront",
"Units": "DegreesC",
"MinValue": -20.0,
"MaxValue": 85.0,
"Timeout": 5.0,
"Type": "ExternalSensor",
"MonitorPath": "/some/external/sensor/path", // Path to sensor data if not standard Hwmon
"Scale": 1000 // Example: if sensor reports in millidegrees
}
OpenBMC uses YAML files to define the D-Bus interfaces for sensors, including their properties and threshold behaviors. These are generally located in the phosphor-dbus-interfaces
repository, under paths like xyz/openbmc_project/Sensor/Value.yaml
or xyz/openbmc_project/Sensor/Threshold/Warning.yaml
. While you typically don't modify these core interface definitions, your sensor configuration files (JSON or specific daemon configs) will reference these interfaces and provide values for properties like Unit
, Scale
, MinValue
, MaxValue
, and threshold limits (e.g., WarningHigh
, CriticalLow
).
After adding the necessary DTS entries and configuration files, rebuild your OpenBMC image and flash it to your target system. Once the system boots, you need to verify that the sensor is correctly recognized and reporting data.
Verification using busctl
:
You can use the busctl
command-line utility to inspect D-Bus objects:
busctl tree xyz.openbmc_project.sensors
busctl introspect xyz.openbmc_project.sensors /xyz/openbmc_project/sensors/temperature/temp_sensor
busctl get-property xyz.openbmc_project.sensors /xyz/openbmc_project/sensors/temperature/temp_sensor xyz.openbmc_project.Sensor.Value Value
Verification using REST API:
If bmcweb
(OpenBMC's web server) is running, you can query sensor data via its REST API:
curl -b cjar -k https://<BMC_IP>/xyz/openbmc_project/sensors/temperature/temp_sensor
Replace <BMC_IP>
with your BMC's IP address and the sensor path accordingly. If the host system (the main server) needs to be powered on for the sensor to be active, ensure it is on using commands like obmcutil poweron
.
Example of an OpenBMC web interface showing hardware status, where newly added sensors would appear.
Several daemons and services work together to manage sensors in OpenBMC. Understanding their roles can help in troubleshooting and configuration.
Component | Primary Role | Configuration Method | Typical Use Case |
---|---|---|---|
phosphor-hwmon |
Reads sensor data directly from Linux Hwmon sysfs entries and exposes them as D-Bus objects. | Configuration files (e.g., in /etc/default/obmc/hwmon/ or via MRW) defining mappings and properties. |
Sensors with standard Hwmon kernel drivers. Simpler, static configurations. |
dbus-sensors |
A suite of applications for more flexible and dynamic sensor detection and D-Bus object creation. Includes specific handlers like adcsensor , cpusensor , and fansensor . |
Often works with entity-manager using JSON/YAML configuration files. Can also read from Hwmon, other D-Bus services, or directly from drivers. |
Complex sensor types, external sensors, ADC-based sensors, or scenarios requiring dynamic configuration. |
entity-manager |
Parses system configuration data (typically JSON files) that describe the hardware entities on the platform, including sensors and their properties. | JSON or YAML configuration files stored in the OpenBMC filesystem or within machine-specific layers. | Provides a structured way to define the system's inventory and how components, including sensors, are managed and interconnected. |
ExternalSensor Daemon | A specific application (often part of or used by dbus-sensors ) that supports adding sensors with flexible configurations not tied directly to Hwmon sysfs. |
JSON configuration files specifying sensor name, units, value ranges, and how to read the sensor. | Sensors whose data is available through non-standard kernel interfaces or other means. |
This table summarizes the primary roles and configuration approaches for key sensor management components within the OpenBMC framework. The choice of component often depends on the sensor type and the complexity of its integration.
Adding different types of sensors to OpenBMC can vary in complexity across several aspects of the integration process. The following radar chart provides an opinionated visualization of the relative effort or knowledge typically required for integrating common sensor types. The scores (1-10, higher means more effort/complexity) are illustrative and can vary based on the specific hardware and OpenBMC version.
This chart helps to understand that while some aspects like D-Bus interfacing might be consistently involved, the effort in areas like kernel driver availability or Device Tree configuration can differ significantly. For instance, a standard I2C temperature sensor with good kernel support might be simpler than a custom PMBus device requiring more intricate configuration.
The following mindmap illustrates the general workflow and architectural layers involved when adding a sensor to an OpenBMC system. It highlights the journey of sensor data from the physical hardware up to the point where it's accessible by management applications.
This mindmap visually breaks down the sensor integration process, showing how different components interact, from the physical hardware layer through the Linux kernel and into the OpenBMC software stack where sensor data is ultimately consumed.
The Entity Manager is a crucial subsystem in OpenBMC responsible for discovering and managing system components, including sensors, in a dynamic way. It often works in conjunction with services like dbus-sensors
to populate the D-Bus with objects representing the hardware inventory. This video provides an overview of the Entity Manager, its role, and how it uses configuration data (often JSON) to understand the system's makeup. This is particularly relevant when adding sensors that are part of a more complex or dynamically configured system.
Understanding how Entity Manager processes configuration files and interacts with other daemons is key for successfully integrating new sensors, especially in systems that rely heavily on it for hardware discovery and representation.