1## Code Update ##
2
3#### Redfish Code Update ####
4
5Currently supported BMC and PNOR update formats are UBI.
6For code update information, please refer to [code-update.md](https://github.com/openbmc/docs/blob/master/code-update/code-update.md)
7
8* UBI Format
9
10    For BMC code update, download the system type *.ubi.mdt.tar image from
11    https://jenkins.openbmc.org/job/latest-master/ and run as follows:
12
13    For Witherspoon system:
14    ```
15    * Code Update with OnReset Policy
16
17        $ cd redfish/update_service/test_redfish_bmc_code_update.robot
18        $ robot -v OPENBMC_HOST:x.x.x.x -v IMAGE_FILE_PATH:<image path>/obmc-phosphor-image-witherspoon.ubi.mtd.tar --include Redfish_Code_Update_With_ApplyTime_OnReset redfish/update_service/test_redfish_bmc_code_update.robot
19
20    * Code Update with Immediate Policy
21
22        $ cd redfish/update_service/test_redfish_bmc_code_update.robot
23        $ robot -v OPENBMC_HOST:x.x.x.x -v IMAGE_FILE_PATH:<image path>/obmc-phosphor-image-witherspoon.ubi.mtd.tar --include Redfish_Code_Update_With_ApplyTime_Immediate redfish/update_service/test_redfish_bmc_code_update.robot
24    ```
25
26    For host code update, download the system type *.pnor.squashfs.tar image
27    from https://openpower.xyz/job/openpower-op-build/ and run as follows:
28
29    For Witherspoon system:
30    ```
31    * Code Update with OnReset Policy
32
33        $ cd redfish/update_service/test_redfish_host_code_update.robot
34        $ robot -v OPENBMC_HOST:x.x.x.x -v IMAGE_FILE_PATH:<image path>/witherspoon.pnor.squashfs.tar --include Redfish_Code_Update_With_ApplyTime_OnReset redfish/update_service/test_redfish_host_code_update.robot
35
36    * Code Update with Immediate Policy
37
38        $ cd redfish/update_service/test_redfish_host_code_update.robot
39        $ robot -v OPENBMC_HOST:x.x.x.x -v IMAGE_FILE_PATH:<image path>/witherspoon.pnor.squashfs.tar --include Redfish_Code_Update_With_ApplyTime_Immediate redfish/update_service/test_redfish_host_code_update.robot
40    ```
41
42#### REST Code Update ####
43
44Currently supported BMC and PNOR update formats are UBI and non-UBI.
45For code update information, please refer to [code-update.md](https://github.com/openbmc/docs/blob/master/code-update/code-update.md)
46
47
48* UBI Format
49
50    For BMC code update, download the system type *.ubi.mdt.tar image from
51    https://jenkins.openbmc.org/job/latest-master/ and run as follows:
52
53    For Witherspoon system:
54    ```
55    $ cd extended/code_update/
56    $ robot -v OPENBMC_HOST:x.x.x.x -v IMAGE_FILE_PATH:<image path>/obmc-phosphor-image-witherspoon.ubi.mtd.tar --include REST_BMC_Code_Update  bmc_code_update.robot
57    ```
58
59    For host code update, download the system type *.pnor.squashfs.tar image
60    from https://openpower.xyz/job/openpower-op-build/ and run as follows:
61
62    For Witherspoon system:
63    ```
64    $ cd extended/code_update/
65    $ robot -v OPENBMC_HOST:x.x.x.x -v IMAGE_FILE_PATH:<image path>/witherspoon.pnor.squashfs.tar --include REST_Host_Code_Update  host_code_update.robot
66    ```
67
68* Non-UBI Format
69
70    For BMC code update, download the system type *all.tar image from
71    https://jenkins.openbmc.org/job/latest-master/ and run as follows:
72
73    For a Zaius system:
74    ```
75    $ cd extended/code_update/
76    $ robot -v OPENBMC_HOST:x.x.x.x -v FILE_PATH:<image path>/zaius-<date time>.all.tar --include Initiate_Code_Update_BMC update_bmc.robot
77    ```
78
79    For host code update, download the system type *.pnor from
80    https://openpower.xyz/job/openpower-op-build/ and run as follows:
81
82    For a Zaius system:
83    ```
84    $ cd extended/
85    $ robot -v OPENBMC_HOST:x.x.x.x -v PNOR_IMAGE_PATH:<image path>/zaius.pnor test_bios_update.robot
86    ```
87
88#### Generating Bad Firmware Image for testing ####
89
90Procedure is to create bad firmware image for BMC and same steps applicable for Host image.
91
92*   No MANIFEST file
93
94    ```
95    Command to list the content of the firmware image.
96
97    tar -tvf obmc-phosphor-image-witherspoon-20210516025203.ubi.mtd.tar
98    -rw-r--r-- jenkins-op/jenkins-op 306804 2021-05-15 22:00 image-u-boot
99    -rw-r--r-- jenkins-op/jenkins-op 3039300 2021-05-12 03:32 image-kernel
100    -rw-r--r-- jenkins-op/jenkins-op 19861504 2021-05-15 22:00 image-rofs
101    -rw-r--r-- jenkins-op/jenkins-op   850304 2021-05-15 22:00 image-rwfs
102    -rw-r--r-- jenkins-op/jenkins-op      176 2021-05-15 22:00 MANIFEST
103    -rw-r--r-- jenkins-op/jenkins-op      272 2021-05-15 22:00 publickey
104    -rw-r--r-- jenkins-op/jenkins-op      128 2021-05-15 22:00 image-u-boot.sig
105    -rw-r--r-- jenkins-op/jenkins-op      128 2021-05-15 22:00 image-kernel.sig
106    -rw-r--r-- jenkins-op/jenkins-op      128 2021-05-15 22:00 image-rofs.sig
107    -rw-r--r-- jenkins-op/jenkins-op      128 2021-05-15 22:00 image-rwfs.sig
108    -rw-r--r-- jenkins-op/jenkins-op      128 2021-05-15 22:00 MANIFEST.sig
109    -rw-r--r-- jenkins-op/jenkins-op      128 2021-05-15 22:00 publickey.sig
110    -rw-r--r-- jenkins-op/jenkins-op      128 2021-05-15 22:00 image-full.sig
111
112    Delete MANIFEST file from the tar firmware image.
113
114    tar --delete -vf obmc-phosphor-image-witherspoon-20210516025203.ubi.mtd.tar MANIFEST
115
116    tar -tvf obmc-phosphor-image-witherspoon-20210516025203.ubi.mtd.tar
117    -rw-r--r-- jenkins-op/jenkins-op 306804 2021-05-15 22:00 image-u-boot
118    -rw-r--r-- jenkins-op/jenkins-op 3039300 2021-05-12 03:32 image-kernel
119    -rw-r--r-- jenkins-op/jenkins-op 19861504 2021-05-15 22:00 image-rofs
120    -rw-r--r-- jenkins-op/jenkins-op   850304 2021-05-15 22:00 image-rwfs
121    -rw-r--r-- jenkins-op/jenkins-op      272 2021-05-15 22:00 publickey
122    -rw-r--r-- jenkins-op/jenkins-op      128 2021-05-15 22:00 image-u-boot.sig
123    -rw-r--r-- jenkins-op/jenkins-op      128 2021-05-15 22:00 image-kernel.sig
124    -rw-r--r-- jenkins-op/jenkins-op      128 2021-05-15 22:00 image-rofs.sig
125    -rw-r--r-- jenkins-op/jenkins-op      128 2021-05-15 22:00 image-rwfs.sig
126    -rw-r--r-- jenkins-op/jenkins-op      128 2021-05-15 22:00 MANIFEST.sig
127    -rw-r--r-- jenkins-op/jenkins-op      128 2021-05-15 22:00 publickey.sig
128    -rw-r--r-- jenkins-op/jenkins-op      128 2021-05-15 22:00 image-full.sig
129
130    Command to re-name tar firmware image.
131
132    mv obmc-phosphor-image-witherspoon-20210516025203.ubi.mtd.tar bmc_bad_manifest.ubi.mtd.tar
133    ```
134
135*   No kernel image
136
137    ```
138    Command to list the content of the firmware image.
139
140    tar -tvf obmc-phosphor-image-witherspoon-20210516025203.ubi.mtd.tar
141    -rw-r--r-- jenkins-op/jenkins-op 306804 2021-05-15 22:00 image-u-boot
142    -rw-r--r-- jenkins-op/jenkins-op 3039300 2021-05-12 03:32 image-kernel
143    -rw-r--r-- jenkins-op/jenkins-op 19861504 2021-05-15 22:00 image-rofs
144    -rw-r--r-- jenkins-op/jenkins-op   850304 2021-05-15 22:00 image-rwfs
145    -rw-r--r-- jenkins-op/jenkins-op      176 2021-05-15 22:00 MANIFEST
146    -rw-r--r-- jenkins-op/jenkins-op      272 2021-05-15 22:00 publickey
147    -rw-r--r-- jenkins-op/jenkins-op      128 2021-05-15 22:00 image-u-boot.sig
148    -rw-r--r-- jenkins-op/jenkins-op      128 2021-05-15 22:00 image-kernel.sig
149    -rw-r--r-- jenkins-op/jenkins-op      128 2021-05-15 22:00 image-rofs.sig
150    -rw-r--r-- jenkins-op/jenkins-op      128 2021-05-15 22:00 image-rwfs.sig
151    -rw-r--r-- jenkins-op/jenkins-op      128 2021-05-15 22:00 MANIFEST.sig
152    -rw-r--r-- jenkins-op/jenkins-op      128 2021-05-15 22:00 publickey.sig
153    -rw-r--r-- jenkins-op/jenkins-op      128 2021-05-15 22:00 image-full.sig
154
155    Delete image-kernel file from the tar firmware image.
156
157    tar --delete -vf obmc-phosphor-image-witherspoon-20210516025203.ubi.mtd.tar image-kernel
158
159    tar -tvf obmc-phosphor-image-witherspoon-20210516025203.ubi.mtd.tar
160    -rw-r--r-- jenkins-op/jenkins-op 306804 2021-05-15 22:00 image-u-boot
161    -rw-r--r-- jenkins-op/jenkins-op 19861504 2021-05-15 22:00 image-rofs
162    -rw-r--r-- jenkins-op/jenkins-op   850304 2021-05-15 22:00 image-rwfs
163    -rw-r--r-- jenkins-op/jenkins-op      176 2021-05-15 22:00 MANIFEST
164    -rw-r--r-- jenkins-op/jenkins-op      272 2021-05-15 22:00 publickey
165    -rw-r--r-- jenkins-op/jenkins-op      128 2021-05-15 22:00 image-u-boot.sig
166    -rw-r--r-- jenkins-op/jenkins-op      128 2021-05-15 22:00 image-kernel.sig
167    -rw-r--r-- jenkins-op/jenkins-op      128 2021-05-15 22:00 image-rofs.sig
168    -rw-r--r-- jenkins-op/jenkins-op      128 2021-05-15 22:00 image-rwfs.sig
169    -rw-r--r-- jenkins-op/jenkins-op      128 2021-05-15 22:00 MANIFEST.sig
170    -rw-r--r-- jenkins-op/jenkins-op      128 2021-05-15 22:00 publickey.sig
171    -rw-r--r-- jenkins-op/jenkins-op      128 2021-05-15 22:00 image-full.sig
172
173    Command to re-name tar firmware image.
174
175    mv obmc-phosphor-image-witherspoon-20210516025203.ubi.mtd.tar bmc_nokernel_image.ubi.mtd.tar
176    ```
177
178*   Invalid key image
179
180    ```
181    Command to untar the firmware image.
182
183    tar -xvf obmc-phosphor-image-witherspoon-20210516025203.ubi.mtd.tar -C /directory_path/untar_files/
184    image-u-boot
185    image-kernel
186    image-rofs
187    image-rwfs
188    MANIFEST
189    publickey
190    image-u-boot.sig
191    image-kernel.sig
192    image-rofs.sig
193    image-rwfs.sig
194    MANIFEST.sig
195    publickey.sig
196    image-full.sig
197
198    Change few random characters in public key file that in turn corrupts the public key file.
199
200    Command to tar the firmware image files.
201
202    tar -cvf bmc_invalid_key.ubi.mtd.tar *
203    ```
204