xref: /openbmc/docs/designs/psu-firmware-update.md (revision 58d4966355eadde8ae8700d05d94c9c6ce0c36f0)
111d810dbSLei YU# PSU firmware update
211d810dbSLei YU
3f4febd00SPatrick WilliamsAuthor: Lei YU <mine260309@gmail.com> <LeiYU>
411d810dbSLei YU
5f4febd00SPatrick WilliamsOther contributors: Su Xiao <suxiao@inspur.com> Derek Howard <derekh@us.ibm.com>
611d810dbSLei YU
7f4febd00SPatrick WilliamsCreated: 2019-06-03
811d810dbSLei YU
911d810dbSLei YU## Problem Description
1011d810dbSLei YU
1111d810dbSLei YUThere is no support in OpenBMC to update the firmware for PSUs.
1211d810dbSLei YU
1311d810dbSLei YU## Background and References
1411d810dbSLei YU
1511d810dbSLei YUIn OpenBMC, there is an existing interface for [software update][1].
1611d810dbSLei YU
1711d810dbSLei YUThe update process consists of:
18f4febd00SPatrick Williams
1911d810dbSLei YU1. Uploading an image to the BMC;
2011d810dbSLei YU2. Processing the image to check the version and purpose of the image;
2111d810dbSLei YU3. Verifying and activating the image.
2211d810dbSLei YU
2311d810dbSLei YUCurrently, BMC and BIOS firmware update are supported:
24f4febd00SPatrick Williams
25f4febd00SPatrick Williams- [phosphor-bmc-code-mgmt][2] implements BMC code update, and it supports all
2611d810dbSLei YU  the above 3 processes.
27f4febd00SPatrick Williams- [openpower-pnor-code-mgmt][3] implements BIOS code update, and it only
28f4febd00SPatrick Williams  implements "verifying and activating" the image. It shares the function of the
29f4febd00SPatrick Williams  above 1 & 2 processes.
30f4febd00SPatrick Williams- Both of the above use the same [Software DBus interface][1].
3111d810dbSLei YU
3211d810dbSLei YUFor PSU firmware update, it is preferred to re-use the same function for the
3311d810dbSLei YUabove 1 & 2.
3411d810dbSLei YU
3511d810dbSLei YU## Requirements
3611d810dbSLei YU
3711d810dbSLei YUThe PSU firmware shall be updated in the below cases:
38f4febd00SPatrick Williams
3911d810dbSLei YU1. The user manually invokes the APIs to do the update;
4011d810dbSLei YU2. After BMC code update and if there is a newer PSU image in the BMC's
4111d810dbSLei YU   filesystem, BMC shall update the PSU firmware;
4211d810dbSLei YU3. When a PSU is replaced and the version is older than the one in BMC's
4311d810dbSLei YU   filesystem, BMC shall update the PSU firmware.
44*58d49663SDerek Howard4. An optional 'override' parameter may be specified to do the update in the
45*58d49663SDerek Howard   above cases regardless of which PSU image is newer.
46*58d49663SDerek Howard5. There are cases that a system could use different models of PSUs, and thus
4711d810dbSLei YU   different PSU firmware images need to be supported.
4811d810dbSLei YU
4911d810dbSLei YUFor some PSUs, it is risky to do PSU code update while the host is running to
50f4febd00SPatrick Williamsavoid power loss. This shall be handled by PSU vendor-specific tools, but not in
51f4febd00SPatrick Williamsthe generic framework.
5211d810dbSLei YU
5311d810dbSLei YUNote: The "vendor-specific" referred below is the PSU vendor-specific.
5411d810dbSLei YU
5511d810dbSLei YUSo the below checks are optional and expected to be handled by vendor-specific
5611d810dbSLei YUtool:
57f4febd00SPatrick Williams
5811d810dbSLei YU1. If the host is powered off;
5911d810dbSLei YU2. If the redundant PSUs are all connected;
6011d810dbSLei YU3. If the AC input and DC standby output is OK on all the PSUs;
6111d810dbSLei YU
6211d810dbSLei YU## Proposed Design
6311d810dbSLei YU
64f4febd00SPatrick WilliamsAs described in the above requirements, there are different cases where the PSU
65f4febd00SPatrick Williamsfirmware is updated:
66f4febd00SPatrick Williams
67f4febd00SPatrick Williams- When the APIs are invoked;
68f4febd00SPatrick Williams- When a new version is updated together with BMC code update;
69f4febd00SPatrick Williams- When a PSU is replaced with an old version of the firmware.
7011d810dbSLei YU
7111d810dbSLei YU### Update by API
7211d810dbSLei YU
7311d810dbSLei YUThis method is usually used by users who manually update PSU firmware.
7411d810dbSLei YU
75f4febd00SPatrick WilliamsIt will re-use the current interfaces to upload, verify, and activate the image.
7611d810dbSLei YU
7711d810dbSLei YU1. The "Version" interface needs to be extended:
78f4febd00SPatrick Williams   - Add a new [VersionPurpose][4] for PSU;
79f4febd00SPatrick Williams   - Re-use the existing `ExtendedVersion` as an additional string for
8011d810dbSLei YU     vendor-specific purpose, e.g. to indicate the PSU model.
8111d810dbSLei YU2. Re-use the existing functions implemented by [phosphor-bmc-code-mgmt][2] for
8211d810dbSLei YU   uploading and processing the image.
83f4febd00SPatrick Williams   - The PSU update image shall be a tarball that consists of a MANIFEST,
8411d810dbSLei YU     images, and signatures.
85f4febd00SPatrick Williams   - When the PSU image is uploaded and processed, a `VersionObject` shall be
8611d810dbSLei YU     created to indicate the version and its purpose.
8711d810dbSLei YU3. There will be a new service that implements the [Activation][5] interface to
8811d810dbSLei YU   update the PSU firmware.
89f4febd00SPatrick Williams   - The service will be started by default when BMC starts;
90f4febd00SPatrick Williams   - On start, the service will check the PSU's existing firmware and create the
91f4febd00SPatrick Williams     `Version` and `Activation` interfaces.
92f4febd00SPatrick Williams   - The service shall watch the interface added on
9311d810dbSLei YU     `/xyz/openbmc_project/Software`.
94f4febd00SPatrick Williams   - When a new object with PSU `VersionPurpose` is added, the service will
9511d810dbSLei YU     verify the signature of the image;
96f4febd00SPatrick Williams   - The service shall check the `ExtendedVersion` to make sure the image
9711d810dbSLei YU     matches the PSU model.
98f4febd00SPatrick Williams   - The service will have a configuration file to describe the PSU model and
9911d810dbSLei YU     its related vendor-specific tools.
100f4febd00SPatrick Williams   - The service will find the matched vendor-specific tool to perform the code
101f4febd00SPatrick Williams     update. For example, if a vendor specific tool `foo` is configured in
10211d810dbSLei YU     `psu-update@foo.service` which executes `foo psu.bin`, the service will
10311d810dbSLei YU     find the `psu-update@foo.service` and start it by systemd, which performs
10411d810dbSLei YU     the update.
105f4febd00SPatrick Williams   - When the PSU code update is completed, an informational event log shall be
10611d810dbSLei YU     created.
107f4febd00SPatrick Williams   - When the PSU code update is completed, the image, MANIFEST, and optionally
10811d810dbSLei YU     the signature will be saved to a pre-defined directory in read-write
10911d810dbSLei YU     filesystem for future use, in case a new PSU with old firmware is plugged.
11011d810dbSLei YU4. The vendor-specific tool shall run all the checks it needs to be run, before
11111d810dbSLei YU   and after the PSU update, and return a status to the above service to
11211d810dbSLei YU   indicate the result.
11311d810dbSLei YU5. When the vendor-specific tool returns errors, the PSU update will be aborted
11411d810dbSLei YU   and an error event log shall be created.
11511d810dbSLei YU6. During the update, the service shall set the related sensors to
116f4febd00SPatrick Williams   non-functional, and when the update is done, it shall set the related sensors
117f4febd00SPatrick Williams   back to functional.
11811d810dbSLei YU
11911d810dbSLei YU### Update by new BMC image
12011d810dbSLei YU
12111d810dbSLei YUWhen BMC is updated and a new version of PSU firmware is included, it shall be
122f4febd00SPatrick Williamsupdated to the PSU. This will be done by the same service described above.
12311d810dbSLei YU
12411d810dbSLei YU1. On start, the service will check the PSU image, model and version in its
12511d810dbSLei YU   filesystem, compare with the ones in PSU hardware and decide if PSU firmware
12611d810dbSLei YU   update shall be performed.
12711d810dbSLei YU2. There could be two places containing the PSU images:
128f4febd00SPatrick Williams   - The pre-defined directory in read-only filesystem, which is part of BMC
12911d810dbSLei YU     image.
130f4febd00SPatrick Williams   - The other pre-defined directory in read-write filesystem, which is the
131f4febd00SPatrick Williams     location for the saved PSU images by API update. Both places shall be
132f4febd00SPatrick Williams     checked and a newer version will be selected to compare with the PSU
133f4febd00SPatrick Williams     hardware.
13411d810dbSLei YU3. If PSU update is needed, the service will find the matched vendor-specific
13511d810dbSLei YU   tool to perform the code update.
13611d810dbSLei YU4. The following process will be the same as [Update by API].
13711d810dbSLei YU
13811d810dbSLei YU### Update on replaced PSU
13911d810dbSLei YU
14011d810dbSLei YUWhen a PSU is replaced, and the firmware version is older than the one in BMC
141*58d49663SDerek Howardfilesystem (or if the optional 'override' parameter is specified), it shall be
142*58d49663SDerek Howardupdated. This will be done by the same service described above.
14311d810dbSLei YU
144f4febd00SPatrick Williams1. On start, the service will subscribe to the PropertiesChanged signal to the
145f4febd00SPatrick Williams   PSU object path to monitor the PSU presence status. (Or maybe subscribe the
146f4febd00SPatrick Williams   InterfacesAdded/Removed signal?)
14711d810dbSLei YU2. When a PSU's presence status is changed from false to true (or the
148*58d49663SDerek Howard   PropertiesChanged event occurs), the service will check the new PSU's model
149*58d49663SDerek Howard   and firmware version to decide if the firmware needs to be updated.
150f4febd00SPatrick Williams3. If yes, the service will find the matched vendor-specific tool to perform the
151f4febd00SPatrick Williams   code update.
15211d810dbSLei YU4. The following process will be the same as [Update by API].
15311d810dbSLei YU
15411d810dbSLei YU## Alternatives Considered
15511d810dbSLei YU
15611d810dbSLei YU### General implementation
15711d810dbSLei YU
158f4febd00SPatrick WilliamsThe PSU firmware update could be implemented by separated recipes that only call
159f4febd00SPatrick Williamsvendor-specific tools. It will be a bit simpler but loses the unified interface
160f4febd00SPatrick Williamsprovided by OpenBMC's existing [software update interface][1], and thus it will
161f4febd00SPatrick Williamsbecome difficult to use a standard API to the PSU firmware update.
16211d810dbSLei YU
16311d810dbSLei YU### VersionPurpose
164f4febd00SPatrick Williams
165f4febd00SPatrick WilliamsIt is possible to re-use the `VersionPurpose.Other` to represent the PSU image's
166f4febd00SPatrick Williamsversion purpose. But that requires additional information about the image,
167f4febd00SPatrick Williamsotherwise, there is no way to tell if the image is for PSU, or CPLD, or other
168f4febd00SPatrick Williamsperipherals. A new `VersionPurpose.PSU` is more specific and makes it easier to
169f4febd00SPatrick Williamsimplement and friendly for the user.
17011d810dbSLei YU
17111d810dbSLei YU### Additional string
172f4febd00SPatrick Williams
17311d810dbSLei YUThe design proposal uses `ExtendedVersion` as the additional string for
17411d810dbSLei YUvendor-specific purpose, e.g. to indicate the PSU model, so the implementation
175f4febd00SPatrick Williamscould check and compare if the image matches the PSU model. It is possible to
176f4febd00SPatrick Williamsmake it optional or remove this additional string, then the implementation will
177f4febd00SPatrick Williamsnot verify if the image matches the PSU. It could be OK if we trust the user who
178f4febd00SPatrick Williamsis uploading the correct image, especially the image shall be signed. But it is
179f4febd00SPatrick Williamsalways risky in case the image does not match the PSU, and cause unintended
180f4febd00SPatrick Williamsdamage if the incorrect PSU firmware is updated.
18111d810dbSLei YU
18211d810dbSLei YU## Impacts
18311d810dbSLei YU
18411d810dbSLei YUThis design only introduces a new `VersionPurpose` enum into the dbus
185f4febd00SPatrick Williamsinterfaces. The newly introduced PSU firmware update service will be a new
186f4febd00SPatrick Williamsservice that implements existing [Activation][5] interface. There will be new
187f4febd00SPatrick Williamsconfiguration files for the service to:
188f4febd00SPatrick Williams
189f4febd00SPatrick Williams- Link the vendor specific tool with PSU models.
190f4febd00SPatrick Williams- Get the sensors related to the PSU.
191f4febd00SPatrick Williams- etc.
19211d810dbSLei YU
19311d810dbSLei YUSo the impacts are minimal to existing systems.
19411d810dbSLei YU
19511d810dbSLei YU## Testing
19611d810dbSLei YU
19711d810dbSLei YUIt requires the manual tests to verify the PSU code update process.
198f4febd00SPatrick Williams
199f4febd00SPatrick Williams- Verify the PSU code update is done on all PSUs successfully;
200f4febd00SPatrick Williams- Verify the PSU code update will fail if the vendor-specific tool fails on
20111d810dbSLei YU  pre-condition check, of fails on updating PSU.
202f4febd00SPatrick Williams- Verify the PSU code update is performed after a new BMC image is updated
203*58d49663SDerek Howard  containing a new (or different, if 'override' used) version of PSU firmware.
204*58d49663SDerek Howard- Verify the PSU code update is performed after a PSU with old (or different, if
205*58d49663SDerek Howard  'override' is used) firmware is plugged in.
20611d810dbSLei YU
207f4febd00SPatrick Williams[1]:
208f4febd00SPatrick Williams  https://github.com/openbmc/phosphor-dbus-interfaces/tree/master/yaml/xyz/openbmc_project/Software
20911d810dbSLei YU[2]: https://github.com/openbmc/phosphor-bmc-code-mgmt/
21011d810dbSLei YU[3]: https://github.com/openbmc/openpower-pnor-code-mgmt/
211f4febd00SPatrick Williams[4]:
212f4febd00SPatrick Williams  https://github.com/openbmc/phosphor-dbus-interfaces/blob/57b878d048f929643276f1bf7fdf750abc4bde8b/xyz/openbmc_project/Software/Version.interface.yaml#L14
213f4febd00SPatrick Williams[5]:
214f4febd00SPatrick Williams  https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/Software/Activation.interface.yaml
215