1840c6e12SAdriana Kobylak# Firmware update over Redfish 2840c6e12SAdriana Kobylak 3840c6e12SAdriana KobylakAuthor: Andrew Geissler (geissonator) 4840c6e12SAdriana Kobylak 5840c6e12SAdriana KobylakCreated: 2019-02-11 6840c6e12SAdriana Kobylak 7840c6e12SAdriana Kobylak## Problem Description 8*f4febd00SPatrick Williams 9840c6e12SAdriana KobylakOpenBMC is moving to [Redfish][1] as its standard for out of band management. 10840c6e12SAdriana KobylakRedfish has its own API's and methods for updating firmware on a system and 11840c6e12SAdriana Kobylakimplementing those is going to require some changes (and potential upstream work 12840c6e12SAdriana Kobylakwith the DMTF). 13840c6e12SAdriana Kobylak 14840c6e12SAdriana KobylakThe goal of this design document is to lay out the required changes of moving 15840c6e12SAdriana KobylakOpenBMC's existing firmware update implementation over to Redfish. 16840c6e12SAdriana Kobylak 17840c6e12SAdriana Kobylak## Background and References 18*f4febd00SPatrick Williams 19*f4febd00SPatrick WilliamsThe existing firmware update details for OpenBMC can be found [here][2]. It uses 20*f4febd00SPatrick Williamsa custom REST api for uploading and then activating the input image. 21840c6e12SAdriana Kobylak 22840c6e12SAdriana KobylakThe Redfish schema for firmware update can be found [here][3]. Note the 23*f4febd00SPatrick Williamsreferenced doc points to the most recent version of the schema and that is what 24*f4febd00SPatrick Williamsyou'll want to load into your browser (at the time of this writing it is 25840c6e12SAdriana Kobylak[v1_4_0][4]). 26840c6e12SAdriana Kobylak 27840c6e12SAdriana KobylakSome differences between the Redfish API and OpenBMC's existing API: 28*f4febd00SPatrick Williams 29840c6e12SAdriana Kobylak- Redfish has a single upload and update API. OpenBMC has a concept of uploading 30840c6e12SAdriana Kobylak an image with one API and then activating with another. 31840c6e12SAdriana Kobylak- Redfish does not support multiple firmware images being associated with the 32840c6e12SAdriana Kobylak same target. OpenBMC does have support for this concept (for example when a 33840c6e12SAdriana Kobylak target like the BMC has multiple flash chips associated with it). A discussion 34840c6e12SAdriana Kobylak has been started with the DMTF on this within [Issue 3357][10] 35*f4febd00SPatrick Williams - OpenBMC has the concept of a priority that allows a user to chose an image 36*f4febd00SPatrick Williams associated with a target for activation. This allows a user to easily switch 37*f4febd00SPatrick Williams back and forth between multiple images for a single target without uploading 38*f4febd00SPatrick Williams each image every time. 39840c6e12SAdriana Kobylak- Redfish does not support deleting a firmware image (this happens by default 40840c6e12SAdriana Kobylak when a new image is uploaded) 41840c6e12SAdriana Kobylak- Redfish does support the ability to update multiple targets with the same 42840c6e12SAdriana Kobylak image with the same command. OpenBMC does not support this currently. 43*f4febd00SPatrick Williams- Redfish has support via a SimpleUpdate action which allows the user to pass in 44*f4febd00SPatrick Williams a variety of remote locations to retrieve a file from (FTP, HTTP, SCP, ...). 45*f4febd00SPatrick Williams Existing OpenBMC only has support for TFTP. 46840c6e12SAdriana Kobylak- Redfish has the ability to schedule when a firmware update is applied 47840c6e12SAdriana Kobylak (Immediate, OnReset, AtMaintenanceWindowStart...). Existing OpenBMC firmware 48840c6e12SAdriana Kobylak has no concept of this. 49840c6e12SAdriana Kobylak 50840c6e12SAdriana KobylakA lot of companies that are implementing Redfish have chosen to create OEM 51840c6e12SAdriana Kobylakcommands for their firmware update implementations ([ref a][5], [ref b][6]). 52840c6e12SAdriana Kobylak 53840c6e12SAdriana KobylakRedfish firmware update within OpenBMC has already started within [bmcweb][7] 54840c6e12SAdriana Kobylakand this design will be proposing enhancements to that as a base. 55840c6e12SAdriana Kobylak 56840c6e12SAdriana Kobylak## Requirements 57840c6e12SAdriana Kobylak 58840c6e12SAdriana KobylakBreaking this into two sections. The first is what should be done for the next 59840c6e12SAdriana KobylakOpenBMC 2.7 release. The other section is future items that will get done, but 60840c6e12SAdriana Kobylaknot guaranteed for the 2.7 release. The goal with 2.7 is to have feature parity 61840c6e12SAdriana Kobylakwith what the existing OpenBMC REST api's provide. 62840c6e12SAdriana Kobylak 63840c6e12SAdriana Kobylak### 2.7 Requirements 64*f4febd00SPatrick Williams 65840c6e12SAdriana Kobylak- Support FirmwareInventory definition for BMC and BIOS under UpdateService 66840c6e12SAdriana Kobylak - Support FirmwareVersion under Managers/BMC 67840c6e12SAdriana Kobylak - Support BiosVersion under Systems/system 68840c6e12SAdriana Kobylak- Support firmware update for all supported targets (BMC, BIOS) using existing 69840c6e12SAdriana Kobylak Redfish API's (/redfish/v1/UpdateService) 70840c6e12SAdriana Kobylak - Note that after further discussion with the DMTF, the existing UpdateService 71840c6e12SAdriana Kobylak is considered to be OEM. [Issue 3296][11] addresses this and will be 72840c6e12SAdriana Kobylak implemented by OpenBMC once approved. The existing API will continue to be 73840c6e12SAdriana Kobylak supported within the Redfish specification so the OpenBMC 2.7 release will 74840c6e12SAdriana Kobylak support this. 75840c6e12SAdriana Kobylak - Must provide status to user on their image during an update 76840c6e12SAdriana Kobylak- Support a subset of ApplyTime (Immediate, OnReset) 77840c6e12SAdriana Kobylak- Support a TFTP based SimpleUpdate 78840c6e12SAdriana Kobylak - This must be configurable (enable/disable) via compile option within bmcweb 79840c6e12SAdriana Kobylak 80840c6e12SAdriana Kobylak### Future Requirements 81840c6e12SAdriana Kobylak 82*f4febd00SPatrick Williams**Note:** TODO: The goal of this section is to document at a high level what 83*f4febd00SPatrick Williamswill be required post 2.7 release. An update to this design document will be 84*f4febd00SPatrick Williamsrequired before these requirements are implemented. They are here to ensure 85*f4febd00SPatrick Williamsnothing in the base design would inhibit the ability to implement these later. 86840c6e12SAdriana Kobylak 87840c6e12SAdriana Kobylak- Support new concept defined in [PR 3420][12] to be able to support multiple 88840c6e12SAdriana Kobylak firmware images for a single target. 89*f4febd00SPatrick Williams- Support new UpdateService firmware update implementation defined in [Issue 90*f4febd00SPatrick Williams 3296][11] 91840c6e12SAdriana Kobylak- Support firmware update for other targets (power supplies, voltage regulators, 92840c6e12SAdriana Kobylak ...) 93840c6e12SAdriana Kobylak- Support to update multiple targets with the same firmware image at once 94840c6e12SAdriana Kobylak- Support scheduling of when update occurs (Maintenance windows) 95840c6e12SAdriana Kobylak- Support remaining TransferProtocolTypes in UpdateService (CIFS, FTP, SFTP, 96840c6e12SAdriana Kobylak HTTP, HTTPS, NSF, SCP, NFS) 97840c6e12SAdriana Kobylak - TODO: Any update mechanism that doesn't have transport security on its own, 98840c6e12SAdriana Kobylak like FTP, needs a secondary verification mechanism. Update mechanisms that 99840c6e12SAdriana Kobylak have transport security need a way to adjust the trusted root certificates. 100840c6e12SAdriana Kobylak- Support the Task schema to provide progress to user during upload and 101840c6e12SAdriana Kobylak activation phases 102840c6e12SAdriana Kobylak 103840c6e12SAdriana Kobylak## Proposed Design 104840c6e12SAdriana Kobylak 105840c6e12SAdriana Kobylak### Update An Image 106840c6e12SAdriana Kobylak 107840c6e12SAdriana KobylakThe pseudo flow for an update is: 108*f4febd00SPatrick Williams 109840c6e12SAdriana Kobylak``` 110840c6e12SAdriana KobylakDiscover UpdateService location 111840c6e12SAdriana KobylakHttpPushUri = GET https://${bmc}/redfish/v1/UpdateService 112840c6e12SAdriana KobylakPOST ApplyTime property in 113840c6e12SAdriana Kobylak UpdateService/HttpPushUriOptions->HttpPushUriApplyTime object 114840c6e12SAdriana Kobylak (Immediate or OnReset) 115840c6e12SAdriana KobylakPOST <image> https://${bmc}/${HttpPushUri} 116840c6e12SAdriana Kobylak``` 117*f4febd00SPatrick Williams 118840c6e12SAdriana KobylakThis will cause the following on the back-end: 119*f4febd00SPatrick Williams 120840c6e12SAdriana Kobylak- Receive the image 121840c6e12SAdriana Kobylak- Copy it internally to the required location in the filesystem (/tmp/images) 122840c6e12SAdriana Kobylak- Wait for the InterfacesAdded signal from /xyz/openbmc_project/software 123840c6e12SAdriana Kobylak- Activate the new image 124840c6e12SAdriana Kobylak- If ApplyTime is Immediate, reboot the BMC or Host 125840c6e12SAdriana Kobylak- If ApplyTime is OnReset, do nothing (user will need to initiate host or bmc 126840c6e12SAdriana Kobylak reboot to apply image) 127840c6e12SAdriana Kobylak 128840c6e12SAdriana KobylakNote that the ApplyTime property will be processed by the software management 129*f4febd00SPatrick Williamsstack at the end of the activation. Note that the ApplyTime property is global 130*f4febd00SPatrick Williamsto all firmware update packages and will be used for all subsequent firmware 131*f4febd00SPatrick Williamsupdate packages. 132840c6e12SAdriana Kobylak 133840c6e12SAdriana Kobylak### Status of an Image 134840c6e12SAdriana Kobylak 135*f4febd00SPatrick WilliamsThe user needs to know the status of their firmware images, especially during an 136*f4febd00SPatrick Williamsupdate. The Task concept is still being defined within the DMTF and will provide 137*f4febd00SPatrick Williamsthe full status of an image during upload and activate. Using the Status object 138*f4febd00SPatrick Williamsassociated with the software inventory items will be used as a mechanism to 139*f4febd00SPatrick Williamsprovide status of inventory items back to the user. Here is the mapping of 140*f4febd00SPatrick Williams[phosphor activation states][13] to [Redfish Status States][14]. 141*f4febd00SPatrick Williams 142840c6e12SAdriana Kobylak``` 143840c6e12SAdriana KobylakNotReady -> Disabled 144840c6e12SAdriana KobylakInvalid -> Disabled 145840c6e12SAdriana KobylakReady -> Disabled 146840c6e12SAdriana KobylakActivating -> Updating 147840c6e12SAdriana KobylakActive -> Enabled 148840c6e12SAdriana KobylakFailed -> Disabled 149840c6e12SAdriana Kobylak``` 150840c6e12SAdriana Kobylak 151840c6e12SAdriana Kobylak### Change the Priority of an Image 152840c6e12SAdriana Kobylak 153840c6e12SAdriana KobylakOn OpenBMC systems that support multiple flash images for one target, there will 154840c6e12SAdriana Kobylakstill be pseudo support for this using Redfish. The first image will be uploaded 155840c6e12SAdriana Kobylakto a system, written to flash chip 0, and activated. If another image is 156840c6e12SAdriana Kobylakuploaded, it will be written to flash chip 1 and activated. The first image 157840c6e12SAdriana Kobylakstill exists in flash chip 0 and could be re-activated by the user. 158840c6e12SAdriana Kobylak 159840c6e12SAdriana KobylakAs defined in DMTF issue [3357][10], use the ActiveSoftwareImage concept within 160840c6e12SAdriana Kobylakthe Redfish Settings object to allow the user to select the image to activate 161840c6e12SAdriana Kobylakduring the next activation window. Internally OpenBMC has the concept of a 162840c6e12SAdriana Kobylakpriority being assigned to each image associated with a target. OpenBMC firmware 163840c6e12SAdriana Kobylakwill continue to do this, but will simply set the "ActiveSoftwareImage" image to 164840c6e12SAdriana Kobylakpriority 0 (highest) to ensure it is activated during the next activation 165840c6e12SAdriana Kobylakwindow. After setting the priority to 0, the software manager automatically 166840c6e12SAdriana Kobylakupdates the priority of the other images as needed. 167840c6e12SAdriana Kobylak 168*f4febd00SPatrick Williams### Remote Image Download Based Update 169840c6e12SAdriana Kobylak 170840c6e12SAdriana KobylakAs noted above, Redfish supports a SimpleUpdate object under the UpdateService. 171840c6e12SAdriana KobylakThe SimpleUpdate schema supports a variety of transfer protocols (CIFS, FTP, 172840c6e12SAdriana KobylakTFTP, ...). The existing back end of OpenBMC only supports TFTP so initially 173840c6e12SAdriana Kobylakthat is all that will be supported via Redfish on OpenBMC. 174840c6e12SAdriana Kobylak 175840c6e12SAdriana KobylakThe Redfish API takes a parameter, ImageURI, which contains both the server 176840c6e12SAdriana Kobylakaddress information and the name of the file. The back end software manager 177840c6e12SAdriana Kobylakinterface on OpenBMC requires two parameters, the TFTP server address and the 178840c6e12SAdriana Kobylakfile name so there will be some parsing required. 179840c6e12SAdriana Kobylak 180840c6e12SAdriana KobylakThe pseudo flow for an update is: 181*f4febd00SPatrick Williams 182840c6e12SAdriana Kobylak``` 183840c6e12SAdriana Kobylak# Discover SimpleUpdate URI Action location 184840c6e12SAdriana KobylakGET https://${bmc}/redfish/v1/UpdateService 185840c6e12SAdriana Kobylak 186840c6e12SAdriana Kobylak# Configure when the new image should be applied 187840c6e12SAdriana KobylakPOST ApplyTime property in 188840c6e12SAdriana Kobylak UpdateService/HttpPushUriOptions->HttpPushUriApplyTime object 189840c6e12SAdriana Kobylak (Immediate or OnReset) 190840c6e12SAdriana Kobylak 191840c6e12SAdriana Kobylak# Request OpenBMC to download from TFTP server and activate the image 192840c6e12SAdriana KobylakPOST https://${bmc}/redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate 193840c6e12SAdriana Kobylak [ImageURI=<tftp server ip>/<file name>, TransferProtocol=TFTP] 194840c6e12SAdriana Kobylak``` 195840c6e12SAdriana Kobylak 196840c6e12SAdriana KobylakTFTP is an insecure protocol. There is no username or password associated with 197840c6e12SAdriana Kobylakit and no validation of the input URL. OpenBMC does have signed image support 198840c6e12SAdriana Kobylakwhich is, by default, part of the update process. The user must have 199840c6e12SAdriana Kobylakadministration authority to request this update so it is assumed they know what 200840c6e12SAdriana Kobylakthey are doing and the level of security available with TFTP. 201840c6e12SAdriana Kobylak 202840c6e12SAdriana KobylakDue to the security concerns with TFTP, this feature will be disabled by default 203840c6e12SAdriana Kobylakwithin bmcweb but can be enabled via a compile flag (see CMakeLists.txt within 204840c6e12SAdriana Kobylakbmcweb repository for details). 205840c6e12SAdriana Kobylak 206840c6e12SAdriana Kobylak### Delete an Image 207*f4febd00SPatrick Williams 208840c6e12SAdriana KobylakNo support for deleting an image will be provided (until the DMTF provides it). 209840c6e12SAdriana KobylakWhen new images are uploaded, they by default have no priority. When they are 210840c6e12SAdriana Kobylakactivated, they are given the highest priority and all other images have their 211840c6e12SAdriana Kobylakpriority updated as needed. When no more space is available in flash filesystem, 212840c6e12SAdriana Kobylakthe lowest priority image will be deleted when a new one is uploaded and 213840c6e12SAdriana Kobylakactivated. 214840c6e12SAdriana Kobylak 215840c6e12SAdriana Kobylak## Alternatives Considered 216*f4febd00SPatrick Williams 217840c6e12SAdriana KobylakCould simply create Redfish OEM api's that look like OpenBMC's current custom 218*f4febd00SPatrick WilliamsREST api's. The porting would be minimal but then OpenBMC would not conform to 219*f4febd00SPatrick Williamsany standard Redfish API's. Other vendors have done this but the Redfish DMTF is 220*f4febd00SPatrick Williamsmaking strides towards enhancing the UpdateService to contain the features 221*f4febd00SPatrick Williamsrequired to make an enterprise based firmware update API. OpenBMC should just 222*f4febd00SPatrick Williamsstay at the forefront of these DMTF changes and ensure they are implemented as 223*f4febd00SPatrick Williamsthey are released. 224840c6e12SAdriana Kobylak 225840c6e12SAdriana Kobylak## Impacts 226*f4febd00SPatrick Williams 227840c6e12SAdriana KobylakThis will be using the existing D-Bus API's for firmware update internally so 228840c6e12SAdriana Kobylakthere should be minimal impact between the previous REST implementation. 229840c6e12SAdriana Kobylak 230840c6e12SAdriana KobylakOpenBMC has two implementations of firmware update. Different systems have 231840c6e12SAdriana Kobylakimplemented different implementations. To be clear, this design will be using 232840c6e12SAdriana Kobylakthe D-Bus API's behind the [Software Version Management][8] implementation. 233840c6e12SAdriana Kobylak 234840c6e12SAdriana Kobylak## Testing 235*f4febd00SPatrick Williams 236840c6e12SAdriana KobylakEnd to end [tests][9] are being written for the firmware update of BMC and BIOS 237840c6e12SAdriana Kobylakfirmware, these must pass. Also unit tests must be written with the required 238840c6e12SAdriana KobylakD-Bus API's mocked to ensure proper code coverage. 239840c6e12SAdriana Kobylak 240840c6e12SAdriana Kobylak[1]: https://redfish.dmtf.org/ 241*f4febd00SPatrick Williams[2]: 242*f4febd00SPatrick Williams https://github.com/openbmc/docs/blob/master/architecture/code-update/code-update.md#steps-to-update 243840c6e12SAdriana Kobylak[3]: http://redfish.dmtf.org/schemas/v1/UpdateService.json 244*f4febd00SPatrick Williams[4]: 245*f4febd00SPatrick Williams http://redfish.dmtf.org/schemas/v1/UpdateService.v1_4_0.json#/definitions/UpdateService 246840c6e12SAdriana Kobylak[5]: https://www.supermicro.com/manuals/other/RedfishRefGuide.pdf 247*f4febd00SPatrick Williams[6]: 248*f4febd00SPatrick Williams https://github.com/dell/iDRAC-Redfish-Scripting/blob/master/Redfish%20Python/DeviceFirmwareDellUpdateServiceREDFISH.py 249*f4febd00SPatrick Williams[7]: 250*f4febd00SPatrick Williams https://github.com/openbmc/bmcweb/blob/master/redfish-core/lib/update_service.hpp 251*f4febd00SPatrick Williams[8]: 252*f4febd00SPatrick Williams https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/Software/README.md 253840c6e12SAdriana Kobylak[9]: https://github.com/openbmc/openbmc-test-automation 254840c6e12SAdriana Kobylak[10]: https://github.com/DMTF/Redfish/issues/3357 255840c6e12SAdriana Kobylak[11]: https://github.com/DMTF/Redfish/pull/3296 256840c6e12SAdriana Kobylak[12]: https://github.com/DMTF/Redfish/pull/3420 257*f4febd00SPatrick Williams[13]: 258*f4febd00SPatrick Williams https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/Software/Activation.interface.yaml 259840c6e12SAdriana Kobylak[14]: http://redfish.dmtf.org/schemas/v1/Resource.json#/definitions/Status 260