https://github.com/openbmc/phosphor-psu-code-mgmt
https://github.com/openbmc/phosphor-psu-code-mgmt
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/openbmc/phosphor-psu-code-mgmt
- Owner: openbmc
- License: apache-2.0
- Created: 2019-07-22T16:31:03.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2025-02-08T04:12:43.000Z (over 1 year ago)
- Last Synced: 2025-03-22T04:02:03.404Z (over 1 year ago)
- Language: C++
- Size: 531 KB
- Stars: 2
- Watchers: 1
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# phosphor-psu-code-mgmt
phosphor-psu-code-mgmt is a service to provide management for PSU code,
including:
- PSU code version
- PSU code update
## Building
```text
meson build/ && ninja -C build
```
## Unit test
- Run it in OpenBMC CI, refer to [local-ci-build.md][1]
- Run it in [OE SDK][2], run below commands in a x86-64 SDK env:
```text
meson -Doe-sdk=enabled -Dtests=enabled build/
ninja -C build/ test # Meson skips running the case due to it thinks it's cross compiling
# Manually run the tests
for t in `find build/test/ -maxdepth 1 -name "test_*"`; do ./$t || break ; done
```
## Vendor-specific tools
This repo contains generic code to handle the PSU versions and updates. It
depends on vendor-specific tools to provide the below functions on the real PSU
hardware:
- Get PSU firmware version
- Get PSU model
- Compare the firmware version
- Update the PSU firmware
It provides configure options for vendor-specific tools for the above functions:
- `PSU_VERSION_UTIL`: It shall be defined as a command-line tool that accepts
the PSU inventory path as input, and outputs the PSU version string to stdout.
- `PSU_MODEL_UTIL`: It shall be defined as a command-line tool that accepts the
PSU inventory path as input, and outputs the PSU model string to stdout.
- `PSU_VERSION_COMPARE_UTIL`: It shall be defined as a command-line tool that
accepts one or more PSU version strings, and outputs the latest version string
to stdout.
- `PSU_UPDATE_SERVICE`: It shall be defined as a systemd service that accepts
two arguments:
- The PSU inventory DBus object;
- The path of the PSU image(s).
For example:
```text
meson -Dtests=disabled \
'-DPSU_VERSION_UTIL=/usr/bin/psutils --raw --get-version' \
'-DPSU_MODEL_UTIL=/usr/bin/psutils --raw --get-model' \
'-DPSU_VERSION_COMPARE_UTIL=/usr/bin/psutils --raw --compare' \
'-DPSU_UPDATE_SERVICE=psu-update@.service' \
build
```
The above configures the vendor-specific tools to use `psutils` from
[phosphor-power][3] to get the PSU version and model, compare PSU versions, and
use `psu-update@.service` to perform the PSU firmware update, where internally
it invokes `psutils` as well.
## Usage
### PSU version
When the service starts, it queries the inventory to get all the PSU inventory
paths, invokes the vendor-specific tool to get the versions, and creates version
objects under `/xyz/openbmc_project/software` that are associated with the PSU
inventory path. If multiple PSUs are using the same version, multiple PSU
inventory paths are associated.
E.g.
- Example of system with two PSUs that have different versions:
```text
"/xyz/openbmc_project/software/02572429": {
"Activation": "xyz.openbmc_project.Software.Activation.Activations.Active",
"Associations": [
[
"inventory",
"activation",
"/xyz/openbmc_project/inventory/system/chassis/motherboard/powersupply1"
]
],
"ExtendedVersion": "",
"Path": "",
"Purpose": "xyz.openbmc_project.Software.Version.VersionPurpose.PSU",
"RequestedActivation": "xyz.openbmc_project.Software.Activation.RequestedActivations.None",
"Version": "01120114"
},
"/xyz/openbmc_project/software/7094f612": {
"Activation": "xyz.openbmc_project.Software.Activation.Activations.Active",
"Associations": [
[
"inventory",
"activation",
"/xyz/openbmc_project/inventory/system/chassis/motherboard/powersupply0"
]
],
"ExtendedVersion": "",
"Path": "",
"Purpose": "xyz.openbmc_project.Software.Version.VersionPurpose.PSU",
"RequestedActivation": "xyz.openbmc_project.Software.Activation.RequestedActivations.None",
"Version": "00000110"
},
```
- Example of system with two PSUs that have the same version:
```text
"/xyz/openbmc_project/software/9463c2ad": {
"Activation": "xyz.openbmc_project.Software.Activation.Activations.Active",
"Associations": [
[
"inventory",
"activation",
"/xyz/openbmc_project/inventory/system/chassis/motherboard/powersupply0"
],
[
"inventory",
"activation",
"/xyz/openbmc_project/inventory/system/chassis/motherboard/powersupply1"
]
],
"ExtendedVersion": "",
"Path": "",
"Purpose": "xyz.openbmc_project.Software.Version.VersionPurpose.PSU",
"RequestedActivation": "xyz.openbmc_project.Software.Activation.RequestedActivations.None",
"Version": "01100110"
},
```
### PSU update
1. Generate a tarball of PSU firmware image by [generate-psu-tar tool][4].
```text
./generate-psu-tar --image --version --model --manufacturer \
--machineName --outfile --sign
```
2. To update the PSU firmware, follow the same steps as described in
[code-update.md][5]:
- Upload a PSU image tarball and get the version ID;
- Set the RequestedActivation state of the uploaded image's version ID.
- Check the state and wait for the activation to be completed.
3. After a successful update, the PSU image and the manifest is stored in BMC's
persistent storage defined by `IMG_DIR_PERSIST`. When a PSU is replaced, the
PSU's firmware version will be checked and updated if it's older than the one
stored in BMC.
4. It is possible to put a PSU image and MANIFEST in the built-in OpenBMC image
in BMC's read-only filesystem defined by `IMG_DIR_BUILTIN`. When the service
starts, it will compare the versions of the built-in image and the existing
PSUs. If there is any PSU that has older firmware, it will be updated to the
new firmware.
[1]: https://github.com/openbmc/docs/blob/master/testing/local-ci-build.md
[2]:
https://github.com/openbmc/docs/blob/master/cheatsheet.md#building-the-openbmc-sdk
[3]: https://github.com/openbmc/phosphor-power/tree/master/tools/power-utils
[4]:
https://github.com/openbmc/phosphor-psu-code-mgmt/blob/master/tools/generate-psu-tar
[5]:
https://github.com/openbmc/docs/blob/master/architecture/code-update/code-update.md