Skip to content

Commit

Permalink
yosemite4: Support update single blade PLDM Firmware Device
Browse files Browse the repository at this point in the history
Summary:
# Description
- Support update single blade PLDM firmware device.
- This commit support updating BICs and CXLs.
  - Support update single blade SD/FF/WF BIC.
  - Support update single CXL on specific blade.

# Motivation
- User unable to update single blade BIC FW by BMC, BMC will update for all available blades together.

X-link: facebookexternal/openbmc.wiwynn#2998

Test Plan:
- User can update single blade SD/FF/WF BIC.
- User can update single CXL on specific blade.

- Test Log [Update single blade SD BIC]

[Recovery]
root@bmc:~# bic-update.sh sd --rcvy 5 /tmp/uart_Y4BSD.bin /tmp/pldm_sd_bic_image_with_slot Start to Recovery slot 5 sd BIC
UART is ttyS5
i2c bus is 4
Setting BIC boot from UART
Doing the recovery update...
Recovery BIC is finished.
Restart MCTP/PLDM daemon
`- /xyz
  `- /xyz/openbmc_project
    `- /xyz/openbmc_project/mctp
      `- /xyz/openbmc_project/mctp/1
        |- /xyz/openbmc_project/mctp/1/50
        `- /xyz/openbmc_project/mctp/1/8
Start to Update BIC
software_id = 3207297738
Waiting for updating... 14 sec
Update done.
slot5: Do 12V cycle
Done

[BIC console]
[00:00:36.312,000] <inf> pldm: package loaded: 88% [00:00:36.459,000] <inf> pldm: package loaded: 89% [00:00:36.610,000] <inf> pldm: package loaded: 90% [00:00:36.743,000] <inf> pldm: package loaded: 91% [00:00:36.873,000] <inf> pldm: package loaded: 92% [00:00:37.005,000] <inf> pldm: package loaded: 93% [00:00:37.146,000] <inf> pldm: package loaded: 94% [00:00:37.304,000] <inf> pldm: package loaded: 95% [00:00:37.453,000] <inf> pldm: package loaded: 96% [00:00:37.602,000] <inf> pldm: package loaded: 97% [00:00:37.738,000] <inf> pldm: package loaded: 98% [00:00:37.896,000] <inf> pldm: package loaded: 99% [00:00:38.032,000] <inf> pldm: package loaded: 100% [00:00:38.064,000] <inf> util_spi: Update success
[00:00:38.074,000] <inf> pldm: Component 0 update success! [00:00:38.074,000] <inf> pldm: Transfer complete
[00:00:38.076,000] <inf> pldm: Verify complete
[00:00:38.078,000] <inf> pldm: Apply complete
[00:00:38.082,000] <inf> pldm: Activate firmware

[Update Single blade SD BIC]
root@bmc:~/chris# ./bic-update.sh sd 5 ./pldm_sd_bic_image_with_slot `- /xyz
  `- /xyz/openbmc_project
    `- /xyz/openbmc_project/mctp
      `- /xyz/openbmc_project/mctp/1
        |- /xyz/openbmc_project/mctp/1/50
        `- /xyz/openbmc_project/mctp/1/8
Start to Update BIC
software_id = 3207297738
Waiting for updating... 14 sec
Update done.
Done

(BIC console was checked to make sure only slot 5 is updated)

[Update all SD BICs]
root@bmc:~/chris# bic-update.sh sd pldm_sd_bic_image_main WARNING! This will automatically update all BICs.
Continue? [y/N] y
`- /xyz
  `- /xyz/openbmc_project
    `- /xyz/openbmc_project/mctp
      `- /xyz/openbmc_project/mctp/1
        |- /xyz/openbmc_project/mctp/1/50
        `- /xyz/openbmc_project/mctp/1/8
Start to Update BIC
software_id = 3207297738
Waiting for updating... 17 sec
Update done.
Done

(BIC console was checked to make sure all slots are updated)

[Check Desciptors]
root@bmc:~# pldmtool fw_update QueryDeviceIdentifiers -m 50 -v pldmtool: Tx: 80 05 01
pldmtool: Rx: 00 05 01 00 1c 00 00 00 03 01 00 04 00 00 00 a0 15 00 01 02 00 00 00 07 01 0a 00 35 00 00 00 00 00 00 00 00 00 Unknown descriptor type, type=263
{
    "EID": 50,
    "Descriptors": [
        {
            "Type": "IANA Enterprise ID",
            "Value": [
                "0000a015"
            ]
        },
        {
            "Type": "PCI Device ID",
            "Value": [
                "0000"
            ]
        }
    ]
}

[WF BIC]

[Recovery]
root@bmc:~# bic-update.sh wf --rcvy 5 ~/chris/uart_Y4BWF_with_slot.bin ~/chris/pldm_wf_bic_image_with_slot Start to Recovery slot 5 wf BIC
Check Power : On
UART is ttyS5
i2c bus is 4
Setting BIC boot from UART
Doing the recovery update...
Recovery BIC is finished.
pldmtool: Tx: 80 02 39 01 01 01 01 01
pldmtool: Rx: 00 02 39 00
Restart MCTP/PLDM daemon
`- /xyz
  `- /xyz/openbmc_project
    `- /xyz/openbmc_project/mctp
      `- /xyz/openbmc_project/mctp/1
        |- /xyz/openbmc_project/mctp/1/50
        |- /xyz/openbmc_project/mctp/1/51
        |- /xyz/openbmc_project/mctp/1/52
        |- /xyz/openbmc_project/mctp/1/53
        `- /xyz/openbmc_project/mctp/1/8
