Skip to content

Commit 4ac9344

Browse files
dkodihaltomjoseph83
authored andcommitted
Initial version of pldm_fwup_pkg_creator.py
pldm_fwup_pkg_creator.py is a python script that can generate a PLDM firmware update package out of one or more image files, given a corresponding metadata JSON file. Signed-off-by: Deepak Kodihalli <[email protected]> Change-Id: I7655ab2be72731332afc686b1c55b1312455ba1a Signed-off-by: Tom Joseph <[email protected]>
1 parent 34b535a commit 4ac9344

File tree

4 files changed

+707
-0
lines changed

4 files changed

+707
-0
lines changed

setup.cfg

Whitespace-only changes.

tools/fw-update/README.md

+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# Overview
2+
pldm_fwup_pkg_creator.py is a python script that can package one or more
3+
firmware image blobs into a PLDM firmware update package, as per the DSP0267
4+
specification v1.1.0 - Section 7.
5+
6+
# Requirements
7+
- Python 3.6+
8+
- Python bitarray module
9+
- For example on Ubuntu: sudo pip3 install bitarray
10+
11+
# Usage
12+
13+
pldm_fwup_pkg_creator.py [-h]
14+
pldmfwuppkgname metadatafile images
15+
[images ...]
16+
17+
positional arguments:
18+
pldmfwuppkgname Name of the PLDM FW update package
19+
metadatafile Path of metadata JSON file
20+
images One or more firmware image paths, in the same order as
21+
ComponentImageInformationArea entries
22+
23+
- Provide name for the PLDM FW update package, output will be written to a file
24+
with this name
25+
- Providing the metadata JSON file is a must
26+
- The file path of at least one image file must be provided
27+
- In case there are more than one images, they should be specified in the
28+
*same order* as the entries in the "ComponentImageInformationArea" list in the
29+
metadata json
30+
31+
# Metadata JSON file
32+
Some fields corresponding to the PLDM firmware update package must be
33+
specified in an input metadata file (see the section 'Mapping fields to
34+
DSP0267') that's in JSON format. Typically it is not necessary to write this
35+
file each time the PLDM firmware update package has to be generated - one or
36+
more platform specific metadata JSON files can be reused. The key names used in
37+
the metadata JSON *match with the proprerty names* used in DSP0267.
38+
There is an example metadata json file included - metadata-example.json, which
39+
has example entries for preparing a PLDM firmware update package that targets
40+
three devices, and there are a total of three component images.
41+
42+
# Mapping fields to DSP0267
43+
This section describes the following:
44+
- which fields of the PLDM firmware update package are supported by the script
45+
- whether those fields need to be specified in the JSON, or are generated by the
46+
script
47+
48+
## Package Header Information
49+
Metadata JSON must have a key called "PackageHeaderInformation", which is of
50+
type Object. See below for details on properties:
51+
- PackageHeaderIdentifier: Supported, must be specified in metadata file
52+
- PackageHeaderFormatRevision: Supported, must be specified in metadata file
53+
- PackageHeaderSize: Supported, generated by the script
54+
- PackageReleaseDateTime: Supported, this is an optional field in the metadata
55+
file and the format is dd/MM/yyyy HH:mm:ss. If not specified in the metadata
56+
file, current time is taken.
57+
- ComponentBitmapBitLength: Supported, generated by the script
58+
- Only 32 components supported at the moment
59+
- PackageVersionStringType: Supported - only ASCII at the moment. Generated by
60+
the script
61+
- PackageVersionStringLength: Supported, generated by the script
62+
- PackageVersionString: Supported, must be specified in metadata file
63+
64+
## Firmware Device Identification Area
65+
Metadata JSON must have a key called "FirmwareDeviceIdentificationArea", which
66+
is of type List. Each List entry corresponds to an firmware device ID record.
67+
See below for details on properties:
68+
- DeviceIDRecordCount: Supported, generated by the script
69+
- FirmwareDeviceIDRecords: which is a list of Individual Firmware Device ID
70+
Records. Each such record can have the following properties:
71+
- RecordLength: Supported, generated by the script
72+
- DescriptorCount: Supported, generated by the script
73+
- DeviceUpdateOptionFlags: Supported, must be specified in metadata file
74+
- add each bit that is to be set to 1 to the list
75+
"DeviceUpdateOptionFlags"
76+
- ComponentImageSetVersionStringType: Supported - only ASCII at the moment.
77+
Generated by the script
78+
- ComponentImageSetVersionStringLength: Supported, generated by the script
79+
- FirmwareDevicePackageDataLength: Not supported. Set to 0 by the script
80+
- ApplicableComponents: Supported, must be specified in metadata file
81+
- specify all "ComponentIdentifier" values that apply in the
82+
"ApplicableComponents" list
83+
- ComponentImageSetVersionString: Supported, must be specified in metadata
84+
file
85+
- RecordDescriptors:
86+
- Initial Descriptor: Supported, must be specified in metadata file.
87+
Metatdata file must have key called "InitialDescriptor", which is of
88+
type Object:
89+
- InitialDescriptorType: Supported, must be specified in metadata
90+
file. The supported types are 0x0000(PCI Vendor ID), 0x0001(IANA
91+
Enterprise ID), 0x0002 (UUID), 0x0003(PnP Vendor ID), 0x0004( ACPI
92+
Vendor ID)
93+
- InitialDescriptorLength: Supported, generated by the script
94+
- InitialDescriptorData: Supported, must be specified in metadata
95+
file as a hex string
96+
- Optional Additional Descriptors: Not supported at the moment
97+
- FirmwareDevicePackageData: Not supported at the moment
98+
99+
## Downstream Device Identification Area
100+
Not supported at the moment
101+
102+
## Component Image Information Area
103+
Metadata JSON must have a key called "ComponentImageInformationArea", which
104+
is of type List. Each List entry corresponds to an Individual Component Image
105+
Information. See below for details on properties:
106+
- ComponentImageCount: Supported, generated by the script
107+
- ComponentImageInformation: which is a list of Individual Component Image
108+
Information records. Each such record can have the following properties:
109+
- ComponentClassification: Supported, must be specified in metadata file
110+
- ComponentIdentifier: Supported, must be specified in metadata file
111+
- ComponentComparisonStamp: Not supported. Set to 0xFFFFFFFF by the script
112+
- ComponentOptions: Supported, must be specified in metadata file
113+
- add each bit that is to be set to 1 to the list "ComponentOptions"
114+
- only supported option at the moment is Force Update (0x0)
115+
- RequestedComponentActivationMethod: Supported, must be specified in
116+
metadata file
117+
- add each bit that is to be set to 1 to the list
118+
"RequestedComponentActivationMethod"
119+
- ComponentLocationOffset: Supported, generated by the script
120+
- ComponentSize: Supported, generated by the script
121+
- ComponentVersionStringType: Supported - only ASCII at the moment.
122+
Generated by the script
123+
- ComponentVersionStringLength: Supported, generated by the script
124+
- ComponentVersionString: Supported, must be specified in metadata file
125+
126+
## Package Header Checksum
127+
Supported, generated by the script

tools/fw-update/metadata-example.json

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
{
2+
"PackageHeaderInformation": {
3+
"PackageHeaderIdentifier": "1244D2648D7D4718A030FC8A56587D5A",
4+
"PackageHeaderFormatVersion": 2,
5+
"PackageReleaseDateTime": "25/12/2021 00:00:00",
6+
"PackageVersionString": "VersionString1"
7+
},
8+
"FirmwareDeviceIdentificationArea": [
9+
{
10+
"DeviceUpdateOptionFlags": [
11+
0
12+
],
13+
"ComponentImageSetVersionString": "VersionString2",
14+
"ApplicableComponents": [
15+
100,
16+
200
17+
],
18+
"InitialDescriptor": {
19+
"InitialDescriptorType": 2,
20+
"InitialDescriptorData": "1244D2648D7D4718A030FC8A56587D5B"
21+
}
22+
},
23+
{
24+
"DeviceUpdateOptionFlags": [
25+
],
26+
"ComponentImageSetVersionString": "VersionString3",
27+
"ApplicableComponents": [
28+
100,
29+
200,
30+
300
31+
],
32+
"InitialDescriptor": {
33+
"InitialDescriptorType": 2,
34+
"InitialDescriptorData": "1244D2648D7D4718A030FC8A56587D5C"
35+
}
36+
},
37+
{
38+
"DeviceUpdateOptionFlags": [
39+
],
40+
"ComponentImageSetVersionString": "VersionString4",
41+
"ApplicableComponents": [
42+
100
43+
],
44+
"InitialDescriptor": {
45+
"InitialDescriptorType": 2,
46+
"InitialDescriptorData": "1244D2648D7D4718A030FC8A56587D5D"
47+
}
48+
}
49+
],
50+
"ComponentImageInformationArea": [
51+
{
52+
"ComponentClassification": 10,
53+
"ComponentIdentifier": 100,
54+
"ComponentOptions": [
55+
],
56+
"RequestedComponentActivationMethod": [
57+
],
58+
"ComponentVersionString": "VersionString5"
59+
},
60+
{
61+
"ComponentClassification": 10,
62+
"ComponentIdentifier": 200,
63+
"ComponentOptions": [
64+
],
65+
"RequestedComponentActivationMethod": [
66+
0
67+
],
68+
"ComponentVersionString": "VersionString6"
69+
},
70+
{
71+
"ComponentClassification": 16,
72+
"ComponentIdentifier": 300,
73+
"ComponentOptions": [
74+
0
75+
],
76+
"RequestedComponentActivationMethod": [
77+
2,
78+
3
79+
],
80+
"ComponentVersionString": "VersionString7"
81+
}
82+
]
83+
}

0 commit comments

Comments
 (0)