Skip to content

Commit

Permalink
meta-ampere: flash: Update method to turn on the host
Browse files Browse the repository at this point in the history
While BMC is in firmware updating phase, the BMC's state is
UpdateInProgress, BMC rejects all turn on host requests during this time
if users enabled "only-allow-boot-when-bmc-ready" option build.

This commit updates the method to turn on the host after flashing done.
When flashing done, BMC does not directly request to turn on the host,
it request to start [email protected] instead. This
service shall check BMC's state then request to turn on the host. B/c
this service's "Type" is simple, it does not block firmware updating
action.

Tested:
    1. Turn on the Host then request to flashing new firmware.
    2. Wait until flashing done, check the Host's state.
       $busctl get-property xyz.openbmc_project.State.Host0
               /xyz/openbmc_project/state/host0 \
               xyz.openbmc_project.State.Host CurrentHostState
    3. The Host's state is "Running"

Signed-off-by: Thang Tran <[email protected]>
  • Loading branch information
thangtran-ampere authored and thangqn-ampere committed Oct 15, 2024
1 parent 9fa1792 commit 5d24c0f
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[Unit]
Description=Ampere service to turn on the host after flashing

[Service]
Type=simple
ExecStart=/usr/sbin/turn_on_host_after_flash.sh %i
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

# This script is used to turn on the Host after flashing.
# It has to wait for BMC's state enter to "Ready" status
# due to current BMC's state is "UpdateInProgress", therefore
# we can not request to turn on the Host immediately.

time_out=30

if [ "$#" -gt 0 ]
then
time_out=$1
fi

for i in $(seq 1 "$time_out")
do
bmc_state=$(busctl get-property xyz.openbmc_project.State.BMC \
/xyz/openbmc_project/state/bmc0 xyz.openbmc_project.State.BMC \
CurrentBMCState | cut -d " " -f 2)

if [[ "${bmc_state}" == *".Ready"* ]]
then
temp_val=$(busctl set-property xyz.openbmc_project.State.Host0 \
/xyz/openbmc_project/state/host0 xyz.openbmc_project.State.Host \
RequestedHostTransition s xyz.openbmc_project.State.Host.Transition.On)
break
fi

sleep 1s
done

exit
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,31 @@ FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"

SRC_URI += " \
file://firmware_update.sh \
file://turn_on_host_after_flash.sh \
file://allow-reboot-actions.service \
file://prevent-reboot-actions.service \
file://[email protected] \
file://0001-BMC-Updater-Support-update-on-BMC-Alternate-device.patch \
"

PACKAGECONFIG:append = " flash_bios static-dual-image"

SYSTEMD_SERVICE:${PN}:updater += "${@bb.utils.contains('PACKAGECONFIG', 'flash_bios', 'allow-reboot-actions.service', '', d)}"
SYSTEMD_SERVICE:${PN}:updater += "${@bb.utils.contains('PACKAGECONFIG', 'flash_bios', 'prevent-reboot-actions.service', '', d)}"
SYSTEMD_SERVICE:${PN}:updater += "${@bb.utils.contains('PACKAGECONFIG', 'flash_bios', '[email protected]', '', d)}"

FILES:${PN} += "${@bb.utils.contains('PACKAGECONFIG', 'flash_bios', '${systemd_unitdir}/system/allow-reboot-actions.service', '', d)}"
FILES:${PN} += "${@bb.utils.contains('PACKAGECONFIG', 'flash_bios', '${systemd_unitdir}/system/prevent-reboot-actions.service', '', d)}"
FILES:${PN} += "${@bb.utils.contains('PACKAGECONFIG', 'flash_bios', '${systemd_unitdir}/system/[email protected]', '', d)}"

RDEPENDS:${PN} += "bash"

do_install:append() {
install -d ${D}/usr/sbin
install -m 0755 ${WORKDIR}/firmware_update.sh ${D}/usr/sbin/firmware_update.sh
install -m 0755 ${WORKDIR}/turn_on_host_after_flash.sh ${D}/usr/sbin/turn_on_host_after_flash.sh

install -m 0644 ${WORKDIR}/allow-reboot-actions.service ${D}${systemd_unitdir}/system/allow-reboot-actions.service
install -m 0644 ${WORKDIR}/prevent-reboot-actions.service ${D}${systemd_unitdir}/system/prevent-reboot-actions.service
install -m 0644 ${WORKDIR}/turn-on-the-host-after-flash@.service ${D}${systemd_unitdir}/system/turn-on-the-host-after-flash@.service
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ do_smpmpro_upgrade() {
then
sleep 5
echo "Turn on the Host"
obmcutil poweron
systemctl start turn-on-the-host-after-flash@60
fi

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# limitations under the License.
# shellcheck disable=SC2046



do_flash () {
# Check the PNOR partition available
HOST_MTD=$(< /proc/mtd grep "pnor-uefi" | sed -n 's/^\(.*\):.*/\1/p')
Expand Down Expand Up @@ -126,5 +128,5 @@ if [ "$chassisstate" == 'On' ];
then
sleep 5
echo "Turn on the Host"
obmcutil poweron
systemctl start turn-on-the-host-after-flash@60
fi
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ do_eeprom_flash() {
then
sleep 5
echo "Turn on the Host"
obmcutil poweron
systemctl start turn-on-the-host-after-flash@60
fi
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,6 @@ if [ "$chassisstate" == 'On' ];
then
sleep 5
echo "Turn on the Host"
obmcutil poweron
systemctl start turn-on-the-host-after-flash@60
fi

Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ do_eeprom_flash() {
then
sleep 5
echo "Turn on the Host"
obmcutil poweron
systemctl start turn-on-the-host-after-flash@60
fi
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ if [ "$chassisstate" == 'On' ] || [ $SPECIAL_BOOT == 1 ];
then
sleep 5
echo "Turn on the Host"
obmcutil poweron
systemctl start turn-on-the-host-after-flash@60
fi

# Detection SECProv of failure or success
Expand Down

0 comments on commit 5d24c0f

Please sign in to comment.