Start to Update BIC
software_id = 3648103133
Waiting for updating... 20 sec
Update done.
slot5: Do 12V cycle
Done

[DC on to make sure WF BIC is online]
root@bmc:~# busctl set-property xyz.openbmc_project.State.Host${slot} /xyz/openbmc_project/state/host${slot} xyz.openbmc_project.State.Host RequestedHostTransition s "xyz.openbmc_project.State.Host.Transition.On" root@bmc:~# systemctl restart mctpd
root@bmc:~# busctl tree xyz.openbmc_project.MCTP
`- /xyz
  `- /xyz/openbmc_project
    `- /xyz/openbmc_project/mctp
      `- /xyz/openbmc_project/mctp/1
        |- /xyz/openbmc_project/mctp/1/50
        |- /xyz/openbmc_project/mctp/1/51
        |- /xyz/openbmc_project/mctp/1/52
        `- /xyz/openbmc_project/mctp/1/8

[Update single blade of WF BIC]
root@bmc:~# bic-update.sh wf 5 ~/chris/pldm_wf_bic_image_with_slot `- /xyz
  `- /xyz/openbmc_project
    `- /xyz/openbmc_project/mctp
      `- /xyz/openbmc_project/mctp/1
        |- /xyz/openbmc_project/mctp/1/50
        |- /xyz/openbmc_project/mctp/1/51
        |- /xyz/openbmc_project/mctp/1/52
        `- /xyz/openbmc_project/mctp/1/8
Start to Update BIC
software_id = 3648103133
Waiting for updating... 16 sec
Update done.
Done

root@bmc:~# pldmtool fw_update QueryDeviceIdentifiers -m 52 -v pldmtool: Tx: 80 05 01
pldmtool: Rx: 00 05 01 00 1c 00 00 00 03 01 00 04 00 00 00 a0 15 00 01 02 00 00 02 07 01 0a 00 35 00 00 00 00 00 00 00 00 00 Unknown descriptor type, type=263
{
    "EID": 52,
    "Descriptors": [
        {
            "Type": "IANA Enterprise ID",
            "Value": [
                "0000a015"
            ]
        },
        {
            "Type": "PCI Device ID",
            "Value": [
                "0002"
            ]
        }
    ]
}

[FF BIC]
[Recovery]

root@bmc:~# bic-update.sh ff --rcvy 5 ~/chris/uart_Y4BFF_with_slot.bin ~/chris/pldm_ff_bic_image_with_slot Start to Recovery slot 5 ff BIC
Check Power : On
UART is ttyS5
i2c bus is 4
Setting BIC boot from UART
Doing the recovery update...
Recovery BIC is finished.
pldmtool: Tx: 80 02 39 01 01 01 01 01
pldmtool: Rx: 00 02 39 00
Restart MCTP/PLDM daemon
`- /xyz
  `- /xyz/openbmc_project
    `- /xyz/openbmc_project/mctp
      `- /xyz/openbmc_project/mctp/1
        |- /xyz/openbmc_project/mctp/1/50
        |- /xyz/openbmc_project/mctp/1/51
        |- /xyz/openbmc_project/mctp/1/52
        |- /xyz/openbmc_project/mctp/1/54
        `- /xyz/openbmc_project/mctp/1/8
Start to Update BIC
software_id = 3463480235
Waiting for updating... 115 sec
Update done.
slot5: Do 12V cycle
Done

[DC on to make sure FF BIC is online]
root@bmc:~# busctl set-property xyz.openbmc_project.State.Host${slot} /xyz/openbmc_project/state/host${slot} xyz.openbmc_project.State.Host RequestedHostTransition s "xyz.openbmc_project.State.Host.Transition.On" root@bmc:~# systemctl restart mctpd
root@bmc:~# busctl tree xyz.openbmc_project.MCTP
`- /xyz
  `- /xyz/openbmc_project
    `- /xyz/openbmc_project/mctp
      `- /xyz/openbmc_project/mctp/1
        |- /xyz/openbmc_project/mctp/1/50
        |- /xyz/openbmc_project/mctp/1/51
        |- /xyz/openbmc_project/mctp/1/52
        `- /xyz/openbmc_project/mctp/1/8

