diff options
Diffstat (limited to 'meta-ampere')
41 files changed, 730 insertions, 281 deletions
diff --git a/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl.bb b/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl.bb index e7c3cc160..5c4b6a012 100644 --- a/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl.bb +++ b/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl.bb @@ -7,79 +7,29 @@ LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7ca inherit systemd inherit obmc-phosphor-systemd -# For now, monitoring shutdown_ack and reboot_ack are the only usecases -OBMC_HOST_MONITOR_INSTANCES = "shutdown_ack reboot_ack" -SYSTEMD_ENVIRONMENT_FILE_${PN} +="obmc/gpio/shutdown_ack obmc/gpio/reboot_ack" - S = "${WORKDIR}" -SRC_URI = "file://ampere-host-shutdown.service \ - file://ampere-host-reset.service \ - file://ampere_power_util.sh \ - file://ampere-chassis-poweroff.service \ - file://ampere-chassis-poweron.service \ - file://ampere-host-reset-ack.service \ - file://ampere-host-force-reset.service \ - file://ampere-host-power-cycle.service \ +SRC_URI = " \ + file://ampere-host-force-reset@.service \ + file://ampere-host-on-host-check@.service \ " -DEPENDS = "systemd virtual/obmc-gpio-monitor" -RDEPENDS_${PN} = "bash virtual/obmc-gpio-monitor" - SYSTEMD_PACKAGES = "${PN}" SYSTEMD_SERVICE_${PN} = " \ - ampere-host-shutdown.service \ - ampere-host-reset.service \ - ampere-chassis-poweroff.service \ - ampere-chassis-poweron.service \ - ampere-host-reset-ack.service \ - ampere-host-force-reset.service \ - ampere-host-power-cycle.service \ + ampere-host-force-reset@.service \ " -# host power control -# overwrite the host shutdown to graceful shutdown -HOST_SHUTDOWN_TMPL = "ampere-host-shutdown.service" -HOST_SHUTDOWN_TGTFMT = "obmc-host-shutdown@{0}.target" -HOST_SHUTDOWN_FMT = "../${HOST_SHUTDOWN_TMPL}:${HOST_SHUTDOWN_TGTFMT}.requires/${HOST_SHUTDOWN_TMPL}" -SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'HOST_SHUTDOWN_FMT', 'OBMC_HOST_INSTANCES')}" - -# Force the power cycle target to run the ampere power cycle -HOST_REBOOT_SVC = "ampere-host-power-cycle.service" -HOST_REBOOT_SVC_TGTFMT = "obmc-host-reboot@{0}.target" -HOST_REBOOT_SVC_FMT = "../${HOST_REBOOT_SVC}:${HOST_REBOOT_SVC_TGTFMT}.requires/${HOST_REBOOT_SVC}" -SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'HOST_REBOOT_SVC_FMT', 'OBMC_HOST_INSTANCES')}" -# overwrite the host reset to graceful reset -HOST_WARM_REBOOT_SOFT_SVC = "ampere-host-reset.service" -HOST_WARM_REBOOT_TGTFMT = "obmc-host-warm-reboot@{0}.target" -HOST_WARM_REBOOT_SOFT_SVC_FMT = "../${HOST_WARM_REBOOT_SOFT_SVC}:${HOST_WARM_REBOOT_TGTFMT}.requires/${HOST_WARM_REBOOT_SOFT_SVC}" -SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'HOST_WARM_REBOOT_SOFT_SVC_FMT', 'OBMC_HOST_INSTANCES')}" - -# overwrite force reboot -HOST_WARM_REBOOT_FORCE_TGT = "ampere-host-force-reset.service" +# append force reboot +HOST_WARM_REBOOT_FORCE_TGT = "ampere-host-force-reset@.service" +HOST_WARM_REBOOT_FORCE_INSTMPL = "ampere-host-force-reset@{0}.service" HOST_WARM_REBOOT_FORCE_TGTFMT = "obmc-host-force-warm-reboot@{0}.target" -HOST_WARM_REBOOT_FORCE_TARGET_FMT = "../${HOST_WARM_REBOOT_FORCE_TGT}:${HOST_WARM_REBOOT_FORCE_TGTFMT}.requires/${HOST_WARM_REBOOT_FORCE_TGT}" +HOST_WARM_REBOOT_FORCE_TARGET_FMT = "../${HOST_WARM_REBOOT_FORCE_TGT}:${HOST_WARM_REBOOT_FORCE_TGTFMT}.requires/${HOST_WARM_REBOOT_FORCE_INSTMPL}" SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'HOST_WARM_REBOOT_FORCE_TARGET_FMT', 'OBMC_HOST_INSTANCES')}" - -# chassis power control -CHASSIS_POWERON_SVC = "ampere-chassis-poweron.service" -CHASSIS_POWERON_TGTFMT = "obmc-chassis-poweron@{0}.target" -CHASSIS_POWERON_FMT = "../${CHASSIS_POWERON_SVC}:${CHASSIS_POWERON_TGTFMT}.requires/${CHASSIS_POWERON_SVC}" -SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'CHASSIS_POWERON_FMT', 'OBMC_CHASSIS_INSTANCES')}" - -CHASSIS_POWEROFF_SVC = "ampere-chassis-poweroff.service" -CHASSIS_POWEROFF_TGTFMT = "obmc-chassis-poweroff@{0}.target" -CHASSIS_POWEROFF_FMT = "../${CHASSIS_POWEROFF_SVC}:${CHASSIS_POWEROFF_TGTFMT}.requires/${CHASSIS_POWEROFF_SVC}" -SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'CHASSIS_POWEROFF_FMT', 'OBMC_CHASSIS_INSTANCES')}" - -TMPL = "phosphor-gpio-monitor@.service" -INSTFMT = "phosphor-gpio-monitor@{0}.service" -TGT = "multi-user.target" -FMT = "../${TMPL}:${TGT}.requires/${INSTFMT}" -SYSTEMD_LINK_${PN} += "${@compose_list(d, 'FMT', 'OBMC_HOST_MONITOR_INSTANCES')}" - -do_install() { - install -d ${D}/usr/sbin - install -m 0755 ${WORKDIR}/ampere_power_util.sh ${D}/${sbindir}/ampere_power_util.sh -} - +SYSTEMD_SERVICE_${PN} += "${HOST_WARM_REBOOT_FORCE_TGT}" + +HOST_ON_RESET_HOSTTMPL = "ampere-host-on-host-check@.service" +HOST_ON_RESET_HOSTINSTMPL = "ampere-host-on-host-check@{0}.service" +HOST_ON_RESET_HOSTTGTFMT = "obmc-host-startmin@{0}.target" +HOST_ON_RESET_HOSTFMT = "../${HOST_ON_RESET_HOSTTMPL}:${HOST_ON_RESET_HOSTTGTFMT}.requires/${HOST_ON_RESET_HOSTINSTMPL}" +SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'HOST_ON_RESET_HOSTFMT', 'OBMC_HOST_INSTANCES')}" +SYSTEMD_SERVICE_${PN} += "${HOST_ON_RESET_HOSTTMPL}" diff --git a/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-chassis-poweroff.service b/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-chassis-poweroff.service deleted file mode 100644 index b0a1af785..000000000 --- a/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-chassis-poweroff.service +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=Ampere Computing LLC Power OFF Chassis -Requires=op-wait-power-off@%i.service -Before=op-wait-power-off@%i.service -Conflicts=obmc-chassis-poweron@0.target - -[Service] -RemainAfterExit=no -Type=oneshot -ExecStart=/usr/bin/env ampere_power_util.sh mb off -SyslogIdentifier=ampere_power_util.sh diff --git a/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-chassis-poweron.service b/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-chassis-poweron.service deleted file mode 100644 index 76ceb8856..000000000 --- a/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-chassis-poweron.service +++ /dev/null @@ -1,9 +0,0 @@ -[Unit] -Description=Ampere Computing LLC Power ON Chassis -Conflicts=obmc-chassis-poweroff@0.target - -[Service] -RemainAfterExit=yes -Type=oneshot -ExecStart=/usr/bin/env ampere_power_util.sh mb on -SyslogIdentifier=ampere_power_util.sh diff --git a/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-force-reset.service b/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-force-reset.service deleted file mode 100644 index 8a40baf7b..000000000 --- a/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-force-reset.service +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=Ampere Computing LLC force reset host -Conflicts=obmc-chassis-poweroff@0.target -OnFailure=obmc-chassis-powerreset@0.target - -[Service] -RemainAfterExit=no -Type=oneshot -ExecStart=/usr/bin/env ampere_power_util.sh mb force_reset -SyslogIdentifier=ampere_power_util.sh - diff --git a/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-force-reset@.service b/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-force-reset@.service new file mode 100644 index 000000000..6e03c8b81 --- /dev/null +++ b/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-force-reset@.service @@ -0,0 +1,14 @@ +[Unit] +Description=Ampere Computing LLC force reset host%i +Wants=phosphor-reboot-host@%i.service +Conflicts=obmc-chassis-poweroff@%i.target +OnFailure=obmc-chassis-powerreset@%i.target + +[Service] +RemainAfterExit=no +Type=oneshot +ExecStart=/bin/sh -c "sleep 3 && /usr/bin/env ampere_power_util.sh mb force_reset" +SyslogIdentifier=ampere_power_util.sh + +[Install] +WantedBy=obmc-host-force-warm-reboot@%i.target
\ No newline at end of file diff --git a/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-on-host-check@.service b/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-on-host-check@.service new file mode 100644 index 000000000..36e5a642c --- /dev/null +++ b/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-on-host-check@.service @@ -0,0 +1,13 @@ +[Unit] +Description=Check Host%i status before obmc-host-startmin +Wants=obmc-host-started@%i.target +After=obmc-host-started@%i.target +Conflicts=obmc-host-stop@%i.target +Conflicts=phosphor-reset-host-check@%i.service +OnFailure=obmc-host-quiesce@%i.target +OnFailureJobMode=flush +ConditionPathExists=!/run/openbmc/host@%i-on + +[Service] +Type=oneshot +ExecStart=/usr/sbin/ampere_host_check.sh 1 0 diff --git a/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-power-cycle.service b/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-power-cycle.service deleted file mode 100644 index 2fb03effb..000000000 --- a/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-power-cycle.service +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=Ampere Computing LLC power cycle service -Conflicts=obmc-host-start@0.target -OnFailure=obmc-chassis-powerreset@0.target - -[Service] -RemainAfterExit=no -Type=oneshot -ExecStart=/usr/bin/env ampere_power_util.sh mb cycle -SyslogIdentifier=ampere_power_util.sh diff --git a/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-reset-ack.service b/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-reset-ack.service deleted file mode 100644 index 504186ec6..000000000 --- a/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-reset-ack.service +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=Ampere Computing LLC triggering reset ACK -Conflicts=obmc-host-start@0.target -OnFailure=obmc-chassis-powerreset@0.target - -[Service] -RemainAfterExit=no -Type=oneshot -ExecStart=/usr/bin/env ampere_power_util.sh mb force_reset -SyslogIdentifier=ampere_power_util.sh diff --git a/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-reset.service b/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-reset.service deleted file mode 100644 index ac7618ad0..000000000 --- a/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-reset.service +++ /dev/null @@ -1,9 +0,0 @@ -[Unit] -Description=Ampere Computing LLC warm reset host -Conflicts=obmc-chassis-poweroff@0.target - -[Service] -RemainAfterExit=no -Type=oneshot -ExecStart=/usr/bin/env ampere_power_util.sh mb graceful_reset -SyslogIdentifier=ampere_power_util.sh diff --git a/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-shutdown.service b/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-shutdown.service deleted file mode 100644 index be4d45260..000000000 --- a/meta-ampere/meta-common/recipes-ac01/host/ampere-hostctrl/ampere-host-shutdown.service +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=Ampere Computing LLC graceful shutdown host -Conflicts=obmc-host-start@0.target -OnFailure=obmc-chassis-poweroff@0.target - -[Service] -RemainAfterExit=no -Type=oneshot -ExecStart=/usr/bin/env ampere_power_util.sh mb graceful_shutdown -SyslogIdentifier=ampere_power_util.sh diff --git a/meta-ampere/meta-common/recipes-ac01/host/files/ampere_power_util.sh b/meta-ampere/meta-common/recipes-ac01/host/files/ampere_power_util.sh deleted file mode 100644 index 8bab9a370..000000000 --- a/meta-ampere/meta-common/recipes-ac01/host/files/ampere_power_util.sh +++ /dev/null @@ -1,109 +0,0 @@ -#!/bin/bash -# Usage of this utility -function usage() { - echo "usage: power-util mb [on|off|status|cycle|reset|graceful_shutdown|graceful_reset|force_reset]"; -} - -power_off() { - echo "Shutting down Server $2" - busctl set-property xyz.openbmc_project.State.Chassis /xyz/openbmc_project/state/chassis0 xyz.openbmc_project.State.Chassis RequestedPowerTransition s xyz.openbmc_project.State.Chassis.Transition.Off -} - -power_on() { - echo "Powering on Server $2" - busctl set-property xyz.openbmc_project.State.Chassis /xyz/openbmc_project/state/chassis0 xyz.openbmc_project.State.Chassis RequestedPowerTransition s xyz.openbmc_project.State.Chassis.Transition.On -} - -power_status() { - st=$(busctl get-property xyz.openbmc_project.State.Chassis /xyz/openbmc_project/state/chassis0 xyz.openbmc_project.State.Chassis CurrentPowerState | cut -d"." -f6) - if [ "$st" == "On\"" ]; then - echo "on" - else - echo "off" - fi -} - -power_reset() { - echo "Reset on server $2" - busctl set-property xyz.openbmc_project.State.Host /xyz/openbmc_project/state/host0 xyz.openbmc_project.State.Host RequestedHostTransition s xyz.openbmc_project.State.Host.Transition.Reboot -} - -graceful_shutdown() { - if [ -f "/run/openbmc/host@0-request" ]; then - echo "shutdown host immediately" - power_off - else - echo "Triggering graceful shutdown" - gpioset -l 0 49=1 - sleep 1 - gpioset -l 0 49=0 - sleep 30s - fi -} - -force_reset() { - echo "Triggering sysreset pin" - gpioset -l 0 91=1 - sleep 1 - gpioset -l 0 91=0 -} - -if [ $# -lt 2 ]; then - echo "Total number of parameter=$#" - echo "Insufficient parameter" - usage; - exit 0; -fi - -if [ $1 != "mb" ]; then - echo "Invalid parameter1=$1" - usage; - exit 0; -fi - -if [ $2 = "on" ]; then - if [ $(power_status) == "off" ]; then - power_on - fi -elif [ $2 = "off" ]; then - if [ $(power_status) == "on" ]; then - power_off - fi - # If any request of graceful reset, need to power on - if [ -f "/run/openbmc/host@0-graceful-reset" ]; then - sleep 20s - power_on - rm -f "/run/openbmc/host@0-graceful-reset" - fi -elif [ $2 == "cycle" ]; then - if [ $(power_status) == "on" ]; then - echo "Powering off server" - power_off - sleep 20s - power_on - else - echo "Host is already off, do nothing" - fi -elif [ $2 == "reset" ]; then - if [ $(power_status) == "on" ]; then - power_reset - else - echo "ERROR: Server not powered on" - fi -elif [[ $2 == "graceful_shutdown" ]]; then - graceful_shutdown -elif [ $2 == "graceful_reset" ]; then - mkdir -p "/run/openbmc/" - touch "/run/openbmc/host@0-graceful-reset" - graceful_shutdown - sleep 20s -elif [ $2 == "status" ]; then - power_status -elif [ $2 == "force_reset" ]; then - force_reset -else - echo "Invalid parameter2=$2" - usage; -fi - -exit 0; diff --git a/meta-ampere/meta-common/recipes-devtools/mtd/mtd-utils/0001-flashcp-support-offset-option.patch b/meta-ampere/meta-common/recipes-devtools/mtd/mtd-utils/0001-flashcp-support-offset-option.patch new file mode 100644 index 000000000..174a1cd6d --- /dev/null +++ b/meta-ampere/meta-common/recipes-devtools/mtd/mtd-utils/0001-flashcp-support-offset-option.patch @@ -0,0 +1,143 @@ +From e29268bb252b4eec5830816912817a2650b04ee9 Mon Sep 17 00:00:00 2001 +From: Tung Nguyen <tung.nguyen@amperecomputing.com> +Date: Tue, 20 Jul 2021 15:32:32 +0700 +Subject: [PATCH] flashcp support offset option + +The flashcp command from mtd-utils just support to flash from offset 0. +Add offset option to specify the start offset so that firmware can be +flashed correctly + +Signed-off-by: Tung Nguyen <tung.nguyen@amperecomputing.com> + +%% original patch: 0001-support-flash-offset.patch +--- + misc-utils/flashcp.c | 50 +++++++++++++++++++++++++++++++++++++++++--- + 1 file changed, 47 insertions(+), 3 deletions(-) + +diff --git a/misc-utils/flashcp.c b/misc-utils/flashcp.c +index d7b0a59..d1ef79c 100644 +--- a/misc-utils/flashcp.c ++++ b/misc-utils/flashcp.c +@@ -90,7 +90,7 @@ static NORETURN void showusage(bool error) + "\n" + "Flash Copy - Written by Abraham van der Merwe <abraham@2d3d.co.za>\n" + "\n" +- "usage: %1$s [ -v | --verbose | -A | --erase-all ] <filename> <device>\n" ++ "usage: %1$s [ -v | --verbose | -A | --erase-all ] <filename> <device> <offset>\n" + " %1$s -h | --help\n" + " %1$s -V | --version\n" + "\n" +@@ -100,6 +100,7 @@ static NORETURN void showusage(bool error) + " -V | --version Show version information and exit\n" + " <filename> File which you want to copy to flash\n" + " <device> Flash device to write to (e.g. /dev/mtd0, /dev/mtd1, etc.)\n" ++ " <offset> The start offset. Optional, default: 0\n" + "\n", + PROGRAM_NAME); + +@@ -154,6 +155,16 @@ static void safe_rewind (int fd,const char *filename) + } + } + ++static int safe_rewind_offset(int fd, const char *filename, off_t offset) ++{ ++ if (lseek(fd, offset, SEEK_SET) < 0) { ++ log_printf(LOG_ERROR, "While seeking to start of %s: %m\n", filename); ++ return EXIT_FAILURE; ++ } ++ ++ return EXIT_SUCCESS; ++} ++ + /******************************************************************************/ + + static int dev_fd = -1,fil_fd = -1; +@@ -167,6 +178,8 @@ static void cleanup (void) + int main (int argc,char *argv[]) + { + const char *filename = NULL,*device = NULL; ++ off_t offset; ++ + int i,flags = FLAG_NONE; + ssize_t result; + size_t size,written; +@@ -218,6 +231,20 @@ int main (int argc,char *argv[]) + showusage(true); + } + } ++ ++ if (optind + 3 == argc) { ++ flags |= FLAG_FILENAME; ++ filename = argv[optind]; ++ DEBUG("Got filename: %s\n", filename); ++ ++ flags |= FLAG_DEVICE; ++ device = argv[optind + 1]; ++ DEBUG("Got device: %s\n", device); ++ ++ offset = strtoul(argv[optind + 2], NULL, 16); ++ DEBUG("Got offset: 0x%x\n", offset); ++ } ++ + if (optind+2 == argc) { + flags |= FLAG_FILENAME; + filename = argv[optind]; +@@ -226,6 +253,8 @@ int main (int argc,char *argv[]) + flags |= FLAG_DEVICE; + device = argv[optind+1]; + DEBUG("Got device: %s\n",device); ++ ++ offset = 0; + } + + if (flags & FLAG_HELP || device == NULL) +@@ -257,6 +286,12 @@ int main (int argc,char *argv[]) + exit (EXIT_FAILURE); + } + ++ /* does offset is out of the mtd */ ++ if (offset > mtd.size) { ++ log_printf(LOG_ERROR, "%s offset won't fit into %s!\n", offset, device); ++ exit(EXIT_FAILURE); ++ } ++ + /***************************************************** + * erase enough blocks so that we can write the file * + *****************************************************/ +@@ -271,6 +306,8 @@ int main (int argc,char *argv[]) + } + else + { ++ /* Erase from the offset */ ++ erase.start = offset; + erase.length = (filestat.st_size + mtd.erasesize - 1) / mtd.erasesize; + erase.length *= mtd.erasesize; + } +@@ -317,6 +354,12 @@ int main (int argc,char *argv[]) + size = filestat.st_size; + i = BUFSIZE; + written = 0; ++ ++ /* if offset is greater than 0 */ ++ if (offset) ++ if (safe_rewind_offset(dev_fd, device, offset) != EXIT_SUCCESS) ++ return EXIT_FAILURE; ++ + while (size) + { + if (size < BUFSIZE) i = size; +@@ -361,8 +404,9 @@ int main (int argc,char *argv[]) + * verify that flash == file data * + **********************************/ + +- safe_rewind (fil_fd,filename); +- safe_rewind (dev_fd,device); ++ safe_rewind(fil_fd, filename); ++ safe_rewind_offset(dev_fd, device, offset); ++ + size = filestat.st_size; + i = BUFSIZE; + written = 0; +-- +2.17.1 + diff --git a/meta-ampere/meta-common/recipes-devtools/mtd/mtd-utils_%.bbappend b/meta-ampere/meta-common/recipes-devtools/mtd/mtd-utils_%.bbappend new file mode 100644 index 000000000..08aa3ce69 --- /dev/null +++ b/meta-ampere/meta-common/recipes-devtools/mtd/mtd-utils_%.bbappend @@ -0,0 +1,3 @@ +FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" + +SRC_URI += "file://0001-flashcp-support-offset-option.patch " diff --git a/meta-ampere/meta-common/recipes-phosphor/network/phosphor-network_%.bbappend b/meta-ampere/meta-common/recipes-phosphor/network/phosphor-network_%.bbappend new file mode 100644 index 000000000..b2883fcaf --- /dev/null +++ b/meta-ampere/meta-common/recipes-phosphor/network/phosphor-network_%.bbappend @@ -0,0 +1 @@ +PACKAGECONFIG_append = " nic-ethtool" diff --git a/meta-ampere/meta-common/recipes-phosphor/sel-logger/phosphor-sel-logger_%.bbappend b/meta-ampere/meta-common/recipes-phosphor/sel-logger/phosphor-sel-logger_%.bbappend index 4be8ddbd5..2f74fd2c3 100644 --- a/meta-ampere/meta-common/recipes-phosphor/sel-logger/phosphor-sel-logger_%.bbappend +++ b/meta-ampere/meta-common/recipes-phosphor/sel-logger/phosphor-sel-logger_%.bbappend @@ -1,2 +1 @@ -# Enable threshold monitoring -EXTRA_OECMAKE += "-DSEL_LOGGER_MONITOR_THRESHOLD_EVENTS=ON" +PACKAGECONFIG_append = " log-threshold" diff --git a/meta-ampere/meta-common/recipes-phosphor/state/phosphor-state-manager/ampere-reset-host-check@.service b/meta-ampere/meta-common/recipes-phosphor/state/phosphor-state-manager/ampere-reset-host-check@.service new file mode 100644 index 000000000..83f6581be --- /dev/null +++ b/meta-ampere/meta-common/recipes-phosphor/state/phosphor-state-manager/ampere-reset-host-check@.service @@ -0,0 +1,18 @@ +[Unit] +Description=Check Host%i status on BMC reset +Wants=phosphor-ipmi-host.service +After=phosphor-ipmi-host.service +Wants=obmc-host-reset-running@%i.target +Before=obmc-host-reset-running@%i.target +Wants=op-reset-chassis-on@%i.service +After=op-reset-chassis-on@%i.service +Conflicts=obmc-host-stop@%i.target +ConditionPathExists=/run/openbmc/chassis@%i-on + +[Service] +RemainAfterExit=yes +Type=oneshot +ExecStart=/usr/sbin/ampere_host_check.sh 1 0 + +[Install] +WantedBy=obmc-host-reset@%i.target
\ No newline at end of file diff --git a/meta-ampere/meta-common/recipes-phosphor/state/phosphor-state-manager_%.bbappend b/meta-ampere/meta-common/recipes-phosphor/state/phosphor-state-manager_%.bbappend index d54407ba3..bdb89ce63 100644 --- a/meta-ampere/meta-common/recipes-phosphor/state/phosphor-state-manager_%.bbappend +++ b/meta-ampere/meta-common/recipes-phosphor/state/phosphor-state-manager_%.bbappend @@ -4,21 +4,10 @@ DEPS_CFG = "resetreason.conf" DEPS_TGT = "phosphor-discover-system-state@.service" SYSTEMD_OVERRIDE_${PN}-discover_append = "${DEPS_CFG}:${DEPS_TGT}.d/${DEPS_CFG}" -# We don't want the obmc-host-shutdown (softoff) to require -# obmc-chassis-poweroff. obmc-chassis-poweroff will be activated once -# the Shutdown ACK pin is toggled (monitored by phosphor-gpio-monitor) -HOST_STOP_FMT = "" -HOST_REBOOT_FMT = "" +SRC_URI += " \ + file://ampere-reset-host-check@.service \ + " -pkg_postinst_${PN}-obmc-targets_append() { - rm "$D$systemd_system_unitdir/obmc-host-shutdown@0.target.requires/obmc-chassis-poweroff@0.target" - - rm "$D$systemd_system_unitdir/obmc-host-warm-reboot@0.target.requires/xyz.openbmc_project.Ipmi.Internal.SoftPowerOff.service" - rm "$D$systemd_system_unitdir/obmc-host-warm-reboot@0.target.requires/obmc-host-force-warm-reboot@0.target" - - rm "$D$systemd_system_unitdir/obmc-host-reboot@0.target.requires/phosphor-reboot-host@0.service" - rm "$D$systemd_system_unitdir/obmc-host-reboot@0.target.requires/obmc-host-shutdown@0.target" - - rm "$D$systemd_system_unitdir/obmc-host-force-warm-reboot@0.target.requires/obmc-host-stop@0.target" - rm "$D$systemd_system_unitdir/obmc-host-force-warm-reboot@0.target.requires/phosphor-reboot-host@0.service" -} +do_install_append() { + install -m 0644 ${WORKDIR}/ampere-reset-host-check@.service ${D}${systemd_unitdir}/system/phosphor-reset-host-check@.service +}
\ No newline at end of file diff --git a/meta-ampere/meta-jade/conf/machine/mtjade.conf b/meta-ampere/meta-jade/conf/machine/mtjade.conf index 171a023f4..43a1059dd 100644 --- a/meta-ampere/meta-jade/conf/machine/mtjade.conf +++ b/meta-ampere/meta-jade/conf/machine/mtjade.conf @@ -25,9 +25,12 @@ OBMC_MACHINE_FEATURES += "\ VOLATILE_LOG_DIR = "no" OBMC_IMAGE_EXTRA_INSTALL_append = "\ + mtjade-utils \ ampere-usbnet \ ampere-flash-utils \ ampere-mac-update \ + mtjade-gpio-config \ + mtd-utils \ " PREFERRED_PROVIDER_virtual/obmc-chassis-mgmt = "packagegroup-ampere-apps" diff --git a/meta-ampere/meta-jade/recipes-ampere/flash/ampere-flash-utils/ampere_flash_bios.sh b/meta-ampere/meta-jade/recipes-ampere/flash/ampere-flash-utils/ampere_flash_bios.sh index 876671c1b..7a9ace30e 100755 --- a/meta-ampere/meta-jade/recipes-ampere/flash/ampere-flash-utils/ampere_flash_bios.sh +++ b/meta-ampere/meta-jade/recipes-ampere/flash/ampere-flash-utils/ampere_flash_bios.sh @@ -15,6 +15,8 @@ # limitations under the License. do_flash () { + OFFSET=$1 + # Check the PNOR partition available HOST_MTD=$(cat /proc/mtd | grep "pnor" | sed -n 's/^\(.*\):.*/\1/p') if [ -z "$HOST_MTD" ]; @@ -30,18 +32,10 @@ do_flash () { echo "Fail to probe Host SPI-NOR device" exit 1 fi - - echo "--- Flashing firmware to @/dev/$HOST_MTD" - flash_eraseall /dev/$HOST_MTD - flashcp -v $IMAGE /dev/$HOST_MTD - - echo "--- Unbind the ASpeed SMC driver" - echo 1e630000.spi > /sys/bus/platform/drivers/aspeed-smc/unbind - else - echo "--- Flashing firmware to @/dev/$HOST_MTD" - flash_eraseall /dev/$HOST_MTD - flashcp -v $IMAGE /dev/$HOST_MTD fi + + echo "--- Flashing firmware to @/dev/$HOST_MTD offset=$OFFSET" + flashcp -v $IMAGE /dev/$HOST_MTD $OFFSET } @@ -84,7 +78,7 @@ if [[ $? -ne 0 ]]; then fi # Flash the firmware -do_flash +do_flash 0x400000 # Switch the host SPI bus to HOST." echo "--- Switch the host SPI bus to HOST." @@ -99,5 +93,5 @@ if [ "$chassisstate" == 'On' ]; then sleep 5 echo "Turn on the Host" - obmcutil chassison + obmcutil poweron fi diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config.bb b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config.bb new file mode 100644 index 000000000..69fedd67a --- /dev/null +++ b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config.bb @@ -0,0 +1,44 @@ +SUMMARY = "Ampere Computing LLC Utilities" +DESCRIPTION = "Ampere Utilities for Mt.Jade systems" +PR = "r1" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" + +inherit systemd +inherit obmc-phosphor-systemd + +S = "${WORKDIR}" + +SRC_URI = " \ + file://ampere_gpio_utils.sh \ + " + +DEPENDS = "systemd" +RDEPENDS_${PN} = "bash" + +SYSTEMD_PACKAGES = "${PN}" + +SYSTEMD_SERVICE_${PN} = " \ + ampere-gpio-poweroff@.service \ + ampere-gpio-poweron@.service \ + " + +# chassis power on +CHASSIS_POWERON_SVC = "ampere-gpio-poweron@.service" +CHASSIS_POWERON_INSTMPL = "ampere-gpio-poweron@{0}.service" +CHASSIS_POWERON_TGTFMT = "obmc-chassis-poweron@{0}.target" +CHASSIS_POWERON_FMT = "../${CHASSIS_POWERON_SVC}:${CHASSIS_POWERON_TGTFMT}.requires/${CHASSIS_POWERON_INSTMPL}" +SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'CHASSIS_POWERON_FMT', 'OBMC_CHASSIS_INSTANCES')}" + +# chassis power off +CHASSIS_POWEROFF_SVC = "ampere-gpio-poweroff@.service" +CHASSIS_POWEROFF_INSTMPL = "ampere-gpio-poweroff@{0}.service" +CHASSIS_POWEROFF_TGTFMT = "obmc-chassis-poweroff@{0}.target" +CHASSIS_POWEROFF_FMT = "../${CHASSIS_POWEROFF_SVC}:${CHASSIS_POWEROFF_TGTFMT}.requires/${CHASSIS_POWEROFF_INSTMPL}" +SYSTEMD_LINK_${PN} += "${@compose_list_zip(d, 'CHASSIS_POWEROFF_FMT', 'OBMC_CHASSIS_INSTANCES')}" + +do_install() { + install -d ${D}/usr/sbin + install -m 0755 ${WORKDIR}/ampere_gpio_utils.sh ${D}/${sbindir}/ +} + diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config/ampere-gpio-poweroff@.service b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config/ampere-gpio-poweroff@.service new file mode 100644 index 000000000..78862eb32 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config/ampere-gpio-poweroff@.service @@ -0,0 +1,10 @@ +[Unit] +Description=Ampere set GPIOs before power off +Requires=op-wait-power-off@%i.service +Before=op-wait-power-off@%i.service +Conflicts=obmc-chassis-poweron@%i.target + +[Service] +Type=oneshot +ExecStart=/usr/bin/env ampere_gpio_utils.sh power off +SyslogIdentifier=ampere_gpio_utils
\ No newline at end of file diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config/ampere-gpio-poweron@.service b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config/ampere-gpio-poweron@.service new file mode 100644 index 000000000..09aa58826 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config/ampere-gpio-poweron@.service @@ -0,0 +1,10 @@ +[Unit] +Description=Ampere set GPIOs before power on +Requires=op-wait-power-on@%i.service +Before=op-wait-power-on@%i.service +Conflicts=obmc-chassis-poweroff@%i.target + +[Service] +Type=oneshot +ExecStart=/usr/bin/env ampere_gpio_utils.sh power on +SyslogIdentifier=ampere_gpio_utils diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config/ampere_gpio_utils.sh b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config/ampere_gpio_utils.sh new file mode 100644 index 000000000..8e4f455bf --- /dev/null +++ b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-gpio-config/ampere_gpio_utils.sh @@ -0,0 +1,43 @@ +#!/bin/bash +source /usr/sbin/gpio-defs.sh +source /usr/sbin/gpio-lib.sh + +function usage() { + echo "usage: ampere_gpio_utils.sh [power] [on|off]"; +} + +set_gpio_power_off() { + echo "Setting GPIO before Power off" + gpio_configure_output $OCP_AUX_PWREN 1 + gpio_configure_output $OCP_MAIN_PWREN 0 + gpio_configure_output $SPI0_PROGRAM_SEL 0 +} + +set_gpio_power_on() { + echo "Setting GPIO before Power on" + gpio_configure_output $OCP_AUX_PWREN 1 + gpio_configure_output $OCP_MAIN_PWREN 1 + gpio_configure_output $SPI0_PROGRAM_SEL 1 + gpio_configure_output $SPI0_BACKUP_SEL 0 +} + +if [ $# -lt 2 ]; then + echo "Total number of parameter=$#" + echo "Insufficient parameter" + usage; + exit 0; +fi + +if [ $1 == "power" ]; then + if [ $2 == "on" ]; then + set_gpio_power_on + elif [ $2 == "off" ]; then + set_gpio_power_off + fi + exit 0; +else + echo "Invalid parameter1=$1" + usage; + exit 0; +fi +exit 0; diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils.bb b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils.bb new file mode 100644 index 000000000..159ccdd64 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils.bb @@ -0,0 +1,22 @@ +SUMMARY = "Ampere Platform Environment Definitions" +DESCRIPTION = "Ampere Platform Environment Definitions" +PR = "r1" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" + +SRC_URI = " \ + file://gpio-defs.sh \ + file://gpio-lib.sh \ + file://ampere_power_util.sh \ + file://ampere_host_check.sh \ + " + +RDEPENDS_${PN} = "bash" + +do_install() { + install -d ${D}/usr/sbin + install -m 0755 ${WORKDIR}/gpio-lib.sh ${D}/${sbindir}/ + install -m 0755 ${WORKDIR}/gpio-defs.sh ${D}/${sbindir}/ + install -m 0755 ${WORKDIR}/ampere_power_util.sh ${D}/${sbindir}/ + install -m 0755 ${WORKDIR}/ampere_host_check.sh ${D}/${sbindir}/ +}
\ No newline at end of file diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/ampere_host_check.sh b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/ampere_host_check.sh new file mode 100644 index 000000000..9eeeeca5a --- /dev/null +++ b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/ampere_host_check.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +source /usr/sbin/gpio-defs.sh +source /usr/sbin/gpio-lib.sh + +host_status() { + st=$(busctl get-property xyz.openbmc_project.State.Host /xyz/openbmc_project/state/host0 xyz.openbmc_project.State.Host CurrentHostState | cut -d"." -f6) + if [ "$st" == "Running\"" ]; then + echo "on" + else + echo "off" + fi +} + +createFile=$1 +setState=$2 + +if [ $(host_status) == "on" ]; then + exit 0 +fi + +# Time out to check S0_FW_BOOT_OK is 60 seconds +cnt=60 +val=0 +while [ $cnt -gt 0 ]; +do + val=$(gpio_get_val $S0_CPU_FW_BOOT_OK) + cnt=$((cnt - 1)) + echo "$cnt S0_CPU_FW_BOOT_OK = $val" + if [ $val == 1 ]; then + # Sleep 5 second before the host is ready + sleep 5 + if [ $createFile == 1 ]; then + if [ ! -d "/run/openbmc" ]; then + mkdir -p /run/openbmc + fi + echo "Creating /run/openbmc/host@0-on" + touch /run/openbmc/host@0-on + fi + exit 0 + fi + sleep 1 +done + +exit 1 diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/ampere_power_util.sh b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/ampere_power_util.sh new file mode 100644 index 000000000..2c8ba3d91 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/ampere_power_util.sh @@ -0,0 +1,131 @@ +#!/bin/bash +#ampere_platform_config.sh is platform configuration file +source /usr/sbin/gpio-defs.sh + +# Usage of this utility +function usage() { + echo "usage: power-util mb [status|shutdown_ack|force_reset|soft_off]"; +} + +power_status() { + st=$(busctl get-property xyz.openbmc_project.State.Chassis /xyz/openbmc_project/state/chassis0 xyz.openbmc_project.State.Chassis CurrentPowerState | cut -d"." -f6) + if [ "$st" == "On\"" ]; then + echo "on" + else + echo "off" + fi +} + +shutdown_ack() { + if [ -f "/run/openbmc/host@0-softpoweroff" ]; then + echo "Receive shutdown ACK triggered after softportoff the host." + touch /run/openbmc/host@0-softpoweroff-shutdown-ack + else + echo "Receive shutdown ACK triggered" + sleep 3 + systemctl start obmc-chassis-poweroff@0.target + fi +} + +soft_off() { + # Trigger shutdown_req + touch /run/openbmc/host@0-softpoweroff + gpioset -l $GPIO_CHIP0_IDX $S0_SHD_REQ_L=1 + sleep 1s + gpioset -l $GPIO_CHIP0_IDX $S0_SHD_REQ_L=0 + + # Wait for shutdown_ack from the host in 30 seconds + cnt=30 + while [ $cnt -gt 0 ]; + do + # Wait for SHUTDOWN_ACK and create the host@0-softpoweroff-shutdown-ack + if [ -f "/run/openbmc/host@0-softpoweroff-shutdown-ack" ]; then + break + fi + sleep 1 + cnt=$((cnt - 1)) + done + # Softpoweroff is successed + sleep 2 + rm -rf /run/openbmc/host@0-softpoweroff + if [ -f "/run/openbmc/host@0-softpoweroff-shutdown-ack" ]; then + rm -rf /run/openbmc/host@0-softpoweroff-shutdown-ack + fi + echo 0 +} + +force_reset() { + if [ -f "/run/openbmc/host@0-softpoweroff" ]; then + # In graceful host reset, after trigger os shutdown, + # the phosphor-state-manager will call force-warm-reset + # in this case the force_reset should wait for shutdown_ack from host + cnt=30 + while [ $cnt -gt 0 ]; + do + if [ -f "/run/openbmc/host@0-softpoweroff-shutdown-ack" ]; then + break + fi + echo "Waiting for shutdown-ack count down $cnt" + sleep 1 + cnt=$((cnt - 1)) + done + # The host OS is failed to shutdown + if [ $cnt == 0 ]; then + echo "Shutdown-ack time out after 30s." + exit 0 + fi + fi + echo "Triggering sysreset pin" + gpioset -l $GPIO_CHIP0_IDX $S0_SYSRESET_L=1 + sleep 1 + gpioset -l $GPIO_CHIP0_IDX $S0_SYSRESET_L=0 +} + +if [ $# -lt 2 ]; then + echo "Total number of parameter=$#" + echo "Insufficient parameter" + usage; + exit 0; +fi + +if [ $1 != "mb" ]; then + echo "Invalid parameter1=$1" + usage; + exit 0; +fi + +# check if power guard enabled +dir="/run/systemd/system/" +file="reboot-guard.conf" +units=("reboot" "poweroff" "halt") +for unit in "${units[@]}"; do + if [ -f ${dir}${unit}.target.d/${file} ]; then + echo "PowerGuard enabled, cannot do power control, exit!!!" + exit -1 + fi +done + +if [ ! -d "/run/openbmc/" ]; then + mkdir -p "/run/openbmc/" +fi + +if [ $2 == "shutdown_ack" ]; then + shutdown_ack +elif [ $2 == "status" ]; then + power_status +elif [ $2 == "force_reset" ]; then + force_reset +elif [ $2 == "soft_off" ]; then + ret=$(soft_off) + if [ $ret == 0 ]; then + echo "The host is already softoff" + else + echo "Failed to softoff the host" + fi + exit $ret; +else + echo "Invalid parameter2=$2" + usage; +fi + +exit 0; diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/gpio-defs.sh b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/gpio-defs.sh new file mode 100644 index 000000000..7c887d409 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/gpio-defs.sh @@ -0,0 +1,40 @@ +# Index of GPIO device in gpioget/gpioset +GPIO_CHIP0_IDX=0 +GPIO_CHIP1_IDX=1 + +# Base of GPIO chip in /sys/class/gpio +GPIO_CHIP0_BASE=792 +GPIO_CHIP1_BASE=780 + +### Power control configuration +# Power control gpios +S0_SHD_REQ_L=49 +S0_SHD_ACK_L=50 +S0_REBOOT_ACK_L=75 +S0_SYSRESET_L=91 + + +### Table 1: GPIO Assignments +S0_CPU_FW_BOOT_OK=48 +CPU_BMC_OVERTEMP_L=51 +CPU_BMC_HIGHTEMP_L=72 +CPU_FAULT_ALERT=73 +S1_CPU_FW_BOOT_OK=202 + +### Table 2: Alert and Additional Miscellaneous Signals +S0_SCP_AUTH_FAILURE=74 +S1_SCP_AUTH_FAILURE=205 +BMC_OK=228 +SLAVE_PRESENT_L=230 + +### Common GPIOs +SYS_PSON_L=42 +BMC_READY=229 + +### OCP power selection +OCP_AUX_PWREN=139 +OCP_MAIN_PWREN=140 + +### SPI0 Mode selection +SPI0_PROGRAM_SEL=226 +SPI0_BACKUP_SEL=227 diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/gpio-lib.sh b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/gpio-lib.sh new file mode 100644 index 000000000..8d1aa61d7 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-ampere/platform/mtjade-utils/gpio-lib.sh @@ -0,0 +1,31 @@ +#!/bin/bash +source /usr/sbin/gpio-defs.sh + +function gpio_number() { + GPIO_BASE=$(cat /sys/class/gpio/gpiochip$GPIO_CHIP0_BASE/base) + echo $((${GPIO_BASE} + $1)) +} + +# Configure GPIO as output and set its value +function gpio_configure_output() { + gpioId=$(gpio_number $1) + echo $gpioId > /sys/class/gpio/export + echo out > /sys/class/gpio/gpio${gpioId}/direction + echo $2 > /sys/class/gpio/gpio${gpioId}/value + echo $gpioId > /sys/class/gpio/unexport +} + +function gpio_get_val() { + gpioId=$(gpio_number $1) + echo $gpioId > /sys/class/gpio/export + echo $(cat /sys/class/gpio/gpio$gpioId/value) + echo $gpioId > /sys/class/gpio/unexport +} + +# Configure GPIO as input +function gpio_configure_input() { + gpioId=$(gpio_number $1) + echo $gpioId > /sys/class/gpio/export + echo "in" > /sys/class/gpio/gpio${gpioId}/direction + echo $gpioId > /sys/class/gpio/unexport +} diff --git a/meta-ampere/meta-jade/recipes-phosphor/gpio/host-gpio-handling.bb b/meta-ampere/meta-jade/recipes-phosphor/gpio/host-gpio-handling.bb new file mode 100644 index 000000000..4358b1242 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-phosphor/gpio/host-gpio-handling.bb @@ -0,0 +1,23 @@ +SUMMARY = "Ampere Computing LLC Host Gpio Handling" +PR = "r1" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" + +inherit obmc-phosphor-systemd + +DEPENDS += "virtual/obmc-gpio-monitor" +RDEPENDS_${PN} += "virtual/obmc-gpio-monitor" + +OBMC_HOST_ACK_MONITOR_INSTANCES = "reboot_ack shutdown_ack" + +SYSTEMD_ENVIRONMENT_FILE_${PN} +="obmc/gpio/reboot_ack \ + obmc/gpio/shutdown_ack \ + " + +TMPL = "phosphor-gpio-monitor@.service" +INSTFMT = "phosphor-gpio-monitor@{0}.service" +TGT = "multi-user.target" +FMT = "../${TMPL}:${TGT}.requires/${INSTFMT}" + +SYSTEMD_SERVICE_${PN} += "ampere-host-shutdown-ack@.service" +SYSTEMD_LINK_${PN} += "${@compose_list(d, 'FMT', 'OBMC_HOST_ACK_MONITOR_INSTANCES')}" diff --git a/meta-ampere/meta-jade/recipes-phosphor/gpio/host-gpio-handling/ampere-host-shutdown-ack@.service b/meta-ampere/meta-jade/recipes-phosphor/gpio/host-gpio-handling/ampere-host-shutdown-ack@.service new file mode 100644 index 000000000..6588191aa --- /dev/null +++ b/meta-ampere/meta-jade/recipes-phosphor/gpio/host-gpio-handling/ampere-host-shutdown-ack@.service @@ -0,0 +1,8 @@ +[Unit] +Description=Ampere Computing LLC host shutdown ACK +Conflicts=obmc-chassis-poweron@0.target + +[Service] +Type=oneshot +ExecStart=/usr/bin/env ampere_power_util.sh mb shutdown_ack +SyslogIdentifier=ampere_host_shutdown_ack diff --git a/meta-ampere/meta-common/recipes-ac01/host/files/obmc/gpio/reboot_ack b/meta-ampere/meta-jade/recipes-phosphor/gpio/host-gpio-handling/obmc/gpio/reboot_ack index 0436d32da..a8ad98ee7 100644 --- a/meta-ampere/meta-common/recipes-ac01/host/files/obmc/gpio/reboot_ack +++ b/meta-ampere/meta-jade/recipes-phosphor/gpio/host-gpio-handling/obmc/gpio/reboot_ack @@ -1,4 +1,4 @@ DEVPATH=/dev/input/event0 KEY=75 POLARITY=1 -TARGET=ampere-host-reset-ack.service +TARGET=obmc-host-force-warm-reboot@0.target diff --git a/meta-ampere/meta-common/recipes-ac01/host/files/obmc/gpio/shutdown_ack b/meta-ampere/meta-jade/recipes-phosphor/gpio/host-gpio-handling/obmc/gpio/shutdown_ack index a0e857fac..18cc87246 100644 --- a/meta-ampere/meta-common/recipes-ac01/host/files/obmc/gpio/shutdown_ack +++ b/meta-ampere/meta-jade/recipes-phosphor/gpio/host-gpio-handling/obmc/gpio/shutdown_ack @@ -1,4 +1,4 @@ DEVPATH=/dev/input/event0 KEY=50 POLARITY=1 -TARGET=ampere-chassis-poweroff.service +TARGET=ampere-host-shutdown-ack@0.service diff --git a/meta-ampere/meta-jade/recipes-phosphor/inventory/inventory-cleanup/inventory-cleanup.yaml b/meta-ampere/meta-jade/recipes-phosphor/inventory/inventory-cleanup/inventory-cleanup.yaml index e900ad789..3fa190852 100644 --- a/meta-ampere/meta-jade/recipes-phosphor/inventory/inventory-cleanup/inventory-cleanup.yaml +++ b/meta-ampere/meta-jade/recipes-phosphor/inventory/inventory-cleanup/inventory-cleanup.yaml @@ -12,5 +12,5 @@ events: /system/chassis: xyz.openbmc_project.Inventory.Item.Chassis: Type: - value: "RackMount" + value: "xyz.openbmc_project.Inventory.Item.Chassis.ChassisType.RackMount" type: string diff --git a/meta-ampere/meta-jade/recipes-phosphor/ipmi/phosphor-ipmi-host/ampere-phosphor-softpoweroff b/meta-ampere/meta-jade/recipes-phosphor/ipmi/phosphor-ipmi-host/ampere-phosphor-softpoweroff new file mode 100644 index 000000000..214aeed7a --- /dev/null +++ b/meta-ampere/meta-jade/recipes-phosphor/ipmi/phosphor-ipmi-host/ampere-phosphor-softpoweroff @@ -0,0 +1,5 @@ +#!/bin/bash +# Usage of this utility +echo "Trigger soft off the host." +/usr/sbin/ampere_power_util.sh mb soft_off +exit $?; diff --git a/meta-ampere/meta-jade/recipes-phosphor/ipmi/phosphor-ipmi-host/ampere.xyz.openbmc_project.Ipmi.Internal.SoftPowerOff.service b/meta-ampere/meta-jade/recipes-phosphor/ipmi/phosphor-ipmi-host/ampere.xyz.openbmc_project.Ipmi.Internal.SoftPowerOff.service new file mode 100644 index 000000000..01b31b1b3 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-phosphor/ipmi/phosphor-ipmi-host/ampere.xyz.openbmc_project.Ipmi.Internal.SoftPowerOff.service @@ -0,0 +1,13 @@ +[Unit] +Description=Ampere Soft power off of the host +Wants=obmc-host-stop-pre@0.target +Before=obmc-host-stop-pre@0.target +Conflicts=obmc-host-start@0.target +ConditionPathExists=!/run/openbmc/host@0-request +ConditionPathExists=!/lib/systemd/system/pldmSoftPowerOff.service + +[Service] +Restart=no +ExecStart=/usr/bin/env phosphor-softpoweroff +SyslogIdentifier=phosphor-softpoweroff +Type=oneshot diff --git a/meta-ampere/meta-jade/recipes-phosphor/ipmi/phosphor-ipmi-host_%.bbappend b/meta-ampere/meta-jade/recipes-phosphor/ipmi/phosphor-ipmi-host_%.bbappend index c0bcbdd3a..b8ea8d8d5 100644 --- a/meta-ampere/meta-jade/recipes-phosphor/ipmi/phosphor-ipmi-host_%.bbappend +++ b/meta-ampere/meta-jade/recipes-phosphor/ipmi/phosphor-ipmi-host_%.bbappend @@ -3,13 +3,23 @@ FILESEXTRAPATHS_append_mtjade := "${THISDIR}/${PN}:" DEPENDS_append_mtjade = " mtjade-yaml-config" RRECOMMENDS_${PN} += "ipmitool" +RDEPENDS_${PN} += "bash" + +SRC_URI += " \ + file://ampere-phosphor-softpoweroff \ + file://ampere.xyz.openbmc_project.Ipmi.Internal.SoftPowerOff.service \ + " EXTRA_OECONF_mtjade = " \ SENSOR_YAML_GEN=${STAGING_DIR_HOST}${datadir}/mtjade-yaml-config/ipmi-sensors-${MACHINE}.yaml \ FRU_YAML_GEN=${STAGING_DIR_HOST}${datadir}/mtjade-yaml-config/ipmi-fru-read.yaml \ " +AMPERE_SOFTPOWEROFF_TMPL = "ampere.xyz.openbmc_project.Ipmi.Internal.SoftPowerOff.service" + do_install_append_mtjade(){ install -d ${D}${includedir}/phosphor-ipmi-host install -m 0644 -D ${S}/selutility.hpp ${D}${includedir}/phosphor-ipmi-host + install -m 0755 ${WORKDIR}/ampere-phosphor-softpoweroff ${D}/${bindir}/phosphor-softpoweroff + install -m 0644 ${WORKDIR}/${AMPERE_SOFTPOWEROFF_TMPL} ${D}${systemd_unitdir}/system/xyz.openbmc_project.Ipmi.Internal.SoftPowerOff.service } diff --git a/meta-ampere/meta-jade/recipes-phosphor/ipmi/phosphor-ipmi-net_%.bbappend b/meta-ampere/meta-jade/recipes-phosphor/ipmi/phosphor-ipmi-net_%.bbappend new file mode 100644 index 000000000..33802713d --- /dev/null +++ b/meta-ampere/meta-jade/recipes-phosphor/ipmi/phosphor-ipmi-net_%.bbappend @@ -0,0 +1,7 @@ +DEFAULT_RMCPP_IFACE = "eth1" + +ALT_RMCPP_IFACE = "eth0" +SYSTEMD_SERVICE_${PN} += " \ + ${PN}@${ALT_RMCPP_IFACE}.service \ + ${PN}@${ALT_RMCPP_IFACE}.socket \ + " diff --git a/meta-ampere/meta-jade/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bbappend b/meta-ampere/meta-jade/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bbappend index f41e5bcd7..ca86a4a21 100644 --- a/meta-ampere/meta-jade/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bbappend +++ b/meta-ampere/meta-jade/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bbappend @@ -1,2 +1,6 @@ -RDEPENDS_${PN}-extras_append_mtjade = " webui-vue phosphor-image-signing" +RDEPENDS_${PN}-extras_append_mtjade = " webui-vue phosphor-image-signing phosphor-virtual-sensor" RDEPENDS_${PN}-inventory_append_mtjade = " fault-monitor id-button psu-hotswap-reset" + +RDEPENDS_${PN}-inventory_append_mtjade = " \ + host-gpio-handling \ + " diff --git a/meta-ampere/meta-jade/recipes-phosphor/sensors/phosphor-virtual-sensor/virtual_sensor_config.json b/meta-ampere/meta-jade/recipes-phosphor/sensors/phosphor-virtual-sensor/virtual_sensor_config.json new file mode 100644 index 000000000..d0dc76782 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-phosphor/sensors/phosphor-virtual-sensor/virtual_sensor_config.json @@ -0,0 +1,36 @@ +[ + { + "Desc": + { + "Name": "total_power", + "SensorType": "power" + }, + "Threshold" : + { + }, + "Params": + { + "DbusParam": + [ + { + "ParamName": "PSU0_POUTPUT", + "Desc": + { + "Name": "PSU0_POUTPUT", + "SensorType": "power" + } + }, + { + "ParamName": "PSU1_POUTPUT", + "Desc": + { + "Name": "PSU1_POUTPUT", + "SensorType": "power" + } + } + ] + }, + "Expression": "PSU0_POUTPUT + PSU1_POUTPUT" + } +] + diff --git a/meta-ampere/meta-jade/recipes-phosphor/sensors/phosphor-virtual-sensor_%.bbappend b/meta-ampere/meta-jade/recipes-phosphor/sensors/phosphor-virtual-sensor_%.bbappend new file mode 100644 index 000000000..3c68ff533 --- /dev/null +++ b/meta-ampere/meta-jade/recipes-phosphor/sensors/phosphor-virtual-sensor_%.bbappend @@ -0,0 +1,10 @@ +FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" + +SRC_URI_append_mtjade += " \ + file://virtual_sensor_config.json \ + " + +do_install_append_mtjade() { + install -m 0644 ${WORKDIR}/virtual_sensor_config.json ${D}${datadir}/phosphor-virtual-sensor/ +} + diff --git a/meta-ampere/meta-jade/recipes-phosphor/watchdog/phosphor-watchdog_%.bbappend b/meta-ampere/meta-jade/recipes-phosphor/watchdog/phosphor-watchdog_%.bbappend new file mode 100644 index 000000000..0d17c372a --- /dev/null +++ b/meta-ampere/meta-jade/recipes-phosphor/watchdog/phosphor-watchdog_%.bbappend @@ -0,0 +1,9 @@ +FILESEXTRAPATHS_append_mtjade := "${THISDIR}/${PN}:" + +# +# Ampere Mt. Jade power control involves different action during +# the course of action which does not involve rebooting the Host. +# Thus disable the use of Host Power-On watchdog. +# +WATCHDOG_FMT = "" +ENABLE_WATCHDOG_FMT = "" |