| 1 |
.. SPDX-License-Identifier: GPL-2.0-only |
| 2 |
|
| 3 |
================================== |
| 4 |
PLDM Firmware Flash Update Library |
| 5 |
================================== |
| 6 |
|
| 7 |
``pldmfw`` implements functionality for updating the flash on a device using |
| 8 |
the PLDM for Firmware Update standard |
| 9 |
<https://www.dmtf.org/documents/pmci/pldm-firmware-update-specification-100>. |
| 10 |
|
| 11 |
.. toctree:: |
| 12 |
:maxdepth: 1 |
| 13 |
|
| 14 |
file-format |
| 15 |
driver-ops |
| 16 |
|
| 17 |
Overview of the ``pldmfw`` library |
| 18 |
================================== |
| 19 |
|
| 20 |
The ``pldmfw`` library is intended to be used by device drivers for |
| 21 |
implementing device flash update based on firmware files following the PLDM |
| 22 |
firmware file format. |
| 23 |
|
| 24 |
It is implemented using an ops table that allows device drivers to provide |
| 25 |
the underlying device specific functionality. |
| 26 |
|
| 27 |
``pldmfw`` implements logic to parse the packed binary format of the PLDM |
| 28 |
firmware file into data structures, and then uses the provided function |
| 29 |
operations to determine if the firmware file is a match for the device. If |
| 30 |
so, it sends the record and component data to the firmware using the device |
| 31 |
specific implementations provided by device drivers. Once the device |
| 32 |
firmware indicates that the update may be performed, the firmware data is |
| 33 |
sent to the device for programming. |
| 34 |
|
| 35 |
Parsing the PLDM file |
| 36 |
===================== |
| 37 |
|
| 38 |
The PLDM file format uses packed binary data, with most multi-byte fields |
| 39 |
stored in the Little Endian format. Several pieces of data are variable |
| 40 |
length, including version strings and the number of records and components. |
| 41 |
Due to this, it is not straight forward to index the record, record |
| 42 |
descriptors, or components. |
| 43 |
|
| 44 |
To avoid proliferating access to the packed binary data, the ``pldmfw`` |
| 45 |
library parses and extracts this data into simpler structures for ease of |
| 46 |
access. |
| 47 |
|
| 48 |
In order to safely process the firmware file, care is taken to avoid |
| 49 |
unaligned access of multi-byte fields, and to properly convert from Little |
| 50 |
Endian to CPU host format. Additionally the records, descriptors, and |
| 51 |
components are stored in linked lists. |
| 52 |
|
| 53 |
Performing a flash update |
| 54 |
========================= |
| 55 |
|
| 56 |
To perform a flash update, the ``pldmfw`` module performs the following |
| 57 |
steps |
| 58 |
|
| 59 |
1. Parse the firmware file for record and component information |
| 60 |
2. Scan through the records and determine if the device matches any record |
| 61 |
in the file. The first matched record will be used. |
| 62 |
3. If the matching record provides package data, send this package data to |
| 63 |
the device. |
| 64 |
4. For each component that the record indicates, send the component data to |
| 65 |
the device. For each component, the firmware may respond with an |
| 66 |
indication of whether the update is suitable or not. If any component is |
| 67 |
not suitable, the update is canceled. |
| 68 |
5. For each component, send the binary data to the device firmware for |
| 69 |
updating. |
| 70 |
6. After all components are programmed, perform any final device-specific |
| 71 |
actions to finalize the update. |