[Update single blade of FF BIC]
root@bmc:~# bic-update.sh ff 5 ~/chris/pldm_ff_bic_image_with_slot `- /xyz
  `- /xyz/openbmc_project
    `- /xyz/openbmc_project/mctp
      `- /xyz/openbmc_project/mctp/1
        |- /xyz/openbmc_project/mctp/1/50
        |- /xyz/openbmc_project/mctp/1/51
        |- /xyz/openbmc_project/mctp/1/52
        |- /xyz/openbmc_project/mctp/1/54
        |- /xyz/openbmc_project/mctp/1/55
        `- /xyz/openbmc_project/mctp/1/8
Start to Update BIC
software_id = 3463480235
Waiting for updating... 16 sec
Update done.
Done

root@bmc:~# pldmtool fw_update QueryDeviceIdentifiers -m 51 -v pldmtool: Tx: 80 05 01
pldmtool: Rx: 00 05 01 00 1c 00 00 00 03 01 00 04 00 00 00 a0 15 00 01 02 00 00 01 07 01 0a 00 35 00 00 00 00 00 00 00 00 00 Unknown descriptor type, type=263
{
    "EID": 51,
    "Descriptors": [
        {
            "Type": "IANA Enterprise ID",
            "Value": [
                "0000a015"
            ]
        },
        {
            "Type": "PCI Device ID",
            "Value": [
                "0001"
            ]
        }
    ]
}

[Update CXL2]

[Check original version]
root@bmc:~# cxl-fw-update version -m 55
Get Firmware Info for EID: 55
FW Slots Supported: 2
Active FW Slot: 1
Staged FW Slot: 2
FW Activation Capabilities: 1
Slot 1 FW Revision: 2.0.5-b5d9fe65c
Slot 2 FW Revision:
Slot 3 FW Revision:
Slot 4 FW Revision:

[Update]
root@bmc:~# cxl-fw-update.sh 5 2 pldm_wf_cxl_2.0.7 software_id = 3648103133
Waiting for updating... 393 sec
Update done.
Update done. Please conduct DC cycle to load the new firmware.

[Reboot Host]
root@bmc:~# busctl set-property xyz.openbmc_project.State.Host5 /xyz/openbmc_project/state/host5 xyz.openbmc_project.State.Host RequestedHostTransition s "xyz.openbmc_project.State.Host.Transition.Reboot"

[Check the version again]
root@bmc:~# cxl-fw-update version -m 55
Get Firmware Info for EID: 55
FW Slots Supported: 2
Active FW Slot: 1
Staged FW Slot: 2
FW Activation Capabilities: 1
Slot 1 FW Revision: 2.0.7-465f8f505
Slot 2 FW Revision:
Slot 3 FW Revision:
Slot 4 FW Revision:

[Update CXL1]

[Check original version]
root@bmc:~# cxl-fw-update version -m 54
Get Firmware Info for EID: 54
FW Slots Supported: 2
Active FW Slot: 1
Staged FW Slot: 2
FW Activation Capabilities: 1
Slot 1 FW Revision: 2.0.5-b5d9fe65c
Slot 2 FW Revision:
Slot 3 FW Revision:
Slot 4 FW Revision:

[Update]
root@bmc:~# cxl-fw-update.sh 5 1 pldm_wf_cxl_2.0.7 software_id = 3648103133
Waiting for updating... 389 sec
Update done.
Update done. Please conduct DC cycle to load the new firmware.

[Reboot Host]
root@bmc:~# busctl set-property xyz.openbmc_project.State.Host5 /xyz/openbmc_project/state/host5 xyz.openbmc_project.State.Host RequestedHostTransition s "xyz.openbmc_project.State.Host.Transition.Reboot"

