BMC REDFISH
REDFISH UPDATE FIRMWARE
| zhangjian38 | 2020-3-23 | v0.1 | Init version |
| zhangjian38 | 2020-3-26 | v0.2 | Click for Details |
文章目錄
- REDFISH UPDATE FIRMWARE
- 1. Update SOP
- 1.1 Upload image file
- 1.2 Start Update
- 2. Key Code Flow
- 2.1 Upload image file
- 2.2 Start Update
1. Update SOP
More details please refer to MegaRAC Redfish - API Doc (v1.7)
1.1 Upload image file
-
URI : https://$ip/redfish/v1/UpdateService/Actions/Oem/UpdateService.UploadFirmwareImage
-
Method : POST
-
Body : type form-data, value "Key":"image_file ", "Value":"<image_file_path>"
Note : This method use local file, not include transfer by ftp or http server
1.2 Start Update
-
URI : https://$ip/redfish/v1/UpdateService/Actions/Oem/UpdateService.BMCFwUpdate
-
Method : POST
-
Body : type JSON(application/json), value {"FlashType":"FULLFwUpdate","UploadSelector":"Default"}
Note : The details about FlashType and UploadSelector Please refet to MegaRAC Redfish - API Doc (v1.7) 3.65.3.3
2. Key Code Flow
? packages:
? update_service_redfish_extension-src
? libredfishflash-src
? gami_bmc_update_module-src
2.1 Upload image file
-
URI Define File : update_service_redfish_extension-6.56.0.0.0-src/data/app/RTP_1_5/extensions/redfish-resource/updateservice/redfish-resource-URI_pattern.lua
local URI_pattern = {{ key = "updateservice_upload_action", pattern = "^" .. CONFIG.SERVICE_PREFIX .. "/UpdateService/(Actions)/(Oem)/(UpdateService.UploadFirmwareImage)$"},... } -
Handler Define File : update_service_redfish_extension-6.56.0.0.0-src/data/app/RTP_1_5/extensions/redfish-resource/updateservice/redfish-resource-handler.lua
local UploadFileHandler = require("redfish.upload-file") ... local handler_table = {updateservice_upload_action = UploadFileHandler, ... } -
Handle Invoke :
- When Upload image file, UploadFileHandler:post will be invoked, in file upload-file.lua function UploadFileHandler:post(target, info, action) ... end
-
Judge that the URL parameter is valid ([There’s](javascript:😉 [nothing](javascript:😉 [to](javascript:😉 [say](javascript:😉 )
-
Wirte image to /tmp/redfishfwupdate/rom.ima
function UploadFileHandler:post(target, info, action)...local redis = self:get_db()local IsSignedImage = "Redfish:UpdateService:Oem:AMI:BMC:UploadedImageFormat"if string.match(fname, '(.-%.ima_enc)$') thencoroutine.yield(redis:set(IsSignedImage, "signed"))elsecoroutine.yield(redis:set(IsSignedImage, "unsigned"))endlocal tmp_name = "/tmp/redfishfwupdate/"local f = io.open(tmp_name .. "rom.ima", "w")f:write(parsed_body)f:close()local fwupdate_in_progress = "Redfish:UpdateService:Oem:AMI:BMC:FWUpdateInProgress"local image_path = tmp_name .. "rom.ima"coroutine.yield(redis:set(fwupdate_in_progress, image_path))... end
2.2 Start Update
-
**URI and Handler Define ** was same as 2.1 Upload image file
-
Handle Invoke :
-
When start update, UpdateServiceHandler:post will be invoked, in file update-service.lua
Note : This Handler Cotains simple update and ami oem update, Now ,I only focus on oem update
function UpdateServiceHandler:post(target, info, action)
...
end
-
Judge that the URL parameter is valid ([There’s](javascript:😉 [nothing](javascript:😉 [to](javascript:😉 [say](javascript:😉 )
-
Invoke function flashBMC()
a. Find Image File
local imagefile=io.popen("ls /tmp/redfishfwupdate/") local uploadedimage=imagefile:read("*a") imagefile:close()if string.find(uploadedimage,"rom.ima") == nil thenself:error_action_requires_file() endb. Set update parameter .
local FlashType = request_data.FlashType local UploadSelector = request_data.UploadSelectorc. Checking ActiveImage and InactivedImage
d. Start update, create a file and set redis for update.
os.execute("touch "..FLASHER_START_FILE) local redis_action_key = "POST:Redfish:UpdateService:OemAction:StartFwUpdate:BMC"yield(redis:set(redis_action_key, turbo.escape.json_encode(request_data))) -
package : gami_bmc_update_module-src , FwUpdate.lua ,function FwUpdate.StartFwUpdate = function(group_name) will be invoked.
TODO : I don’t know why and how this function will be invoked
Note : Why this this function will be invoked, please refer to doc “REDIS 2 FUNCTION HANDLER”
FwUpdate.StartFwUpdate = function(group_name)...wRet = FwUpdate.UpdateFw_BMC(reqdata)... endIn function UpdateFw_BMC
a. Set to FlashMode
<font color=red>**This lib will sending a command to `/var/pipe/flasher_cmd`** </font>```luafunction updateservice:set_flashmode()os.execute("echo '0' > "..FLASHER_FLASHPercent_FILE)local dual_image_support = updateservice:checkDualImageSupport()local wRet = flashlibrary.PrepareFlashArea(FLSH_CMD_PREP_TFTP_FLASH_AREA, dual_image_support)end```
libipmi_update.updateservice:set_flashmode()
CALL LIB REDFISH FLASH(libredfishflash-src)b. Download Image from Remote Path
```luawRet = libipmi_update.updateservice:download_image()```Copy File to /mnt/fwupdate```luafunction updateservice:download_image()os.execute("touch "..FLASHER_DOWNLOAD_FILE)print("Uploading Image from /tmp/redfishfwupdate/ to /mnt/fwupdate/")local cmd = "cp /tmp/redfishfwupdate/rom.ima /mnt/fwupdate/rom.ima"local wRet = os.execute("echo '"..cmd.."'> /tmp/downloadimage_redfish.pid | "..cmd)end```c. Verify Image, CALL LIB REDFISH FLASH
```luafunction updateservice:verifyimage_bmc(flashtype)wRet = flashlibrary.VerifyFirmwareImage(VeriInfo[0], section_info[0], section_count)end```d. Flash Image
CALL LIB REDFISH FLASHLIB REDFISH FLASH Function `StartImageFlash`, send cmd to `"/var/pipe/flasher_cmd"````cint StartImageFlash (unsigned char PreserveCfg, unsigned char ResetBMC,unsigned char FlashType,void *SectionName,INT8U MaxSectionCount){FlasherCmd Cmd;Cmd.Command = REDFISH_FLASH_CMD_START_FLASH;SendCmdExpectNoReply(Cmd);}```Get Progress```luaProgressState = flashlibrary.GetFlashProgress(flprog) local Progress = ffi.string(flprog.Progress, ffi.sizeof(flprog.Progress)) Progress = string.match(Progress, "(%d+)")```
lua wRet = libipmi_update.updateservice:startflash_bmc(flashtype, parameter)
總結
以上是生活随笔為你收集整理的BMC REDFISH的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python处理时间序列非平稳_【Pyt
- 下一篇: DB2-SQLCODE 错误码大全---