blob: b8fbf8c48a3ed241011938ae21838e0d9b459661 [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 Keishing06616252025-04-28 19:20:41 +053011Test Tags IPMI_Flash
George Keishing87dc4422023-10-20 12:56:30 +053012
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
George Keishing06616252025-04-28 19:20:41 +053029 Wait For Host To Ping ${OS_HOST} 3 mins
Tim Lee48d80bd2021-01-25 15:41:37 +080030
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
George Keishing06616252025-04-28 19:20:41 +053092 IF '${OS_BOOT_COMPLETE}' != '${os_state}' Redfish Power On
Tim Lee48d80bd2021-01-25 15:41:37 +080093
94 # generate bad image for test
95 ${cmd}= Catenate dd if=/dev/urandom of=${HOST_WORK_DIR}/${BAD_IMG} bs=1K count=4
96 OS Execute Command ${cmd} ignore_err=1
97 ${cmd}= Catenate dd if=/dev/urandom of=${HOST_WORK_DIR}/${BAD_SIG} bs=1 count=128
98 OS Execute Command ${cmd} ignore_err=1
99
100
101Get LPC SHM Address
102 [Documentation] Get Mapped Address of LPC hare Memory.
103
104 # select SHM logic device
105 OS Execute Command outb 0x4e 0x07
106 OS Execute Command outb 0x4f 0x0f
107
108 OS Execute Command outb 0x4e 0xf4
109 ${output} ${stderr} ${rc}= OS Execute Command inb 0x4f
110 ${output}= Evaluate ${output} + 4
111 ${b0}= Convert To Hex ${output} length=2
112
113 OS Execute Command outb 0x4e 0xf5
114 ${output} ${stderr} ${rc}= OS Execute Command inb 0x4f
115 ${b1}= Convert To Hex ${output} length=2
116
117 OS Execute Command outb 0x4e 0xf6
118 ${output} ${stderr} ${rc}= OS Execute Command inb 0x4f
119 ${b2}= Convert To Hex ${output} length=2
120
121 OS Execute Command outb 0x4e 0xf7
122 ${output} ${stderr} ${rc}= OS Execute Command inb 0x4f
123 ${b3}= Convert To Hex ${output} length=2
124
125 Set Global Variable ${lpcshm_address} ${b3}${b2}${b1}${b0}
126 Rprint Vars lpcshm_address
127
128BIOS Update Status Should Be
129 [Documentation] Check the Update Process is Activating.
130 [Arguments] ${state}
131
132 # Description of argument(s):
133 # state The state of update process.
134
135 ${cmd}= Catenate systemctl show --property=ActiveState --property=LoadState
136 ... --property=Result phosphor-ipmi-flash-bios-update.service
137 ${output} ${stderr} ${rc}= BMC Execute Command ${cmd}
138
139 Should Contain ${output} ${state} case_insensitive=True
140
141Verify BIOS Version
142 [Documentation] Verify BIOS Version.
143 [Arguments] ${image_file_path}
144
145 # Description of argument(s):
146 # image_file_path Path to the image tarball.
147
148 ${image_version}= Get Version Tar ${image_file_path}
149 Rprint Vars image_version
150
151 ${BIOS_Version}= Get BIOS Version
152 Rprint Vars BIOS_Version
153 Should Be Equal ${BIOS_Version} ${image_version}
154
155Verify BMC Version
156 [Documentation] Verify that the version on the BMC is the same as the
157 ... version in the given image via Redfish.
158 [Arguments] ${image_file_path}
159
160 # Description of argument(s):
161 # image_file_path Path to the image tarball.
162
163 # Extract the version from the image tarball on our local system.
164 ${image_version}= Get Version Tar ${image_file_path}
165 Rprint Vars image_version
166 Redfish.Login
167 ${bmc_version}= Redfish Get BMC Version
168 Rprint Vars bmc_version
169
170 Valid Value bmc_version valid_values=['${image_version}']
171
172Update BIOS Firmware
173 [Documentation] Update BIOS Firmware.
174 [Arguments] ${image_file_path}
175
176 # Description of argument(s):
177 # image_file_path Path to the image tarball.
178
179 OperatingSystem.File Should Exist ${image_file_path}
180
181 Run Keyword Wait For Host To Ping ${OS_HOST} 3 mins
182
183 scp.Open connection ${OS_HOST} username=${OS_USERNAME}
184 ... password=${OS_PASSWORD}
185 scp.Put File ${image_file_path} ${HOST_WORK_DIR}/${image_file_path}
186
187 ${cmd}= Catenate tar -xf ${HOST_WORK_DIR}/${image_file_path} -C ${HOST_WORK_DIR}
188 ${output} ${stderr} ${rc}= OS Execute Command ${cmd}
189
190 ${cmd}= Catenate ${HOST_WORK_DIR}/burn_my_bmc --command update --interface ipmilpc
191 ... --image ${HOST_WORK_DIR}/${image-bios} --sig ${HOST_WORK_DIR}/${image-bios-sig} --type bios
192 ... --address 0x${lpcshm_address} --length 0xFFC
193
194 OS Execute Command ${cmd} fork=1
195
196 Wait Until Keyword Succeeds 5 mins 10 secs
197 ... BIOS Update Status Should Be ActiveState=activating
198
199 Wait Until Keyword Succeeds 20 mins 30 secs
200 ... BIOS Update Status Should Be ActiveState=inactive
201
202 ${cmd}= Catenate systemctl show --property=Result
203 ... phosphor-ipmi-flash-bios-update.service
204 ${output} ${stderr} ${rc}= BMC Execute Command ${cmd}
205 Should Contain ${output} Result=success
206
207 Run Keyword Wait For Host To Ping ${OS_HOST} 5 mins
208
209Update BMC Firmware
210 [Documentation] Update BIOS Firmware.
211 [Arguments] ${image_file_path}
212
213 # Description of argument(s):
214 # image_file_path Path to the image tarball.
215
216 OperatingSystem.File Should Exist ${image_file_path}
217
218 Run Keyword Wait For Host To Ping ${OS_HOST} 3 mins
219
220 scp.Open connection ${OS_HOST} username=${OS_USERNAME}
221 ... password=${OS_PASSWORD}
222 scp.Put File ${image_file_path} ${HOST_WORK_DIR}/${image_file_path}
223
224 ${cmd}= Catenate tar -xf ${HOST_WORK_DIR}/${image_file_path} -C ${HOST_WORK_DIR}
225 ${output} ${stderr} ${rc}= OS Execute Command ${cmd}
226
227 ${cmd}= Catenate ${HOST_WORK_DIR}/burn_my_bmc --command update --interface ipmilpc
228 ... --image ${HOST_WORK_DIR}/${image-bmc} --sig ${HOST_WORK_DIR}/${image-bmc-sig} --type image
229 ... --address 0x${lpcshm_address} --length 0xFFC --ignore-update
230
231 ${output} ${stderr} ${rc}= OS Execute Command ${cmd} ignore_err=1
232 Should Not Contain ${stderr} Exception received
233
234 Sleep 10s
George Keishing06616252025-04-28 19:20:41 +0530235 Check If BMC Is Up 20 min 20 sec
Tim Lee48d80bd2021-01-25 15:41:37 +0800236 Wait For BMC Ready