xref: /openbmc/phosphor-dbus-interfaces/yaml/xyz/openbmc_project/Software/README.md (revision 18b5dd4757b8c96e028e80efc5843d635ef095da)
1b1b4d261SWilliam A. Kennington III# Software Version Management and Image Update
2b1b4d261SWilliam A. Kennington III
3b1b4d261SWilliam A. Kennington III## Overview
4b1b4d261SWilliam A. Kennington III
5b1b4d261SWilliam A. Kennington IIIThere are two types of processes involved in software version management and
6b1b4d261SWilliam A. Kennington IIIcode update:
7b1b4d261SWilliam A. Kennington III
8388b58f9SPatrick Williams1. _ImageManager_ - This is a process which manages a collection of, likely
9a1347418SPatrick Williams   temporary, images located somewhere in a file system. These are images which
10a1347418SPatrick Williams   are available on the BMC for update.
11388b58f9SPatrick Williams2. _ItemUpdater_ - This is a process which manages specific storage elements,
12a1347418SPatrick Williams   likely for an inventory item, to determine which software versions are
13a1347418SPatrick Williams   installed onto that item. A specific example of this would be a process that
14a1347418SPatrick Williams   controls and updates the BIOS flash module for a managed host.
15b1b4d261SWilliam A. Kennington III
16388b58f9SPatrick WilliamsA simple system design would be to include a single _ImageManager_ and two
1756936f52SPatrick Williams_ItemUpdater_(s): one for the BMC itself and one for the Host.
18b1b4d261SWilliam A. Kennington III
19b1b4d261SWilliam A. Kennington III### ImageManager
20b1b4d261SWilliam A. Kennington III
21388b58f9SPatrick WilliamsThe _ImageManager_ would provide interfaces at `/xyz/openbmc_project/software`
22a1347418SPatrick Williamsto allow additional images to be added to the BMC, such as Object.Add() for REST
23a1347418SPatrick Williamsand DownloadViaTFTP() for TFTP. The standard Object.Delete() interface would
24a1347418SPatrick Williamsalso be provided to facilitate removing images which are no longer needed.
25a1347418SPatrick WilliamsImages maintained in the file system would be presented as a corresponding
26a1347418SPatrick Williams`/xyz/openbmc_project/software/<id>` object. In addition, the
27a1347418SPatrick Williams`xyz.openbmc_project.Common.FilePath` interface would be provided to specify the
28a1347418SPatrick Williamslocation of the image.
29b1b4d261SWilliam A. Kennington III
30*18b5dd47SPatrick WilliamsIt is assumed that the _ImageManager_ has [at least] a bare minimum amount of
31*18b5dd47SPatrick Williamsparsing knowledge, perhaps due to a common image format, to allow it to populate
32*18b5dd47SPatrick Williamsall of the properties of `xyz.openbmc_project.Software.Version` and
33*18b5dd47SPatrick Williams`xyz.openbmc_project.Inventory.Decorator.Compatible`. _ItemUpdater_(s) will
34*18b5dd47SPatrick Williamslikely listen for standard D-Bus signals to identify new images being created.
35b1b4d261SWilliam A. Kennington III
36ac7adcb5SCarlos J. Mazieri### ItemUpdater
37b1b4d261SWilliam A. Kennington III
38388b58f9SPatrick WilliamsThe _ItemUpdater_ is responsible for monitoring for new `Software.Version`
39a1347418SPatrick Williamselements being created to identify versions that are applicable to the inventory
40a1347418SPatrick Williamselement(s) it is managing. The _ItemUpdater_ should dynamically create an
41a1347418SPatrick Williams`xyz.openbmc_project.Software.Activation` interface under
42b1b4d261SWilliam A. Kennington III`/xyz/openbmc_project/software/`, an association of type
43b1b4d261SWilliam A. Kennington III`{active_image,software_version}` between the `Software.Version` and
44a1347418SPatrick Williams`Software.Activation` under `/xyz/openbmc_project/software/`, and an association
45a1347418SPatrick Williamsof type `{activation,item}` between the `Inventory.Item` and
46a1347418SPatrick Williams`Software.Activation` under `/xyz/openbmc_project/software/<id>`. Application of
47a1347418SPatrick Williamsthe software image is then handled through the `RequestedActivation` property of
48a1347418SPatrick Williamsthe `Software.Activation` interface.
49ac7adcb5SCarlos J. Mazieri
50388b58f9SPatrick WilliamsIn many cases, the _ItemUpdater_'s creation of the `Software.Activation`
51388b58f9SPatrick Williamsinterface will be at the exact same path as the _ImageManager_'s
52ac7adcb5SCarlos J. Mazieri`Software.Version` instance (ie. `/xyz/openbmc_project/software/<id>`). This is
53ac7adcb5SCarlos J. Mazieriappropriate when the software image can be applied to exactly one device in the
54ac7adcb5SCarlos J. Mazierisystem at exactly one storage location. In cases where multiple devices could
55ac7adcb5SCarlos J. Mazieriupdated with the same image or multiple locations in the same device could hold
56ac7adcb5SCarlos J. Mazierithe same image (such as a primary / secondary flash bank relationship), the
57388b58f9SPatrick Williams_ItemUpdater_ should create `Software.Activation` interfaces as a sub-path of
58ac7adcb5SCarlos J. Mazierithe corresponding image, such as `/xyz/openbmc_project/software/<id>/<device>`.
59b1b4d261SWilliam A. Kennington III
60388b58f9SPatrick WilliamsThe _ItemUpdater_ should, if possible, also create its own
61a1347418SPatrick Williams`xyz.openbmc_project.Software.Version` objects, and appropriate associations for
62a1347418SPatrick Williamssoftware versions that are currently present on the managed inventory
63a1347418SPatrick Williamselement(s). This provides a mechanism for interrogation of the software versions
64a1347418SPatrick Williamswhen the _ImageManager_ no longer contains a copy.
65b1b4d261SWilliam A. Kennington III
66b1b4d261SWilliam A. Kennington III## Details
67b1b4d261SWilliam A. Kennington III
68b1b4d261SWilliam A. Kennington III### Image Identifier
69b1b4d261SWilliam A. Kennington III
70388b58f9SPatrick WilliamsThe _ImageManager_ and _ItemUpdater_ should use a common, though perhaps
71b1b4d261SWilliam A. Kennington IIIimplementation specific, algorithm for the `<id>` portion of a D-Bus path for
72b1b4d261SWilliam A. Kennington IIIeach `Software.Version`. This allows the same software version to be contained
73b1b4d261SWilliam A. Kennington IIIin multiple locations but represented by the same object path.
74b1b4d261SWilliam A. Kennington III
75b1b4d261SWilliam A. Kennington IIIA reasonable algorithm might be:
76f05e2050SPatrick Williams`echo <Version.Version> <Compatible.Names> | sha512sum | cut -b 1-8`
77f05e2050SPatrick Williams
78f05e2050SPatrick Williams### Compatibility
79f05e2050SPatrick Williams
80f05e2050SPatrick WilliamsIdentifying that a particular Software image is for a particular system element
81f05e2050SPatrick Williamscan be challenging. For the BMC, two different images may both be the same size
82f05e2050SPatrick Williamsbut for vastly different hardware. If the image for one system is applied onto
83f05e2050SPatrick Williamsthe BMC for another it is quite possible that the image won't even boot
84f05e2050SPatrick Williamsproperly. It is therefore important to be able to specify more details than
85f05e2050SPatrick Williamssimply "BMC" or "Host".
86f05e2050SPatrick Williams
87f05e2050SPatrick WilliamsEarly on implementations used the `Software.Version.Purpose` property and a
88f05e2050SPatrick Williamscustom string in the `Software.ExtendedVersion` to align software images with
89f05e2050SPatrick Williamsappropriate hardware. This lead to an ever-increasing set of `Purpose`
90f05e2050SPatrick Williamsenumeration values and inconsistent implementations of software update routines.
91f05e2050SPatrick Williams
92f05e2050SPatrick WilliamsThe `Inventory.Decorator.Compatible` interface was introduced to give
93f05e2050SPatrick Williamsidentifiers that can be used to map to common software implementations, in a
94f05e2050SPatrick Williamssimilar manner to how the Linux Device Tree compatible strings are used.
95f05e2050SPatrick WilliamsSoftware update should leverage these `Compatible.Names` properties to create a
96f05e2050SPatrick Williamsconsistent mapping of `Software.Version` instances to the system element the
97f05e2050SPatrick Williamsimage is applicable to.
98f05e2050SPatrick Williams
99388b58f9SPatrick WilliamsAt the same path as the `Software.Version`, an _ImageManager_ should create an
100f05e2050SPatrick Williams`xyz.openbmc_project.Inventory.Decorator.Compatible` interface containing
101f05e2050SPatrick Williamsstrings identifying the system element this image can be applied to.
102f05e2050SPatrick WilliamsCorrespondingly, the Inventory Item corresponding to the system element should
103f05e2050SPatrick Williamshave the same string in its `Inventory.Decorator.Compatible` interface. These
104f05e2050SPatrick Williamsstrings shall be of the following format:
105f05e2050SPatrick Williams
106921791c7SManojkiran Eda- `<org>.Software.Element.<identifier>.Type.<type>`
107f05e2050SPatrick Williams
108f05e2050SPatrick WilliamsWhere:
109f05e2050SPatrick Williams
110388b58f9SPatrick Williams- `<org>` corresponds to the organization owning the `<identifier>`, such as
111f05e2050SPatrick Williams  `xyz.openbmc_project` or `com.foo_corp`.
112388b58f9SPatrick Williams- `<identifier>` is a unique name for the element, such as `SystemFoo` or
113f05e2050SPatrick Williams  `BoardBar`. Typically these would be code names for the hardware element such
114f05e2050SPatrick Williams  as `Witherspoon`.
115388b58f9SPatrick Williams- `<type>` is an identifier for sub-element the image corresponds to and is
116f05e2050SPatrick Williams  documented in the `<org>/Software/Element/<identifier>.interface` file under
117f05e2050SPatrick Williams  the `Type` enumeration.
118f05e2050SPatrick Williams
119f05e2050SPatrick WilliamsThe following `<type>` are reserved for a particular meaning:
120f05e2050SPatrick Williams
121f05e2050SPatrick Williams- BMC - The image is for the BMC contained on that element.
122f05e2050SPatrick Williams- Host - The image is the primary firmware for the managed host contained on
123f05e2050SPatrick Williams  that element.
124f05e2050SPatrick Williams
125f05e2050SPatrick WilliamsIf an image contains sub-sections which can be applied to multiple system
126a1347418SPatrick Williamselements, the image should contain `Compatible` strings for each sub-section. It
127a1347418SPatrick Williamsis expected that the _ItemUpdater_ is aware of how to find the sub-section
128f05e2050SPatrick Williamsappropriate for any element(s) being Activated.
129b1b4d261SWilliam A. Kennington III
130b1b4d261SWilliam A. Kennington III### Activation States
131b1b4d261SWilliam A. Kennington III
132a1347418SPatrick Williams`xyz.openbmc_project.Software.Activation` has a property Activation that can be
133a1347418SPatrick Williamsin the following states:
134b1b4d261SWilliam A. Kennington III
135388b58f9SPatrick Williams1. _NotReady_ - Indicating that the _ItemUpdater_ is still processing the
136a1347418SPatrick Williams   version and it is therefore not ready for activation. This might be used on
137a1347418SPatrick Williams   an image that has a security header while verification is being performed.
138388b58f9SPatrick Williams2. _Invalid_ - Indicating that, while the `Software.Version.Purpose` suggested
139a1347418SPatrick Williams   the image was valid for a managed element, a detailed analysis by the
140a1347418SPatrick Williams   _ItemUpdater_ showed that it was not. Reasons may include image corruption
141a1347418SPatrick Williams   detected via CRC or security verification failure. An event may be recorded
142a1347418SPatrick Williams   with additional details.
143388b58f9SPatrick Williams3. _Ready_ - Indicating that the `Software.Version` can be activated.
144388b58f9SPatrick Williams4. _Activating_ - Indicating that the `Software.Version` is in the process of
145b1b4d261SWilliam A. Kennington III   being activated.
146a1347418SPatrick Williams5. _Active_ - The `Software.Version` is active on the managed element. Note that
147a1347418SPatrick Williams   on systems with redundant storage devices a version might be _Active_ but not
148a1347418SPatrick Williams   the primary version.
149388b58f9SPatrick Williams6. _Failed_ - The `Software.Version` or the storage medium on which it is stored
150b1b4d261SWilliam A. Kennington III   has failed. An event may be recorded with additional details.
151388b58f9SPatrick Williams7. _Staged_ - The `Software.Version` is in staged flash region. This will be
152a1347418SPatrick Williams   moved from staged flash region to active flash region upon reset. Staged
153a1347418SPatrick Williams   flash region is the designated flash area which is used to store the
154a1347418SPatrick Williams   integrity validated firmware image that comes in during firmware update
155a1347418SPatrick Williams   process. Note that the staged image is not necessarily a functional firmware.
156b1b4d261SWilliam A. Kennington III
157b1b4d261SWilliam A. Kennington III### Image Apply Time
158b1b4d261SWilliam A. Kennington III
159b1b4d261SWilliam A. Kennington III`xyz.openbmc_project.Software.ApplyTime` has a property called
160a1347418SPatrick WilliamsRequestedApplyTime that indicates when the newly applied software image will be
161a1347418SPatrick Williamsactivated. RequestedApplyTime is a D-Bus property that maps to the "ApplyTime"
162a1347418SPatrick Williamsproperty in the Redfish UpdateService schema. Below are the currently supported
163a1347418SPatrick Williamsvalues and the value can be supplied through HttpPushUriApplyTime object:
164b1b4d261SWilliam A. Kennington III
165388b58f9SPatrick Williams1. _Immediate_ - Indicating that the `Software.Version` needs to be activated
166b1b4d261SWilliam A. Kennington III   immediately.
167a1347418SPatrick Williams2. _OnReset_ - Indicating that the `Software.Version` needs to be activated on
168a1347418SPatrick Williams   the next reset.
169b1b4d261SWilliam A. Kennington III
170b1b4d261SWilliam A. Kennington III### Blocking State Transitions
171b1b4d261SWilliam A. Kennington III
172a1347418SPatrick WilliamsIt is sometimes useful to block a system state transition while activations are
173a1347418SPatrick Williamsbeing performed. For example, we do not want to boot a managed host while its
174a1347418SPatrick WilliamsBIOS is being updated. In order to facilitate this, the interface
175b1b4d261SWilliam A. Kennington III`xyz.openbmc_project.Software.ActivationBlocksTransition` may be added to any
176a1347418SPatrick Williamsobject with `Software.Activation` to indicate this behavior. See that interface
177a1347418SPatrick Williamsfor more details.
178b1b4d261SWilliam A. Kennington III
179b1b4d261SWilliam A. Kennington IIIIt is strongly suggested that any activations are completed prior to a managed
180b1b4d261SWilliam A. Kennington IIIBMC reboot. This could be facilitated with systemd service specifiers.
181b1b4d261SWilliam A. Kennington III
182b1b4d261SWilliam A. Kennington III### Software Versions
183b1b4d261SWilliam A. Kennington III
184a1347418SPatrick WilliamsAll version identifiers are implementation specific strings. No format should be
185a1347418SPatrick Williamsassumed.
186b1b4d261SWilliam A. Kennington III
187b1b4d261SWilliam A. Kennington IIISome software versions are a collection of images, each with their own version
188a1347418SPatrick Williamsidentifiers. The `xyz.openbmc_project.Software.ExtendedVersion` interface can be
189a1347418SPatrick Williamsadded to any `Software.Version` to express the versioning of the aggregation.
190b1b4d261SWilliam A. Kennington III
1913cfcc9c0SAdriana KobylakIn addition, the `xyz.openbmc_project.Software.MinimumVersion` interface can
1923cfcc9c0SAdriana Kobylakcommunicate the minimum software version that a component must have to operate.
1933cfcc9c0SAdriana KobylakThe minimum version check is an optional software feature of the item updater.
1943cfcc9c0SAdriana Kobylak
195b1b4d261SWilliam A. Kennington III### Activation Progress
196b1b4d261SWilliam A. Kennington III
197a1347418SPatrick WilliamsThe `xyz.openbmc_project.Software.ActivationProgress` interface is provided to
198a1347418SPatrick Williamsshow current progress while a software version is _Activating_. It is expected
199a1347418SPatrick Williamsthat an _ItemUpdater_ will dynamically create this interface while the version
200a1347418SPatrick Williamsis _Activating_ and dynamically remove it when the activation is complete (or
201a1347418SPatrick Williamsfailed).
202b1b4d261SWilliam A. Kennington III
203b1b4d261SWilliam A. Kennington III### Handling Redundancy
204b1b4d261SWilliam A. Kennington III
205b1b4d261SWilliam A. Kennington IIIThe `xyz.openbmc_project.Software.RedundancyPriority` interface is provided to
206a1347418SPatrick Williamsexpress the relationship between two (or more) software versions activated for a
207a1347418SPatrick Williamssingle managed element. It is expected that all installed versions are listed as
208a1347418SPatrick Williams_Active_ and the `Priority` shows which version is the primary and which are
209b1b4d261SWilliam A. Kennington IIIavailable for redundancy.
210b1b4d261SWilliam A. Kennington III
211b1b4d261SWilliam A. Kennington IIIPrior to `Activation`, it can be useful to indicate a desired
212b1b4d261SWilliam A. Kennington III`RedundancyPriority`. This can be done by setting the `Priority` on the
213a1347418SPatrick Williams`RequestedRedundancyPriority` interface. Some _ItemUpdater_ implementations may
214a1347418SPatrick Williamsnot honor this field or be unable to comply with the request, in which case the
215a1347418SPatrick Williamsresulting `Activation` may result in one of two conditions: a
216388b58f9SPatrick Williams`ActivationState = Failed` or an `ActivateState = Active` with a
217b1b4d261SWilliam A. Kennington III`RedundancyPriority = 0 (High)`.
218b1b4d261SWilliam A. Kennington III
219ac7adcb5SCarlos J. Mazieri### Image Clean Up
220ac7adcb5SCarlos J. Mazieri
22156936f52SPatrick WilliamsAn _ItemUpdater_ is responsible for garbage collecting images contained on the
222ac7adcb5SCarlos J. Mazierielements it is managing. Often an element can only contain a single image so
223ac7adcb5SCarlos J. Mazierithis is a natural side-effect of the update process. In other cases, the
224388b58f9SPatrick Williams_ItemUpdater_ may remove images based on the `RedundancyPriority` assigned to an
225ac7adcb5SCarlos J. Mazieriimage.
226ac7adcb5SCarlos J. Mazieri
22756936f52SPatrick WilliamsThe _ImageManager_ should expose `Object.Delete()` methods to remove images from
22856936f52SPatrick Williamsthe BMC filesystem. It is possible that some _ItemUpdater_(s) will call this
229ac7adcb5SCarlos J. Mazierimethod once the `Version` is successfully activated.
230ac7adcb5SCarlos J. Mazieri
231388b58f9SPatrick WilliamsIn some designs there may be multiple _ItemUpdater_ instances which are handling
232ac7adcb5SCarlos J. Mazieriupdate for different system elements, all of which can potentially apply the
23356936f52SPatrick Williamssame software image (as in a multi-host design). The _ImageManager_ may
234ac7adcb5SCarlos J. Mazierioptionally monitor the `Software.Activation` signals and actively garbage
235ac7adcb5SCarlos J. Maziericollect an image once all `Software.Activation` under the `.../software/<id>`
236ac7adcb5SCarlos J. Mazieripath are either `Active` or `Staged`.
237ac7adcb5SCarlos J. Mazieri
2384aec8027SWilly Tu### Software Settings
2394aec8027SWilly Tu
240a1347418SPatrick WilliamsThe `xyz.openbmc_project.Software.Settings` interface is provided to show the
241a1347418SPatrick Williamssettings of the given software. The `Software.Settings` should be added to along
242a1347418SPatrick Williamsside `Software.Version` to represent its state from the same service.
2434aec8027SWilly Tu
244388b58f9SPatrick Williams```sh
2454aec8027SWilly Tubusctl introspect $SERVICE /xyz/openbmc_project/software/software_0
2464aec8027SWilly Tu...
2474aec8027SWilly Tuxyz.openbmc_project.Software.Version   interface   -
2484aec8027SWilly Tu.Purpose                               property    s
2494aec8027SWilly Tu.Version                               property    s
2504aec8027SWilly Tuxyz.openbmc_project.Software.Settings  interface   -
2514aec8027SWilly Tu.WriteProtected                        property    b
2524aec8027SWilly Tu...
2534aec8027SWilly Tu```
2544aec8027SWilly Tu
255388b58f9SPatrick WilliamsThe _ItemUpdater_ manages the fields such as `WriteProtected` to help provide
2564aec8027SWilly Tuinformation on how the software is managed.
2574aec8027SWilly Tu
258b1b4d261SWilliam A. Kennington III## REST use-cases
259b1b4d261SWilliam A. Kennington III
260388b58f9SPatrick Williams### Find all software versions on the system, either active or available
261b1b4d261SWilliam A. Kennington III
262a1347418SPatrick WilliamsList `/xyz/openbmc_project/software/`. This list can be filtered to just active
263a1347418SPatrick Williamslisting `.../software/active/` and following the `software_version` association
264a1347418SPatrick Williamsto retrieve version information. To list just "functional" or running versions
265a1347418SPatrick Williamslist `/xyz/openbmc_project/software/functional/`.
266b1b4d261SWilliam A. Kennington III
267388b58f9SPatrick Williams### Find all software versions on a managed element
268b1b4d261SWilliam A. Kennington III
269b1b4d261SWilliam A. Kennington IIIList `/xyz/openbmc_project/inventory/.../<item>/activation` association.
270b1b4d261SWilliam A. Kennington III
271b1b4d261SWilliam A. Kennington III### Upload new version via REST
272b1b4d261SWilliam A. Kennington III
273388b58f9SPatrick WilliamsHTTP PUT to `/xyz/openbmc_project/software/`. _ImageManager_ will assign the
274b1b4d261SWilliam A. Kennington III`<id>` when called for Object.Add().
275b1b4d261SWilliam A. Kennington III
276b1b4d261SWilliam A. Kennington III### Upload new version via ???
277b1b4d261SWilliam A. Kennington III
278b1b4d261SWilliam A. Kennington IIINeed additional interfaces defined for alternative upload methods.
279b1b4d261SWilliam A. Kennington III
280388b58f9SPatrick Williams### Activate a version
281b1b4d261SWilliam A. Kennington III
282388b58f9SPatrick WilliamsModify `RequestedActivation` to _Active_ on the desired `Activation`.
283b1b4d261SWilliam A. Kennington III
284388b58f9SPatrick Williams### Switch primary image
285b1b4d261SWilliam A. Kennington III
286b1b4d261SWilliam A. Kennington IIISet `Priority` to 0 on the desired `RedundancyPriority` interface.
287