[Check the version again]
root@bmc:~# cxl-fw-update version -m 54
Get Firmware Info for EID: 54
FW Slots Supported: 2
Active FW Slot: 1
Staged FW Slot: 2
FW Activation Capabilities: 1
Slot 1 FW Revision: 2.0.7-465f8f505
Slot 2 FW Revision:
Slot 3 FW Revision:
Slot 4 FW Revision:

# Description

Please include a summary of the change and which issue is fixed.

# Motivation

Please include an explanation of why you these changes are necessary

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce.

Reviewed By: wangx6f

Differential Revision: D54575650

fbshipit-source-id: 231838b4aa81d40df17914f28410c7b58bc1eaba
  • Loading branch information
ChrisWang-wiwynn authored and facebook-github-bot committed Mar 8, 2024
1 parent 6e34c31 commit c57fd02
Show file tree
Hide file tree
Showing 7 changed files with 555 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ require common/images/fb-openbmc-image.inc
IMAGE_INSTALL:append = " bios-fw-update"
IMAGE_INSTALL:append = " cpld-fw-handler"
IMAGE_INSTALL:append = " bic-update"
IMAGE_INSTALL:append = " pldm-package-re-wrapper"
IMAGE_INSTALL:append = " cxl-fw-update"
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ BIC_BOOT_STRAP_SPI_VAL="0x00"
BIC_BOOT_STRAP_REG="0x0C"

show_usage() {
echo "Usage: bic-updater.sh [sd|ff|wf] (--rcvy <slot_id> <uart image>) <pldm image>"
echo "Usage: bic-updater.sh [sd|ff|wf] (--rcvy <slot_id> <uart image>) (<slot_id>) <pldm image>"
echo " update all BICs : bic-updater.sh [sd|ff|wf] <pldm image>"
echo " update one BIC : bic-updater.sh [sd|ff|wf] <slot_id> <pldm image>"
echo " recovery one BIC : bic-updater.sh [sd|ff|wf] --rcvy <slot_id> <uart image> <pldm image>"
echo ""
}

Expand Down Expand Up @@ -102,9 +105,74 @@ update_bic() {
fi
}

update_all_slots() {
local is_recovery=$1
local user_specific_slot_id=$2

if [ "$is_recovery" == false ] && [ -z "$user_specific_slot_id" ]; then
# 0 = true
return 0
else
return 1
fi
}

update_single_slot() {
local slot_id=$1
local user_specific_slot_id=$2
local is_recovery=$3

if [ "$is_recovery" == false ] && [ "$slot_id" == "$user_specific_slot_id" ]; then
# 0 = true
return 0
else
return 1
fi
}

conduct_normal_update_and_updated_slot() {
local slot_id=$1
local user_specific_slot_id=$2
local is_recovery=$3

if update_single_slot "$slot_id" "$user_specific_slot_id" "$is_recovery" ; then
# 0 = true
return 0
elif update_all_slots "$is_recovery" "$user_specific_slot_id"; then
return 0
else
return 1
fi
}

conduct_recovery_and_not_recovered_slot() {
local slot_id=$1
local user_specific_slot_id=$2
local is_recovery=$3

if [ "$is_recovery" == true ] && [ "$slot_id" != "$user_specific_slot_id" ]; then
# 0 = true
return 0
else
return 1
fi
}

is_sd_bic() {
local slot_id=$1
local mctp_exp_id=$2

if [[ "$slot_id" -ge 1 && "$slot_id" -le 8 && "$mctp_exp_id" == "0" ]]; then
# 0 = true
return 0
else
return 1
fi
}

