{"id":18368620,"url":"https://github.com/openbmc/phosphor-psu-code-mgmt","last_synced_at":"2025-04-06T17:31:45.093Z","repository":{"id":53835761,"uuid":"198263460","full_name":"openbmc/phosphor-psu-code-mgmt","owner":"openbmc","description":null,"archived":false,"fork":false,"pushed_at":"2025-02-08T04:12:43.000Z","size":544,"stargazers_count":2,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-22T04:02:03.404Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/openbmc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-07-22T16:31:03.000Z","updated_at":"2025-02-08T04:12:47.000Z","dependencies_parsed_at":"2023-02-11T21:40:19.512Z","dependency_job_id":"67d681ca-7c71-4154-a010-29b8e6fbcaa1","html_url":"https://github.com/openbmc/phosphor-psu-code-mgmt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openbmc%2Fphosphor-psu-code-mgmt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openbmc%2Fphosphor-psu-code-mgmt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openbmc%2Fphosphor-psu-code-mgmt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openbmc%2Fphosphor-psu-code-mgmt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/openbmc","download_url":"https://codeload.github.com/openbmc/phosphor-psu-code-mgmt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247522366,"owners_count":20952533,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T23:26:45.854Z","updated_at":"2025-04-06T17:31:45.087Z","avatar_url":"https://github.com/openbmc.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# phosphor-psu-code-mgmt\n\nphosphor-psu-code-mgmt is a service to provide management for PSU code,\nincluding:\n\n- PSU code version\n- PSU code update\n\n## Building\n\n```text\nmeson build/ \u0026\u0026 ninja -C build\n```\n\n## Unit test\n\n- Run it in OpenBMC CI, refer to [local-ci-build.md][1]\n- Run it in [OE SDK][2], run below commands in a x86-64 SDK env:\n\n  ```text\n  meson -Doe-sdk=enabled -Dtests=enabled build/\n  ninja -C build/ test  # Meson skips running the case due to it thinks it's cross compiling\n  # Manually run the tests\n  for t in `find build/test/ -maxdepth 1 -name \"test_*\"`; do ./$t || break ; done\n  ```\n\n## Vendor-specific tools\n\nThis repo contains generic code to handle the PSU versions and updates. It\ndepends on vendor-specific tools to provide the below functions on the real PSU\nhardware:\n\n- Get PSU firmware version\n- Get PSU model\n- Compare the firmware version\n- Update the PSU firmware\n\nIt provides configure options for vendor-specific tools for the above functions:\n\n- `PSU_VERSION_UTIL`: It shall be defined as a command-line tool that accepts\n  the PSU inventory path as input, and outputs the PSU version string to stdout.\n- `PSU_MODEL_UTIL`: It shall be defined as a command-line tool that accepts the\n  PSU inventory path as input, and outputs the PSU model string to stdout.\n- `PSU_VERSION_COMPARE_UTIL`: It shall be defined as a command-line tool that\n  accepts one or more PSU version strings, and outputs the latest version string\n  to stdout.\n- `PSU_UPDATE_SERVICE`: It shall be defined as a systemd service that accepts\n  two arguments:\n  - The PSU inventory DBus object;\n  - The path of the PSU image(s).\n\nFor example:\n\n```text\nmeson -Dtests=disabled \\\n    '-DPSU_VERSION_UTIL=/usr/bin/psutils --raw --get-version' \\\n    '-DPSU_MODEL_UTIL=/usr/bin/psutils --raw --get-model' \\\n    '-DPSU_VERSION_COMPARE_UTIL=/usr/bin/psutils --raw --compare' \\\n    '-DPSU_UPDATE_SERVICE=psu-update@.service' \\\n    build\n```\n\nThe above configures the vendor-specific tools to use `psutils` from\n[phosphor-power][3] to get the PSU version and model, compare PSU versions, and\nuse `psu-update@.service` to perform the PSU firmware update, where internally\nit invokes `psutils` as well.\n\n## Usage\n\n### PSU version\n\nWhen the service starts, it queries the inventory to get all the PSU inventory\npaths, invokes the vendor-specific tool to get the versions, and creates version\nobjects under `/xyz/openbmc_project/software` that are associated with the PSU\ninventory path. If multiple PSUs are using the same version, multiple PSU\ninventory paths are associated.\n\nE.g.\n\n- Example of system with two PSUs that have different versions:\n\n  ```text\n   \"/xyz/openbmc_project/software/02572429\": {\n     \"Activation\": \"xyz.openbmc_project.Software.Activation.Activations.Active\",\n     \"Associations\": [\n       [\n         \"inventory\",\n         \"activation\",\n         \"/xyz/openbmc_project/inventory/system/chassis/motherboard/powersupply1\"\n       ]\n     ],\n     \"ExtendedVersion\": \"\",\n     \"Path\": \"\",\n     \"Purpose\": \"xyz.openbmc_project.Software.Version.VersionPurpose.PSU\",\n     \"RequestedActivation\": \"xyz.openbmc_project.Software.Activation.RequestedActivations.None\",\n     \"Version\": \"01120114\"\n   },\n   \"/xyz/openbmc_project/software/7094f612\": {\n     \"Activation\": \"xyz.openbmc_project.Software.Activation.Activations.Active\",\n     \"Associations\": [\n       [\n         \"inventory\",\n         \"activation\",\n         \"/xyz/openbmc_project/inventory/system/chassis/motherboard/powersupply0\"\n       ]\n     ],\n     \"ExtendedVersion\": \"\",\n     \"Path\": \"\",\n     \"Purpose\": \"xyz.openbmc_project.Software.Version.VersionPurpose.PSU\",\n     \"RequestedActivation\": \"xyz.openbmc_project.Software.Activation.RequestedActivations.None\",\n     \"Version\": \"00000110\"\n   },\n  ```\n\n- Example of system with two PSUs that have the same version:\n\n  ```text\n   \"/xyz/openbmc_project/software/9463c2ad\": {\n     \"Activation\": \"xyz.openbmc_project.Software.Activation.Activations.Active\",\n     \"Associations\": [\n       [\n         \"inventory\",\n         \"activation\",\n         \"/xyz/openbmc_project/inventory/system/chassis/motherboard/powersupply0\"\n       ],\n       [\n         \"inventory\",\n         \"activation\",\n         \"/xyz/openbmc_project/inventory/system/chassis/motherboard/powersupply1\"\n       ]\n     ],\n     \"ExtendedVersion\": \"\",\n     \"Path\": \"\",\n     \"Purpose\": \"xyz.openbmc_project.Software.Version.VersionPurpose.PSU\",\n     \"RequestedActivation\": \"xyz.openbmc_project.Software.Activation.RequestedActivations.None\",\n     \"Version\": \"01100110\"\n   },\n  ```\n\n### PSU update\n\n1. Generate a tarball of PSU firmware image by [generate-psu-tar tool][4].\n\n   ```text\n   ./generate-psu-tar --image \u003cpsu-image\u003e --version \u003cversion\u003e --model \u003cmodel\u003e --manufacturer \\\n   \u003cmanufacturer\u003e --machineName \u003cmachineName\u003e --outfile \u003cpsu.tar\u003e --sign\n   ```\n\n2. To update the PSU firmware, follow the same steps as described in\n   [code-update.md][5]:\n   - Upload a PSU image tarball and get the version ID;\n   - Set the RequestedActivation state of the uploaded image's version ID.\n   - Check the state and wait for the activation to be completed.\n3. After a successful update, the PSU image and the manifest is stored in BMC's\n   persistent storage defined by `IMG_DIR_PERSIST`. When a PSU is replaced, the\n   PSU's firmware version will be checked and updated if it's older than the one\n   stored in BMC.\n4. It is possible to put a PSU image and MANIFEST in the built-in OpenBMC image\n   in BMC's read-only filesystem defined by `IMG_DIR_BUILTIN`. When the service\n   starts, it will compare the versions of the built-in image and the existing\n   PSUs. If there is any PSU that has older firmware, it will be updated to the\n   new firmware.\n\n[1]: https://github.com/openbmc/docs/blob/master/testing/local-ci-build.md\n[2]:\n  https://github.com/openbmc/docs/blob/master/cheatsheet.md#building-the-openbmc-sdk\n[3]: https://github.com/openbmc/phosphor-power/tree/master/tools/power-utils\n[4]:\n  https://github.com/openbmc/phosphor-psu-code-mgmt/blob/master/tools/generate-psu-tar\n[5]:\n  https://github.com/openbmc/docs/blob/master/architecture/code-update/code-update.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenbmc%2Fphosphor-psu-code-mgmt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenbmc%2Fphosphor-psu-code-mgmt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenbmc%2Fphosphor-psu-code-mgmt/lists"}