PLDM Firmware Flash Update Library¶
pldmfw implements functionality for updating the flash on a device usingthe PLDM for Firmware Update standard<https://www.dmtf.org/documents/pmci/pldm-firmware-update-specification-100>.
Overview of thepldmfw library¶
Thepldmfw library is intended to be used by device drivers forimplementing device flash update based on firmware files following the PLDMfirmware file format.
It is implemented using an ops table that allows device drivers to providethe underlying device specific functionality.
pldmfw implements logic to parse the packed binary format of the PLDMfirmware file into data structures, and then uses the provided functionoperations to determine if the firmware file is a match for the device. Ifso, it sends the record and component data to the firmware using the devicespecific implementations provided by device drivers. Once the devicefirmware indicates that the update may be performed, the firmware data issent to the device for programming.
Parsing the PLDM file¶
The PLDM file format uses packed binary data, with most multi-byte fieldsstored in the Little Endian format. Several pieces of data are variablelength, including version strings and the number of records and components.Due to this, it is not straight forward to index the record, recorddescriptors, or components.
To avoid proliferating access to the packed binary data, thepldmfwlibrary parses and extracts this data into simpler structures for ease ofaccess.
In order to safely process the firmware file, care is taken to avoidunaligned access of multi-byte fields, and to properly convert from LittleEndian to CPU host format. Additionally the records, descriptors, andcomponents are stored in linked lists.
Performing a flash update¶
To perform a flash update, thepldmfw module performs the followingsteps
Parse the firmware file for record and component information
Scan through the records and determine if the device matches any recordin the file. The first matched record will be used.
If the matching record provides package data, send this package data tothe device.
For each component that the record indicates, send the component data tothe device. For each component, the firmware may respond with anindication of whether the update is suitable or not. If any component isnot suitable, the update is canceled.
For each component, send the binary data to the device firmware forupdating.
After all components are programmed, perform any final device-specificactions to finalize the update.