# Function to prompt for continuation and check user input
prompt_confirmation() {
echo "WARNING! This tool will automatically update all BICs."
echo "WARNING! This will automatically update all BICs."
read -r -p "Continue? [y/N] " continue
if [ "$continue" != "y" ]; then
echo "Aborting on user request."
Expand Down Expand Up @@ -134,13 +202,17 @@ if [ $# -eq 5 ] && [ "$2" == "--rcvy" ]; then
uart_image=$4
[ ! -f "$uart_image" ] && error_and_exit "UART"
pldm_image=$5
elif [ $# -eq 3 ] && [[ "$2" =~ ^[1-8]+$ ]]; then
slot_id=$2
pldm_image=$3
pldm-package-re-wrapper bic -s "$slot_id" -f "$pldm_image"
pldm_image="${pldm_image}_re_wrapped"
else
prompt_confirmation
fi

[ ! -f "$pldm_image" ] && error_and_exit "PLDM"

# Comfirmation with user
prompt_confirmation

# Execute recovery operations if in recovery mode, based on the value of bic_name
if [ "$is_rcvy" == true ]; then
# Workaround: Avoid pldm daemon blocked
Expand Down Expand Up @@ -189,9 +261,13 @@ if [ "$bic_name" == "wf" ] || [ "$bic_name" == "ff" ]; then
do
mctp_slot_id=$((EID/10));
mctp_exp_id=$((EID%10));
if [ "$mctp_slot_id" != "$slot_id" ] && [ "$mctp_slot_id" != "0" ] && [ "$mctp_exp_id" == "0" ]; then
echo "Slot $mctp_slot_id: Restart BIC"
pldmtool raw -m "$mctp_slot_id"0 -d 0x80 0x02 0x39 0x1 0x1 0x1 0x1 0x1

if is_sd_bic "$mctp_slot_id" "$mctp_exp_id"; then
if conduct_recovery_and_not_recovered_slot "$mctp_slot_id" "$slot_id" "$is_rcvy" ||
conduct_normal_update_and_updated_slot "$mctp_slot_id" "$slot_id" "$is_rcvy"; then
echo "Slot $mctp_slot_id: Restart BIC"
pldmtool raw -m "$mctp_slot_id"0 -d 0x80 0x02 0x39 0x1 0x1 0x1 0x1 0x1
fi
fi
done

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,17 @@ LOCAL_URI = " \
file://cci-mctp-update.cpp \
file://cci-mctp-update.hpp \
file://meson.build \
file://cxl-fw-update.sh \
"

DEPENDS += " \
cli11 \
sdbusplus \
"

RDEPENDS:${PN} = "bash"

do_install:append() {
install -d ${D}/${bindir}
install -m 0755 ${S}/cxl-fw-update.sh ${D}/${bindir}/
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/bin/bash

show_usage() {
echo "Usage: cxl-fw-update.sh <slot_id> (<instance_num>) <pldm image>"
echo " update CXL1 : cxl-fw-update.sh <slot_id> 1 <pldm image>"
echo " update CXL2 : cxl-fw-update.sh <slot_id> 2 <pldm image>"
echo ""
}

wait_for_update_complete() {
counter=0
while true
do
sleep 1
echo -ne "Waiting for updating... ${counter} sec"\\r
progress=$(busctl get-property xyz.openbmc_project.PLDM /xyz/openbmc_project/software/"$software_id" xyz.openbmc_project.Software.ActivationProgress Progress | cut -d " " -f 2)
if [ "${progress}" == 100 ]; then
echo -ne \\n"Update done."\\n
break
fi
counter=$((counter+1))
# Over two minutes is considered timeout
if [ "${counter}" == 600 ]; then
echo -ne \\n"Time out. Fail"\\n
break
fi
done
}

update_cxl() {

cp "$1" /tmp/images

sleep 1

software_id=$(busctl tree xyz.openbmc_project.PLDM |grep /xyz/openbmc_project/software/ | cut -d "/" -f 5)
echo "software_id = $software_id"

sleep 1

if [ "$software_id" != "" ]; then
busctl set-property xyz.openbmc_project.PLDM /xyz/openbmc_project/software/"$software_id" xyz.openbmc_project.Software.Activation RequestedActivation s "xyz.openbmc_project.Software.Activation.RequestedActivations.Active"
wait_for_update_complete
else
echo "Fail: Miss software id."
fi
}

prompt_confirmation() {
echo "WARNING! This will automatically update all all CXL on the blade."
read -r -p "Continue? [y/N] " continue
if [ "$continue" != "y" ]; then
echo "Aborting on user request."
exit 0
fi
}

error_and_exit() {
echo "Please provide valid PLDM image"
show_usage
exit 255
}

# Check for minimum required arguments
[ $# -lt 2 ] && error_and_exit

slot_id=$1
instance_num=$2
pldm_image=$3

if [ $# -eq 2 ]; then
pldm_image=$2
fi

[ ! -f "$pldm_image" ] && error_and_exit

# Check if instance_num is between 1 and 2
if [ $# -eq 3 ] && [[ "$instance_num" =~ ^[1-2]$ ]]; then
pldm-package-re-wrapper cxl -s "$slot_id" -i "$instance_num" -f "$pldm_image"
pldm_image="${pldm_image}_re_wrapped"
else
echo "Instance number must between 1 and 2."
exit 255
fi

update_cxl "$pldm_image"

echo "Update done. If there was no error appeared, please conduct DC cycle to load the new firmware."
Loading

0 comments on commit c57fd02

Please sign in to comment.