1# PSU firmware update 2 3Author: Lei YU <mine260309@gmail.com> <LeiYU> 4 5Other contributors: Su Xiao <suxiao@inspur.com> Derek Howard <derekh@us.ibm.com> 6 7Created: 2019-06-03 8 9## Problem Description 10 11There is no support in OpenBMC to update the firmware for PSUs. 12 13## Background and References 14 15In OpenBMC, there is an existing interface for [software update][1]. 16 17The update process consists of: 18 191. Uploading an image to the BMC; 202. Processing the image to check the version and purpose of the image; 213. Verifying and activating the image. 22 23Currently, BMC and BIOS firmware update are supported: 24 25- [phosphor-bmc-code-mgmt][2] implements BMC code update, and it supports all 26 the above 3 processes. 27- [openpower-pnor-code-mgmt][3] implements BIOS code update, and it only 28 implements "verifying and activating" the image. It shares the function of the 29 above 1 & 2 processes. 30- Both of the above use the same [Software DBus interface][1]. 31 32For PSU firmware update, it is preferred to re-use the same function for the 33above 1 & 2. 34 35## Requirements 36 37The PSU firmware shall be updated in the below cases: 38 391. The user manually invokes the APIs to do the update; 402. After BMC code update and if there is a newer PSU image in the BMC's 41 filesystem, BMC shall update the PSU firmware; 423. When a PSU is replaced and the version is older than the one in BMC's 43 filesystem, BMC shall update the PSU firmware. 444. There are cases that a system could use different models of PSUs, and thus 45 different PSU firmware images need to be supported. 46 47For some PSUs, it is risky to do PSU code update while the host is running to 48avoid power loss. This shall be handled by PSU vendor-specific tools, but not in 49the generic framework. 50 51Note: The "vendor-specific" referred below is the PSU vendor-specific. 52 53So the below checks are optional and expected to be handled by vendor-specific 54tool: 55 561. If the host is powered off; 572. If the redundant PSUs are all connected; 583. If the AC input and DC standby output is OK on all the PSUs; 59 60## Proposed Design 61 62As described in the above requirements, there are different cases where the PSU 63firmware is updated: 64 65- When the APIs are invoked; 66- When a new version is updated together with BMC code update; 67- When a PSU is replaced with an old version of the firmware. 68 69### Update by API 70 71This method is usually used by users who manually update PSU firmware. 72 73It will re-use the current interfaces to upload, verify, and activate the image. 74 751. The "Version" interface needs to be extended: 76 - Add a new [VersionPurpose][4] for PSU; 77 - Re-use the existing `ExtendedVersion` as an additional string for 78 vendor-specific purpose, e.g. to indicate the PSU model. 792. Re-use the existing functions implemented by [phosphor-bmc-code-mgmt][2] for 80 uploading and processing the image. 81 - The PSU update image shall be a tarball that consists of a MANIFEST, 82 images, and signatures. 83 - When the PSU image is uploaded and processed, a `VersionObject` shall be 84 created to indicate the version and its purpose. 853. There will be a new service that implements the [Activation][5] interface to 86 update the PSU firmware. 87 - The service will be started by default when BMC starts; 88 - On start, the service will check the PSU's existing firmware and create the 89 `Version` and `Activation` interfaces. 90 - The service shall watch the interface added on 91 `/xyz/openbmc_project/Software`. 92 - When a new object with PSU `VersionPurpose` is added, the service will 93 verify the signature of the image; 94 - The service shall check the `ExtendedVersion` to make sure the image 95 matches the PSU model. 96 - The service will have a configuration file to describe the PSU model and 97 its related vendor-specific tools. 98 - The service will find the matched vendor-specific tool to perform the code 99 update. For example, if a vendor specific tool `foo` is configured in 100 `psu-update@foo.service` which executes `foo psu.bin`, the service will 101 find the `psu-update@foo.service` and start it by systemd, which performs 102 the update. 103 - When the PSU code update is completed, an informational event log shall be 104 created. 105 - When the PSU code update is completed, the image, MANIFEST, and optionally 106 the signature will be saved to a pre-defined directory in read-write 107 filesystem for future use, in case a new PSU with old firmware is plugged. 1084. The vendor-specific tool shall run all the checks it needs to be run, before 109 and after the PSU update, and return a status to the above service to 110 indicate the result. 1115. When the vendor-specific tool returns errors, the PSU update will be aborted 112 and an error event log shall be created. 1136. During the update, the service shall set the related sensors to 114 non-functional, and when the update is done, it shall set the related sensors 115 back to functional. 116 117### Update by new BMC image 118 119When BMC is updated and a new version of PSU firmware is included, it shall be 120updated to the PSU. This will be done by the same service described above. 121 1221. On start, the service will check the PSU image, model and version in its 123 filesystem, compare with the ones in PSU hardware and decide if PSU firmware 124 update shall be performed. 1252. There could be two places containing the PSU images: 126 - The pre-defined directory in read-only filesystem, which is part of BMC 127 image. 128 - The other pre-defined directory in read-write filesystem, which is the 129 location for the saved PSU images by API update. Both places shall be 130 checked and a newer version will be selected to compare with the PSU 131 hardware. 1323. If PSU update is needed, the service will find the matched vendor-specific 133 tool to perform the code update. 1344. The following process will be the same as [Update by API]. 135 136### Update on replaced PSU 137 138When a PSU is replaced, and the firmware version is older than the one in BMC 139filesystem, it shall be updated. This will be done by the same service described 140above. 141 1421. On start, the service will subscribe to the PropertiesChanged signal to the 143 PSU object path to monitor the PSU presence status. (Or maybe subscribe the 144 InterfacesAdded/Removed signal?) 1452. When a PSU's presence status is changed from false to true (or the 146 InterfacesAdded event occurs), the service will check the new PSU's model, 147 firmware version to decide if the firmware needs to be updated. 1483. If yes, the service will find the matched vendor-specific tool to perform the 149 code update. 1504. The following process will be the same as [Update by API]. 151 152## Alternatives Considered 153 154### General implementation 155 156The PSU firmware update could be implemented by separated recipes that only call 157vendor-specific tools. It will be a bit simpler but loses the unified interface 158provided by OpenBMC's existing [software update interface][1], and thus it will 159become difficult to use a standard API to the PSU firmware update. 160 161### VersionPurpose 162 163It is possible to re-use the `VersionPurpose.Other` to represent the PSU image's 164version purpose. But that requires additional information about the image, 165otherwise, there is no way to tell if the image is for PSU, or CPLD, or other 166peripherals. A new `VersionPurpose.PSU` is more specific and makes it easier to 167implement and friendly for the user. 168 169### Additional string 170 171The design proposal uses `ExtendedVersion` as the additional string for 172vendor-specific purpose, e.g. to indicate the PSU model, so the implementation 173could check and compare if the image matches the PSU model. It is possible to 174make it optional or remove this additional string, then the implementation will 175not verify if the image matches the PSU. It could be OK if we trust the user who 176is uploading the correct image, especially the image shall be signed. But it is 177always risky in case the image does not match the PSU, and cause unintended 178damage if the incorrect PSU firmware is updated. 179 180## Impacts 181 182This design only introduces a new `VersionPurpose` enum into the dbus 183interfaces. The newly introduced PSU firmware update service will be a new 184service that implements existing [Activation][5] interface. There will be new 185configuration files for the service to: 186 187- Link the vendor specific tool with PSU models. 188- Get the sensors related to the PSU. 189- etc. 190 191So the impacts are minimal to existing systems. 192 193## Testing 194 195It requires the manual tests to verify the PSU code update process. 196 197- Verify the PSU code update is done on all PSUs successfully; 198- Verify the PSU code update will fail if the vendor-specific tool fails on 199 pre-condition check, of fails on updating PSU. 200- Verify the PSU code update is performed after a new BMC image is updated 201 containing a new version of PSU firmware. 202- Verify the PSU code update is performed after a PSU with old firmware is 203 plugged in. 204 205[1]: 206 https://github.com/openbmc/phosphor-dbus-interfaces/tree/master/yaml/xyz/openbmc_project/Software 207[2]: https://github.com/openbmc/phosphor-bmc-code-mgmt/ 208[3]: https://github.com/openbmc/openpower-pnor-code-mgmt/ 209[4]: 210 https://github.com/openbmc/phosphor-dbus-interfaces/blob/57b878d048f929643276f1bf7fdf750abc4bde8b/xyz/openbmc_project/Software/Version.interface.yaml#L14 211[5]: 212 https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/Software/Activation.interface.yaml 213