blob: a69405d926348e20be544bf203763119295eb8f3 [file] [log] [blame]
Tim Lee48d80bd2021-01-25 15:41:37 +08001*** Settings ***
2Documentation Module to test In band firmware update.
3
Stanley Chubc284352021-06-08 10:48:48 +08004Resource ../../lib/ipmi_client.robot
5Resource ../../lib/openbmc_ffdc.robot
6Resource ../../lib/connection_client.robot
7Resource ../../lib/code_update_utils.robot
Tim Lee48d80bd2021-01-25 15:41:37 +08008
9Suite Setup Suite Setup Execution
10
George Keishing87dc4422023-10-20 12:56:30 +053011Force Tags IPMI_Flash
12
Tim Lee48d80bd2021-01-25 15:41:37 +080013*** Variables ***
George Keishing87dc4422023-10-20 12:56:30 +053014
Tim Lee48d80bd2021-01-25 15:41:37 +080015${image-bios} image-bios
16${image-bios-sig} image-bios.sig
17${image-bmc} image-bmc
18${image-bmc-sig} image-bmc.sig
19${BAD_IMG} tmp.bin
20${BAD_SIG} tmp.sig
21${lpcshm_address} ${0}
22
23*** Test Cases ***
24
25Test BIOS Firmware Update
26 [Documentation] Test BIOS firmware update over IPMI.
27 [Tags] Test_BIOS_Firmware_Update
28
29 Run Keyword Wait For Host To Ping ${OS_HOST} 3 mins
30
31 Get LPC SHM Address
32 Update BIOS Firmware ${IMAGE_HOST_FILE_PATH_0}
33 Verify BIOS Version ${IMAGE_HOST_FILE_PATH_0}
34 BMC Execute Command
35 ... systemctl restart phosphor-ipmi-host.service
36 Sleep 10s
37 Get LPC SHM Address
38 Update BIOS Firmware ${IMAGE_HOST_FILE_PATH_1}
39 Verify BIOS Version ${IMAGE_HOST_FILE_PATH_1}
40 BMC Execute Command
41 ... systemctl restart phosphor-ipmi-host.service
42 Sleep 10s
43
44Test Invalid BIOS Firmware Update
45 [Documentation] Test Invalid BIOS firmware update over IPMI.
46 [Tags] Test_Invalid_BIOS_Firmware_Update
47
48 Run Keyword Wait For Host To Ping ${OS_HOST} 3 mins
49 Get LPC SHM Address
50
51 ${cmd}= Catenate ${HOST_WORK_DIR}/burn_my_bmc --command update --interface ipmilpc
52 ... --image ${HOST_WORK_DIR}/${BAD_IMG} --sig ${HOST_WORK_DIR}/${BAD_SIG} --type bios
53 ... --address 0x${lpcshmaddress} --length 0xFFC
54
55 ${output} ${stderr} ${rc}= OS Execute Command ${cmd} ignore_err=1
56 Should Contain ${stderr} Verification failed
57
58Test BMC Firmware Update
59 [Documentation] Test BMC firmware update over IPMI.
60 [Tags] Test_BMC_Firmware_Update
61
62 Run Keyword Wait For Host To Ping ${OS_HOST} 3 mins
63 Get LPC SHM Address
64 Update BMC Firmware ${IMAGE_BMC_FILE_PATH_0}
65 Verify BMC Version ${IMAGE_BMC_FILE_PATH_0}
66 Sleep 10s
67 Update BMC Firmware ${IMAGE_BMC_FILE_PATH_1}
68 Verify BMC Version ${IMAGE_BMC_FILE_PATH_1}
69
70Test Invalid BMC Firmware Update
71 [Documentation] Test Invalid BMC firmware update over IPMI.
72 [Tags] Test_Invalid_BMC_Firmware_Update
73
74 Run Keyword Wait For Host To Ping ${OS_HOST} 3 mins
75 Get LPC SHM Address
76
77 ${cmd}= Catenate ${HOST_WORK_DIR}/burn_my_bmc --command update --interface ipmilpc
78 ... --image ${HOST_WORK_DIR}/${BAD_IMG} --sig ${HOST_WORK_DIR}/${BAD_SIG} --type image
79 ... --address 0x${lpcshmaddress} --length 0xFFC
80
81 ${output} ${stderr} ${rc}= OS Execute Command ${cmd} ignore_err=1
82 Should Contain ${stderr} Verification failed
83
84
85*** Keywords ***
86
87Suite Setup Execution
George Keishing3fb75582021-02-10 05:00:09 -060088 [Documentation] Suite Setup Execution.
Tim Lee48d80bd2021-01-25 15:41:37 +080089
90 ${os_state}= Get Host State Attribute OperatingSystemState
91 Rprint Vars os_state
92 Run Keyword if '${OS_BOOT_COMPLETE}' != '${os_state}'
93 ... Redfish Power On
94
95 # generate bad image for test
96 ${cmd}= Catenate dd if=/dev/urandom of=${HOST_WORK_DIR}/${BAD_IMG} bs=1K count=4
97 OS Execute Command ${cmd} ignore_err=1
98 ${cmd}= Catenate dd if=/dev/urandom of=${HOST_WORK_DIR}/${BAD_SIG} bs=1 count=128
99 OS Execute Command ${cmd} ignore_err=1
100
101
102Get LPC SHM Address
103 [Documentation] Get Mapped Address of LPC hare Memory.
104
105 # select SHM logic device
106 OS Execute Command outb 0x4e 0x07
107 OS Execute Command outb 0x4f 0x0f
108
109 OS Execute Command outb 0x4e 0xf4
110 ${output} ${stderr} ${rc}= OS Execute Command inb 0x4f
111 ${output}= Evaluate ${output} + 4
112 ${b0}= Convert To Hex ${output} length=2
113
114 OS Execute Command outb 0x4e 0xf5
115 ${output} ${stderr} ${rc}= OS Execute Command inb 0x4f
116 ${b1}= Convert To Hex ${output} length=2
117
118 OS Execute Command outb 0x4e 0xf6
119 ${output} ${stderr} ${rc}= OS Execute Command inb 0x4f
120 ${b2}= Convert To Hex ${output} length=2
121
122 OS Execute Command outb 0x4e 0xf7
123 ${output} ${stderr} ${rc}= OS Execute Command inb 0x4f
124 ${b3}= Convert To Hex ${output} length=2
125
126 Set Global Variable ${lpcshm_address} ${b3}${b2}${b1}${b0}
127 Rprint Vars lpcshm_address
128
129BIOS Update Status Should Be
130 [Documentation] Check the Update Process is Activating.
131 [Arguments] ${state}
132
133 # Description of argument(s):
134 # state The state of update process.
135
136 ${cmd}= Catenate systemctl show --property=ActiveState --property=LoadState
137 ... --property=Result phosphor-ipmi-flash-bios-update.service
138 ${output} ${stderr} ${rc}= BMC Execute Command ${cmd}
139
140 Should Contain ${output} ${state} case_insensitive=True
141
142Verify BIOS Version
143 [Documentation] Verify BIOS Version.
144 [Arguments] ${image_file_path}
145
146 # Description of argument(s):
147 # image_file_path Path to the image tarball.
148
149 ${image_version}= Get Version Tar ${image_file_path}
150 Rprint Vars image_version
151
152 ${BIOS_Version}= Get BIOS Version
153 Rprint Vars BIOS_Version
154 Should Be Equal ${BIOS_Version} ${image_version}
155
156Verify BMC Version
157 [Documentation] Verify that the version on the BMC is the same as the
158 ... version in the given image via Redfish.
159 [Arguments] ${image_file_path}
160
161 # Description of argument(s):
162 # image_file_path Path to the image tarball.
163
164 # Extract the version from the image tarball on our local system.
165 ${image_version}= Get Version Tar ${image_file_path}
166 Rprint Vars image_version
167 Redfish.Login
168 ${bmc_version}= Redfish Get BMC Version
169 Rprint Vars bmc_version
170
171 Valid Value bmc_version valid_values=['${image_version}']
172
173Update BIOS Firmware
174 [Documentation] Update BIOS Firmware.
175 [Arguments] ${image_file_path}
176
177 # Description of argument(s):
178 # image_file_path Path to the image tarball.
179
180 OperatingSystem.File Should Exist ${image_file_path}
181
182 Run Keyword Wait For Host To Ping ${OS_HOST} 3 mins
183
184 scp.Open connection ${OS_HOST} username=${OS_USERNAME}
185 ... password=${OS_PASSWORD}
186 scp.Put File ${image_file_path} ${HOST_WORK_DIR}/${image_file_path}
187
188 ${cmd}= Catenate tar -xf ${HOST_WORK_DIR}/${image_file_path} -C ${HOST_WORK_DIR}
189 ${output} ${stderr} ${rc}= OS Execute Command ${cmd}
190
191 ${cmd}= Catenate ${HOST_WORK_DIR}/burn_my_bmc --command update --interface ipmilpc
192 ... --image ${HOST_WORK_DIR}/${image-bios} --sig ${HOST_WORK_DIR}/${image-bios-sig} --type bios
193 ... --address 0x${lpcshm_address} --length 0xFFC
194
195 OS Execute Command ${cmd} fork=1
196
197 Wait Until Keyword Succeeds 5 mins 10 secs
198 ... BIOS Update Status Should Be ActiveState=activating
199
200 Wait Until Keyword Succeeds 20 mins 30 secs
201 ... BIOS Update Status Should Be ActiveState=inactive
202
203 ${cmd}= Catenate systemctl show --property=Result
204 ... phosphor-ipmi-flash-bios-update.service
205 ${output} ${stderr} ${rc}= BMC Execute Command ${cmd}
206 Should Contain ${output} Result=success
207
208 Run Keyword Wait For Host To Ping ${OS_HOST} 5 mins
209
210Update BMC Firmware
211 [Documentation] Update BIOS Firmware.
212 [Arguments] ${image_file_path}
213
214 # Description of argument(s):
215 # image_file_path Path to the image tarball.
216
217 OperatingSystem.File Should Exist ${image_file_path}
218
219 Run Keyword Wait For Host To Ping ${OS_HOST} 3 mins
220
221 scp.Open connection ${OS_HOST} username=${OS_USERNAME}
222 ... password=${OS_PASSWORD}
223 scp.Put File ${image_file_path} ${HOST_WORK_DIR}/${image_file_path}
224
225 ${cmd}= Catenate tar -xf ${HOST_WORK_DIR}/${image_file_path} -C ${HOST_WORK_DIR}
226 ${output} ${stderr} ${rc}= OS Execute Command ${cmd}
227
228 ${cmd}= Catenate ${HOST_WORK_DIR}/burn_my_bmc --command update --interface ipmilpc
229 ... --image ${HOST_WORK_DIR}/${image-bmc} --sig ${HOST_WORK_DIR}/${image-bmc-sig} --type image
230 ... --address 0x${lpcshm_address} --length 0xFFC --ignore-update
231
232 ${output} ${stderr} ${rc}= OS Execute Command ${cmd} ignore_err=1
233 Should Not Contain ${stderr} Exception received
234
235 Sleep 10s
236 Check If BMC is Up 20 min 20 sec
237 Wait For BMC Ready