Initial commit

This commit is contained in:
Your Name
2026-04-23 17:07:55 +08:00
commit b7e39e063b
16725 changed files with 1625565 additions and 0 deletions
@@ -0,0 +1,73 @@
SUMMARY = "Ampere Computing LLC Host Control Implementation"
DESCRIPTION = "A host control implementation suitable for Ampere Computing LLC's 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-host-shutdown.service \
file://ampere_power_util.sh \
file://ampere-chassis-poweroff.service \
file://ampere-chassis-poweron.service \
file://ampere-chassis-powercycle.service \
file://ampere-host-shutdown-ack.service \
file://ampere-host-power-cycle.service \
file://ampere-host-reset.service \
"
DEPENDS = "systemd"
RDEPENDS:${PN} = "bash"
SYSTEMD_PACKAGES = "${PN}"
SYSTEMD_SERVICE:${PN} = " \
ampere-host-shutdown.service \
ampere-chassis-poweroff.service \
ampere-chassis-poweron.service \
ampere-chassis-powercycle.service \
ampere-host-shutdown-ack.service \
ampere-host-power-cycle.service \
ampere-host-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')}"
# 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')}"
CHASSIS_POWERCYCLE_SVC = "ampere-chassis-powercycle.service"
CHASSIS_POWERCYCLE_TGTFMT = "obmc-chassis-powercycle@{0}.target"
CHASSIS_POWERCYCLE_FMT = "../${CHASSIS_POWERCYCLE_SVC}:${CHASSIS_POWERCYCLE_TGTFMT}.requires/${CHASSIS_POWERCYCLE_SVC}"
SYSTEMD_LINK:${PN} += "${@compose_list_zip(d, 'CHASSIS_POWERCYCLE_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}${libexecdir}/${PN}
install -m 0755 ${WORKDIR}/ampere_power_util.sh ${D}${libexecdir}/${PN}/ampere_power_util.sh
}
@@ -0,0 +1,8 @@
[Unit]
Description=Ampere Computing LLC Power OFF Chassis
[Service]
RemainAfterExit=no
Type=oneshot
ExecStart=/usr/libexec/ampere-hostctrl/ampere_power_util.sh mb hotswap
SyslogIdentifier=ampere_power_util.sh
@@ -0,0 +1,11 @@
[Unit]
Description=Ampere Computing LLC Power OFF Chassis
Requires=phosphor-wait-power-off@%i.service
Before=phosphor-wait-power-off@%i.service
Conflicts=obmc-chassis-poweron@0.target
[Service]
RemainAfterExit=no
Type=oneshot
ExecStart=/usr/libexec/ampere-hostctrl/ampere_power_util.sh mb off
SyslogIdentifier=ampere_power_util.sh
@@ -0,0 +1,9 @@
[Unit]
Description=Ampere Computing LLC Power ON Chassis
Conflicts=obmc-chassis-poweroff@0.target
[Service]
RemainAfterExit=yes
Type=oneshot
ExecStart=/usr/libexec/ampere-hostctrl/ampere_power_util.sh mb on
SyslogIdentifier=ampere_power_util.sh
@@ -0,0 +1,12 @@
[Unit]
Description=Ampere Computing LLC power cycle service
Conflicts=obmc-host-start@0.target
OnFailure=obmc-chassis-powerreset@0.target
Wants=kudo-bios-verify.service
After=kudo-bios-verify.service
[Service]
RemainAfterExit=no
Type=oneshot
ExecStart=/usr/libexec/ampere-hostctrl/ampere_power_util.sh mb host_cycle
SyslogIdentifier=ampere_power_util.sh
@@ -0,0 +1,12 @@
[Unit]
Description=Ampere Computing LLC power cycle service
Conflicts=obmc-host-start@0.target
OnFailure=obmc-chassis-powerreset@0.target
Wants=kudo-bios-verify.service
After=kudo-bios-verify.service
[Service]
RemainAfterExit=no
Type=oneshot
ExecStart=/usr/libexec/ampere-hostctrl/ampere_power_util.sh mb host_reset
SyslogIdentifier=ampere_power_util.sh
@@ -0,0 +1,11 @@
[Unit]
Description=Ampere Computing LLC host shutdown ACK
Requires=phosphor-wait-power-off@%i.service
Before=phosphor-wait-power-off@%i.service
Conflicts=obmc-chassis-poweron@0.target
[Service]
RemainAfterExit=no
Type=oneshot
ExecStart=/usr/libexec/ampere-hostctrl/ampere_power_util.sh mb shutdown_ack
SyslogIdentifier=ampere_power_util.sh
@@ -0,0 +1,10 @@
[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/libexec/ampere-hostctrl/ampere_power_util.sh mb graceful_shutdown
SyslogIdentifier=ampere_power_util.sh
@@ -0,0 +1,140 @@
#!/bin/bash
# Provide source directive to shellcheck.
# shellcheck source=meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-lib.sh
source /usr/libexec/kudo-fw/kudo-lib.sh
# Usage of this utility
function usage() {
echo "usage: power-util mb [on|off|graceful_shutdown|host_reset|host_cycle|shutdown_ack|hotswap]";
}
hotswap() {
kudo.sh rst hotswap
}
force_off() {
echo "Powering down Server"
set_gpio_ctrl POWER_OUT 1
sleep 6
set_gpio_ctrl POWER_OUT 0
}
power_off() {
busctl set-property xyz.openbmc_project.Watchdog /xyz/openbmc_project/watchdog/host0 xyz.openbmc_project.State.Watchdog ExpireAction s xyz.openbmc_project.State.Watchdog.Action.None
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"
set_gpio_ctrl POWER_OUT 1
sleep 1
set_gpio_ctrl POWER_OUT 0
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
}
host_status() {
BOOT_OK=$(get_gpio_ctrl S0_FW_BOOT_OK)
S5_N=$(get_gpio_ctrl S0_SLPS5_N)
if [ "$S5_N" == 1 ] || [ "$BOOT_OK" == 1 ]; then
echo "on"
else
echo "off"
fi
}
timestamp() {
date +"%s" # current time
}
graceful_shutdown() {
if [ -f "/run/openbmc/host@0-request" ]; then
echo "Shutdown host immediately"
power_off
else
echo "Triggering graceful shutdown"
mkdir /run/openbmc
timestamp > "/run/openbmc/host@0-shutdown-req-time"
set_gpio_ctrl S0_SHD_REQ 0
sleep 3
set_gpio_ctrl S0_SHD_REQ 1
fi
}
host_reset() {
echo "Triggering sysreset pin"
busctl set-property xyz.openbmc_project.Watchdog /xyz/openbmc_project/watchdog/host0 xyz.openbmc_project.State.Watchdog ExpireAction s xyz.openbmc_project.State.Watchdog.Action.None
set_gpio_ctrl S0_SYSRESET 0
sleep 1
set_gpio_ctrl S0_SYSRESET 1
}
host_cycle() {
echo "DC cycling host"
force_off
sleep 2
power_on
}
shutdown_ack() {
echo "Receive shutdown ACK triggered"
power_off
if [ -f "/run/openbmc/host@0-shutdown-req-time" ]; then
rm -rf "/run/openbmc/host@0-shutdown-req-time"
fi
}
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
sleep 3
if [ "$(power_status)" == "off" ]; then
power_on
fi
elif [ "$2" = "off" ]; then
if [ "$(power_status)" == "on" ]; then
power_off
sleep 6
if [ "$(host_status)" == "on" ]; then
force_off
fi
fi
elif [ "$2" == "hotswap" ]; then
hotswap
elif [ "$2" == "graceful_shutdown" ]; then
graceful_shutdown
elif [ "$2" == "host_reset" ]; then
host_reset
elif [ "$2" == "host_cycle" ]; then
host_cycle
elif [ "$2" == "shutdown_ack" ]; then
shutdown_ack
else
echo "Invalid parameter2=$2"
usage;
fi
exit 0;
@@ -0,0 +1,11 @@
[Unit]
Description=Power Cycle by Hotswap Controller
After=gbmc-psu-hardreset.target
[Service]
Type=oneshot
ExecStart=gpioset 2 30=1
StandardOutput=syslog
[Install]
WantedBy=gbmc-psu-hardreset.target
@@ -0,0 +1,21 @@
SUMMARY = "Power Cycle by Hotswap Controller"
DESCRIPTION = "Power Cycle by Hotswap Controller Daemon"
PR = "r1"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
inherit systemd
DEPENDS += "systemd"
RDEPENDS:${PN} += "bash"
FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
SRC_URI += " file://hotswap-power-cycle.service"
do_install() {
install -d ${D}${systemd_unitdir}/system/
install -m 0644 ${WORKDIR}/hotswap-power-cycle.service ${D}${systemd_unitdir}/system/hotswap-power-cycle.service
}
SYSTEMD_PACKAGES = "${PN}"
SYSTEMD_SERVICE:${PN} = " hotswap-power-cycle.service"
@@ -0,0 +1,18 @@
SUMMARY = "foxconn OEM IPMI commands"
DESCRIPTION = "foxconn OEM IPMI commands"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
S = "${WORKDIR}/git"
DEPENDS = "boost phosphor-ipmi-host phosphor-logging systemd libgpiod"
inherit meson pkgconfig
SRC_URI = "git://github.com/openbmc/foxconn-ipmi-oem.git;branch=master;protocol=https"
SRCREV = "40553244bd6131be9c3395f212bed39e44932651"
FILES:${PN}:append = " ${libdir}/ipmid-providers"
FILES:${PN}:append = " ${libdir}/host-ipmid"
FILES:${PN}:append = " ${libdir}/net-ipmid"
@@ -0,0 +1,33 @@
SUMMARY = "Phosphor OpenBMC Kudo BIOS Firmware Upgrade Command"
DESCRIPTION = "Phosphor OpenBMC Kudo BIOS Firmware Upgrade Comman Daemon"
PR = "r1"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
inherit systemd
inherit obmc-phosphor-systemd
DEPENDS += "systemd"
DEPENDS += "phosphor-ipmi-flash"
RDEPENDS:${PN} += "libsystemd"
RDEPENDS:${PN} += "bash"
FILES:${PN} += "${datadir}/phosphor-ipmi-flash/config-bios.json"
SRC_URI += " \
file://phosphor-ipmi-flash-bios-update.service \
file://config-bios.json \
"
SYSTEMD_PACKAGES = "${PN}"
SYSTEMD_SERVICE:${PN} += " \
phosphor-ipmi-flash-bios-update.service \
"
do_install () {
install -d ${D}${datadir}/phosphor-ipmi-flash
install -m 0644 ${WORKDIR}/config-bios.json ${D}${datadir}/phosphor-ipmi-flash
install -d ${D}${systemd_system_unitdir}
install -m 0644 ${WORKDIR}/phosphor-ipmi-flash-bios-update.service ${D}${systemd_system_unitdir}
}
@@ -0,0 +1,19 @@
[{
"blob": "/flash/bios",
"handler": {
"type": "file",
"path": "/run/initramfs/bios-image"
},
"actions": {
"preparation": {
"type": "skip"
},
"verification": {
"type": "skip"
},
"update": {
"type": "systemd",
"unit": "phosphor-ipmi-flash-bios-update.service"
}
}
}]
@@ -0,0 +1,6 @@
[Unit]
Description=Phosphor-ipmi-flash update BIOS firmware service
[Service]
ExecStart=/usr/sbin/kudo-fw.sh bios /run/initramfs/bios-image
Type=oneshot
@@ -0,0 +1,20 @@
SUMMARY = "Phosphor OpenBMC Kudo BMC Firmware Upgrade Command"
DESCRIPTION = "Phosphor OpenBMC Kudo BMC Firmware Upgrade Comman Daemon"
PR = "r1"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
DEPENDS += "phosphor-ipmi-flash"
RDEPENDS:${PN} += "bash"
RPROVIDES:${PN} += "virtual/bmc-update"
FILES:${PN} += "${datadir}/phosphor-ipmi-flash/config-bmc.json"
SRC_URI += " \
file://config-bmc.json \
"
do_install () {
install -d ${D}${datadir}/phosphor-ipmi-flash
install -m 0644 ${WORKDIR}/config-bmc.json ${D}${datadir}/phosphor-ipmi-flash
}
@@ -0,0 +1,20 @@
[{
"blob": "/flash/image",
"handler": {
"type": "file",
"path": "/run/initramfs/image-bmc"
},
"actions": {
"preparation": {
"type": "skip"
},
"verification": {
"type": "skip"
},
"update": {
"type": "systemd",
"unit": "reboot.target",
"mode": "replace-irreversibly"
}
}
}]
@@ -0,0 +1,39 @@
SUMMARY = "Phosphor OpenBMC Kudo CPLD Firmware Upgrade Command"
DESCRIPTION = "Phosphor OpenBMC Kudo CPLD Firmware Upgrade Comman Daemon"
PR = "r1"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
inherit systemd
inherit obmc-phosphor-systemd
DEPENDS += "systemd"
DEPENDS += "phosphor-ipmi-flash"
RDEPENDS:${PN} += "libsystemd"
RDEPENDS:${PN} += "bash"
FILES:${PN} += "${datadir}/phosphor-ipmi-flash/config-bmccpld.json"
FILES:${PN} += "${datadir}/phosphor-ipmi-flash/config-mbcpld.json"
SRC_URI += " \
file://phosphor-ipmi-flash-bmccpld-update.service \
file://phosphor-ipmi-flash-mbcpld-update.service \
file://config-bmccpld.json \
file://config-mbcpld.json \
"
SYSTEMD_PACKAGES = "${PN}"
SYSTEMD_SERVICE:${PN} += " \
phosphor-ipmi-flash-bmccpld-update.service \
phosphor-ipmi-flash-mbcpld-update.service \
"
do_install () {
install -d ${D}${datadir}/phosphor-ipmi-flash
install -m 0644 ${WORKDIR}/config-bmccpld.json ${D}${datadir}/phosphor-ipmi-flash
install -m 0644 ${WORKDIR}/config-mbcpld.json ${D}${datadir}/phosphor-ipmi-flash
install -d ${D}${systemd_system_unitdir}
install -m 0644 ${WORKDIR}/phosphor-ipmi-flash-bmccpld-update.service ${D}${systemd_system_unitdir}
install -m 0644 ${WORKDIR}/phosphor-ipmi-flash-mbcpld-update.service ${D}${systemd_system_unitdir}
}
@@ -0,0 +1,19 @@
[{
"blob": "/flash/bmccpld",
"handler": {
"type": "file",
"path": "/run/initramfs/bmc-cpld.svf"
},
"actions": {
"preparation": {
"type": "skip"
},
"verification": {
"type": "skip"
},
"update": {
"type": "systemd",
"unit": "phosphor-ipmi-flash-bmccpld-update.service"
}
}
}]
@@ -0,0 +1,20 @@
[{
"blob": "/flash/mbcpld",
"handler": {
"type": "file",
"path": "/run/initramfs/mb-cpld.svf"
},
"actions": {
"preparation": {
"type": "skip"
},
"verification": {
"type": "skip"
},
"update": {
"type": "systemd",
"unit": "phosphor-ipmi-flash-mbcpld-update.service"
}
}
}]
@@ -0,0 +1,9 @@
[Unit]
Description=Phosphor-ipmi-flash update BMC CPLD firmware service
[Service]
ExecStart=/usr/sbin/kudo-fw.sh bmccpld /run/initramfs/bmc-cpld.svf
Type=oneshot
[Install]
WantedBy=phosphor-ipmi-flash-bmccpld-update.target
@@ -0,0 +1,9 @@
[Unit]
Description=Phosphor-ipmi-flash update MB CPLD firmware service
[Service]
ExecStart=/usr/sbin/kudo-fw.sh mbcpld /run/initramfs/mb-cpld.svf
Type=oneshot
[Install]
WantedBy=phosphor-ipmi-flash-mbcpld-update.target
@@ -0,0 +1,37 @@
SUMMARY = "Phosphor OpenBMC Kudo Firmware Upgrade Command"
DESCRIPTION = "Phosphor OpenBMC Kudo Firmware Upgrade Comman Daemon"
PR = "r1"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
inherit systemd
inherit obmc-phosphor-systemd
DEPENDS += "systemd"
DEPENDS += "phosphor-ipmi-flash"
RDEPENDS:${PN} += "libsystemd"
RDEPENDS:${PN} += "bash"
SRC_URI = " \
file://kudo-fw.sh \
file://kudo-fw-ver.service \
file://kudo-fw-ver.sh \
file://kudo-lib.sh \
"
SYSTEMD_PACKAGES = "${PN}"
SYSTEMD_SERVICE:${PN} = " \
kudo-fw-ver.service \
"
do_install () {
install -d ${D}${sbindir}
install -d ${D}${libexecdir}/${PN}
install -m 0755 ${WORKDIR}/kudo-fw.sh ${D}${sbindir}/kudo-fw.sh
install -m 0755 ${WORKDIR}/kudo-fw-ver.sh ${D}${libexecdir}/${PN}/kudo-fw-ver.sh
install -m 0755 ${WORKDIR}/kudo-lib.sh ${D}${libexecdir}/${PN}/kudo-lib.sh
install -d ${D}${systemd_system_unitdir}
install -m 0644 ${WORKDIR}/kudo-fw-ver.service ${D}${systemd_system_unitdir}
}
@@ -0,0 +1,10 @@
[Unit]
Description=Firmware Version Daemon
[Service]
RemainAfterExit=yes
Type=oneshot
ExecStart=/usr/libexec/kudo-fw/kudo-fw-ver.sh
[Install]
WantedBy=multi-user.target
@@ -0,0 +1,33 @@
#!/bin/bash
# Disable check for splitting
# shellcheck disable=SC2207
# Provide source directive to shellcheck.
# shellcheck source=meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-lib.sh
source /usr/libexec/kudo-fw/kudo-lib.sh
BMC_CPLD_VER_FILE="/run/cpld0.version"
MB_CPLD_VER_FILE="/run/cpld1.version"
ver=''
function fw_rev() {
case $1 in
cpldb)
rsp=($(i2cget -y -f -a "${I2C_BMC_CPLD[0]}" 0x"${I2C_BMC_CPLD[1]}" 0x00 i 5))
ver=$(printf '%d.%d.%d.%d' "${rsp[4]}" "${rsp[3]}" "${rsp[2]}" "${rsp[1]}")
;;
cpldm)
rsp=($(i2cget -y -f -a "${I2C_MB_CPLD[0]}" 0x"${I2C_MB_CPLD[1]}" 0x00 i 5))
ver=$(printf '%d.%d.%d.%d' "${rsp[4]}" "${rsp[3]}" "${rsp[2]}" "${rsp[1]}")
;;
*)
;;
esac
}
fw_rev cpldb
echo "BMC CPLD version : ${ver}"
echo "${ver}" > "${BMC_CPLD_VER_FILE}"
fw_rev cpldm
echo "MB CPLD version : ${ver}"
echo "${ver}" > "${MB_CPLD_VER_FILE}"
@@ -0,0 +1,204 @@
#!/bin/bash
# Provide source directive to shellcheck.
# shellcheck source=meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-lib.sh
# Disable check for globbing and word splitting within double quotes
# shellcheck disable=SC2086
source /usr/libexec/kudo-fw/kudo-lib.sh
function fwbios() {
KERNEL_FIU_ID="c0000000.spi"
KERNEL_SYSFS_FIU="/sys/bus/platform/drivers/NPCM-FIU"
# switch the SPI mux from Host to BMC
i2cset -y -f -a ${I2C_BMC_CPLD[0]} 0x${I2C_BMC_CPLD[1]} 0x10 0x01
# rescan the spi bus
if [ -d "${KERNEL_SYSFS_FIU}/${KERNEL_FIU_ID}" ]; then
echo "${KERNEL_FIU_ID}" > "${KERNEL_SYSFS_FIU}"/unbind
sleep 1
fi
echo "${KERNEL_FIU_ID}" > "${KERNEL_SYSFS_FIU}"/bind
# write to the mtd device
BIOS_MTD=$(grep "bios" /proc/mtd | sed -n 's/^\(.*\):.*/\1/p')
if [ ! -f "$1" ]; then
echo " Cannot find the" "$1" "image file"
return 1
fi
echo "Flashing BIOS @/dev/${BIOS_MTD}"
if [ "$(flashcp -v $1 /dev/${BIOS_MTD})" -ne 0 ]; then
echo "Flashing the bios failed " >&2
return 1
fi
wait
# switch the SPI mux from BMC to Host
if [ -d "${KERNEL_SYSFS_FIU}/${KERNEL_FIU_ID}" ]; then
echo "${KERNEL_FIU_ID}" > "${KERNEL_SYSFS_FIU}"/unbind
fi
i2cset -y -f -a ${I2C_BMC_CPLD[0]} 0x${I2C_BMC_CPLD[1]} 0x10 0x00
# Disable LPI mode NV_SI_CPU_LPI_FREQ_DISABLE for SCP 1.06 and older.
if [ "$(nvparm -s 0x1 -o 0x114090)" -ne 0 ]; then
echo "Setting LPI mode for SCP 1.06 and older failed " >&2
return 1
fi
# Disable LPI mode NV_SI_CPU_LPI_FREQ_DISABLE for SCP 1.07 and newer
if [ "$(nvparm -s 0x1 -o 0x02A8)" -ne 0 ]; then
echo "Setting LPI mode for SCP 1.07 and newer failed " >&2
return 1
fi
# Disable toggling of SMPro heartbeat
if [ "$(nvparm -s 0x0 -o 0x5F0638)" -ne 0 ]; then
echo "Setting SMpro heartbeat failed " >&2
return 1
fi
if [[ $(find "$1" -type f -size +17156k 2>/dev/null) ]]; then
echo "Extracting the SCP from the image"
dd if="$1" bs=1024 skip=17156 count=256 of=/run/initramfs/myscp.img
# Update both primary and backup EEPROM
fwscp /run/initramfs/myscp.img
fwscpback /run/initramfs/myscp.img
fi
return 0
}
function fwbmccpld() {
# BMC_JTAG_MUX_1 0:BMC 1:MB
set_gpio_ctrl MB_JTAG_MUX_SEL 0
if [ "$(loadsvf -d /dev/jtag0 -s $1 -m 0)" -ne 0 ]; then
echo "BMC CPLD update failed" >&2
return 1
fi
wait
set_gpio_ctrl MB_JTAG_MUX_SEL 1
return 0
}
function fwmbcpld() {
# BMC_JTAG_MUX_1 0:BMC 1:MB
# BMC_JTAG_SEL 0:BMC 1:CPU
set_gpio_ctrl MB_JTAG_MUX_SEL 1
set_gpio_ctrl BMC_JTAG_MUX_SEL 1
if [ "$(loadsvf -d /dev/jtag0 -s $1 -m 0)" -ne 0 ]; then
echo "Mobo CPLD update failed" >&2
return 1
fi
wait
return 0
}
function fwscp() {
# BMC_I2C_BACKUP_SEL 0:failover, 1:main
# BMC_CPU_EEPROM_I2C_SEL 0:BMC, 1:CPU
scp_eeprom_sel=$(get_gpio_ctrl BACKUP_SCP_SEL)
set_gpio_ctrl BACKUP_SCP_SEL 1
set_gpio_ctrl CPU_EEPROM_SEL 0
if [ "$(ampere_eeprom_prog -b ${I2C_CPU_EEPROM[0]} -s 0x${I2C_CPU_EEPROM[1]} -p -f $1)" -ne 0 ]; then
echo "SCP eeprom update failed" >&2
return 1
fi
wait
set_gpio_ctrl CPU_EEPROM_SEL 1
set_gpio_ctrl BACKUP_SCP_SEL "$scp_eeprom_sel"
return 0
}
function fwscpback() {
# BMC_I2C_BACKUP_SEL 0:failover, 1:main
# BMC_CPU_EEPROM_I2C_SEL 0:BMC, 1:CPU
scp_eeprom_sel=$(get_gpio_ctrl BACKUP_SCP_SEL)
set_gpio_ctrl BACKUP_SCP_SEL 0
set_gpio_ctrl CPU_EEPROM_SEL 0
if [ "$(ampere_eeprom_prog -b ${I2C_CPU_EEPROM[0]} -s 0x${I2C_CPU_EEPROM[1]} -p -f $1)" -ne 0 ]; then
echo "SCP BACKUP eeprom update failed" >&2
return 1
fi
wait
set_gpio_ctrl CPU_EEPROM_SEL 1
set_gpio_ctrl BACKUP_SCP_SEL "$scp_eeprom_sel"
return 0
}
function fwmb_pwr_seq(){
#$1 0x40 seq config file
#$2 0x41 seq config file
if [[ ! -e "$1" ]]; then
echo "The file $1 does not exist"
return 1
fi
if [[ ! -e "$2" ]]; then
echo "The file $2 file does not exist"
return 1
fi
echo ${I2C_MB_PWRSEQ1[0]}-00${I2C_MB_PWRSEQ1[1]} > /sys/bus/i2c/drivers/adm1266/unbind
echo ${I2C_MB_PWRSEQ2[0]}-00${I2C_MB_PWRSEQ2[1]} > /sys/bus/i2c/drivers/adm1266/unbind
#Parameters passed to adm1266_fw_fx to be used to flash PS
#1st I2C bus number of PS's
#2nd/3rd PS seq config file
if [ "$(adm1266_fw_fx ${I2C_MB_PWRSEQ1[0]} $1 $2)" -ne 0 ]; then
echo "The power seq flash failed" >&2
return 1
fi
echo ${I2C_MB_PWRSEQ1[0]}-00${I2C_MB_PWRSEQ1[1]} > /sys/bus/i2c/drivers/adm1266/bind
echo ${I2C_MB_PWRSEQ2[0]}-00${I2C_MB_PWRSEQ2[1]} > /sys/bus/i2c/drivers/adm1266/bind
return 0
}
if [[ ! $(which flashcp) ]]; then
echo "flashcp utility not installed"
exit 1
fi
if [[ ! $(which ampere_eeprom_prog) ]]; then
echo "ampere_eeprom_prog utility not installed"
exit 1
fi
if [[ ! $(which loadsvf) ]]; then
echo "loadsvf utility not installed"
exit 1
fi
if [[ ! -e /dev/jtag0 ]]; then
echo "Jtag device driver not functional"
exit 1
fi
case $1 in
bios)
fwbios "$2"
;;
bmccpld)
fwbmccpld "$2"
;;
mbcpld)
fwmbcpld "$2"
;;
scp)
fwscp "$2"
;;
scpback)
fwscpback "$2"
;;
mbseq)
fwmb_pwr_seq "$2" "$3"
;;
*)
;;
esac
ret=$?
rm -f "$2" "$3"
exit $ret
@@ -0,0 +1,73 @@
#!/bin/bash
# Disable check for usage of the definitions within kudo-lib.sh
# shellcheck disable=SC2034
# get_gpio_num
# Dynamically obtains GPIO number from chip base and I2C expanders through line name
# line-name
function get_gpio_num() {
#shellcheck disable=SC2207
CHIP_PIN=($(gpiofind "$1" | awk '{print substr ($1, 9 ), $2 }'))
#shellcheck disable=SC2128
if [ -z "$CHIP_PIN" ]; then
echo "Could not find GPIO with name: $1"
return 1
fi
if [ "${CHIP_PIN[0]}" -gt 7 ]; then
BUS_ADDR=$(gpiodetect | grep gpiochip"${CHIP_PIN[0]}" | awk '{print substr($2, 2, length($2) - 2)}')
GPIO_BASE=$(cat /sys/bus/i2c/devices/"$BUS_ADDR"/gpio/*/base)
echo "$((GPIO_BASE+CHIP_PIN[1]))"
else
echo "$((CHIP_PIN[0]*32+CHIP_PIN[1]))"
fi
}
# set_gpio_ctrl
# line-name, high(1)/low(0)
function set_gpio_ctrl() {
#shellcheck disable=SC2046
gpioset $(gpiofind "$1")="$2"
}
# get_gpio_ctrl
# line-name
function get_gpio_ctrl() {
GPIO_NUM=$(get_gpio_num "$1")
echo "$GPIO_NUM" > /sys/class/gpio/export
cat /sys/class/gpio/gpio"$GPIO_NUM"/value
echo "$GPIO_NUM" > /sys/class/gpio/unexport
}
function get_scp_eeprom() {
scp_eeprom_sel=$(get_gpio_ctrl BACKUP_SCP_SEL)
case $scp_eeprom_sel in
0)
echo " Using Secondary SCP EEPROM"
;;
1)
echo " Using Primary SCP EEPROM"
;;
esac
}
# I2C Definitions
# The array is (<bus> <address>), where address is in hexadecimal.
I2C_BMC_CPLD=(13 76)
I2C_MB_CPLD=(34 76)
I2C_S0_SMPRO=(2 4f)
I2C_S1_SMPRO=(2 4e)
I2C_FANCTRL=(18 2c)
I2C_BMC_PWRSEQ=(14 59)
I2C_MB_PWRSEQ1=(32 40)
I2C_MB_PWRSEQ2=(32 41)
I2C_CPU_EEPROM=(40 50)
I2C_S1_CLKGEN=(37 68)
I2C_S1_PCIE_CLKGEN1=(16 6a)
I2C_S1_PCIE_CLKGEN2=(17 67)
# Board Version Definitions
BOARDVER_EVT_LAST=64
BOARDVER_DVT_LAST=127
BOARDVER_PVT_LAST=191
@@ -0,0 +1,40 @@
SUMMARY = "Phosphor OpenBMC Kudo SCP Firmware Upgrade Command"
DESCRIPTION = "Phosphor OpenBMC Kudo SCP Firmware Upgrade Comman Daemon"
PR = "r1"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
inherit systemd
inherit obmc-phosphor-systemd
DEPENDS += "systemd"
DEPENDS += "phosphor-ipmi-flash"
RDEPENDS:${PN} += "libsystemd"
RDEPENDS:${PN} += "bash"
FILES:${PN} += "${datadir}/phosphor-ipmi-flash/config-scp.json"
FILES:${PN} += "${datadir}/phosphor-ipmi-flash/config-scpback.json"
SRC_URI += " \
file://phosphor-ipmi-flash-scp-update.service \
file://phosphor-ipmi-flash-scpback-update.service \
file://config-scp.json \
file://config-scpback.json \
"
SYSTEMD_PACKAGES = "${PN}"
SYSTEMD_SERVICE:${PN} += " \
phosphor-ipmi-flash-scp-update.service \
phosphor-ipmi-flash-scpback-update.service \
"
do_install () {
install -d ${D}${datadir}/phosphor-ipmi-flash
install -m 0644 ${WORKDIR}/config-scp.json ${D}${datadir}/phosphor-ipmi-flash
install -m 0644 ${WORKDIR}/config-scpback.json ${D}${datadir}/phosphor-ipmi-flash
install -d ${D}${systemd_system_unitdir}
install -m 0644 ${WORKDIR}/phosphor-ipmi-flash-scp-update.service ${D}${systemd_system_unitdir}
install -m 0644 ${WORKDIR}/phosphor-ipmi-flash-scpback-update.service ${D}${systemd_system_unitdir}
}
@@ -0,0 +1,19 @@
[{
"blob": "/flash/scp",
"handler": {
"type": "file",
"path": "/run/initramfs/scp-fw.slim"
},
"actions": {
"preparation": {
"type": "skip"
},
"verification": {
"type": "skip"
},
"update": {
"type": "systemd",
"unit": "phosphor-ipmi-flash-scp-update.service"
}
}
}]
@@ -0,0 +1,20 @@
[{
"blob": "/flash/scpb",
"handler": {
"type": "file",
"path": "/run/initramfs/scp-fw.slim"
},
"actions": {
"preparation": {
"type": "skip"
},
"verification": {
"type": "skip"
},
"update": {
"type": "systemd",
"unit": "phosphor-ipmi-flash-scpback-update.service"
}
}
}]
@@ -0,0 +1,9 @@
[Unit]
Description=Phosphor-ipmi-flash update main EEPROM SCP firmware service
[Service]
ExecStart=/usr/sbin/kudo-fw.sh scp /run/initramfs/scp-fw.slim
Type=oneshot
[Install]
WantedBy=phosphor-ipmi-flash-scp-update.target
@@ -0,0 +1,9 @@
[Unit]
Description=Phosphor-ipmi-flash update failover EEPROM SCP firmware service
[Service]
ExecStart=/usr/sbin/kudo-fw.sh scpback /run/initramfs/scp-fw.slim
Type=oneshot
[Install]
WantedBy=phosphor-ipmi-flash-scpback-update.target
@@ -0,0 +1,30 @@
SUMMARY = "Phosphor OpenBMC Kudo System Power Control Service"
DESCRIPTION = "Phosphor OpenBMC Kudo System Power Control Daemon"
PR = "r1"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
inherit systemd
inherit obmc-phosphor-systemd
DEPENDS += "systemd"
RDEPENDS:${PN} += "libsystemd"
RDEPENDS:${PN} += "bash"
SRC_URI = " \
file://init_once.sh \
file://host-powerctrl.service \
"
SYSTEMD_PACKAGES = "${PN}"
SYSTEMD_SERVICE:${PN} = " \
host-powerctrl.service \
"
do_install () {
install -d ${D}${libexecdir}/${PN}
install -m 0755 ${WORKDIR}/init_once.sh ${D}${libexecdir}/${PN}/init_once.sh
install -d ${D}${systemd_unitdir}/system/
install -m 0644 ${WORKDIR}/host-powerctrl.service ${D}${systemd_unitdir}/system
}
@@ -0,0 +1,16 @@
[Unit]
Description = Host Power Control Sequence
Wants=ssifbridge.service
After=ssifbridge.service
Wants=kudo-bios-verify.service
After=kudo-bios-verify.service
[Service]
Restart=no
RemainAfterExit=true
Type=oneshot
ExecStart=/usr/libexec/kudo-boot/init_once.sh
StandardOutput=syslog
[Install]
WantedBy=sysinit.target
@@ -0,0 +1,75 @@
#!/bin/bash
# Provide source directive to shellcheck.
# shellcheck source=meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-lib.sh
source /usr/libexec/kudo-fw/kudo-lib.sh
function set_mux_default(){
# set all mux route to CPU before power on host
# BMC_CPU_RTC_I2C_SEL
set_gpio_ctrl CPU_RTC_SEL 1
# BMC_CPU_DDR_I2C_SEL
set_gpio_ctrl CPU_DDR_SEL 1
# BMC_CPU_EEPROM_I2C_SEL
set_gpio_ctrl CPU_EEPROM_SEL 1
# BMC_CPU_PMBUS_SEL
set_gpio_ctrl CPU_VRD_SEL 1
# LED control
# LED_BMC_LIVE
set_gpio_ctrl LED_BMC_ALIVE 1
# SPI control
# Send command to CPLD to switch the bios spi interface to host
i2cset -y -f -a "${I2C_BMC_CPLD[0]}" 0x"${I2C_BMC_CPLD[1]}" 0x10 0x00
}
# 0 - 63 EVT
# 64 + DVT/PVT
boardver=$(printf '%d' "$(awk '{print $6}' /sys/bus/i2c/drivers/fiicpld/"${I2C_MB_CPLD[0]}"-00"${I2C_MB_CPLD[1]}"/CMD00)")
# On EVT machines, the secondary SCP EEPROM is used.
# Set BMC_I2C_BACKUP_SEL to secondary.
if [[ $boardver -lt $BOARDVER_EVT_LAST ]]; then
echo "EVT system. Choosing secondary SCP EEPROM."
set_gpio_ctrl BACKUP_SCP_SEL 0
set_mux_default
# Power control
# S0_BMC_OK
set_gpio_ctrl S0_BMC_OK 1
else
echo "DVT or PVT system"
# sleep so that FRU and all ipmitool Devices are ready before HOST OS
# HPM_STBY_RST_N to DC-SCM spec
set_gpio_ctrl HPM_STBY_RST_N 1 # on DVT this became HPM_STBY_RST_N (EVT1 came from CPLD)
sleep 5 # for the MUX to get ready
set_mux_default
# Power control
# S0_BMC_OK
set_gpio_ctrl S0_BMC_OK 1
fi
# Disable CPU 1 CLK when cpu not detected
# echo init_once cpu $CPU1_STATUS > /dev/ttyS0
# echo init_once board $boardver > /dev/ttyS0
CPU1_STATUS_N=$(get_gpio_ctrl S1_STATUS_N)
if [[ $CPU1_STATUS_N == 1 ]]; then
#Execute this only on DVT systems
if [[ $boardver -lt $BOARDVER_EVT_LAST ]]; then
echo EVT system "$boardver"
else
echo DVT system "$boardver"
i2cset -y -a -f "${I2C_S1_CLKGEN[0]}" 0x"${I2C_S1_CLKGEN[1]}" 0x05 0x03
fi
#These i2c deviecs are already installed on EVT systems
i2cset -y -a -f "${I2C_S1_PCIE_CLKGEN1[0]}" 0x"${I2C_S1_PCIE_CLKGEN1[1]}" 0 1 0xdf i
i2cset -y -a -f "${I2C_S1_PCIE_CLKGEN1[0]}" 0x"${I2C_S1_PCIE_CLKGEN1[1]}" 11 1 0x01 i
i2cset -y -a -f "${I2C_S1_PCIE_CLKGEN2[0]}" 0x"${I2C_S1_PCIE_CLKGEN2[1]}" 1 2 0x3f 0x0c i
fi
# Create /run/openbmc for system power files
mkdir "/run/openbmc"
# Restart psusensor service to enusre that the VBAT sensor doesn't say "no reading" until
# it's second query after a hotswap
(sleep 45; systemctl restart xyz.openbmc_project.psusensor.service)&
@@ -0,0 +1,21 @@
SUMMARY = "Phosphor OpenBMC Kudo System Command"
DESCRIPTION = "Phosphor OpenBMC Kudo System Command Daemon"
PR = "r1"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
RDEPENDS:${PN} += "bash"
SRC_URI = " \
file://kudo.sh \
file://kudo-ras.sh \
"
SYSTEMD_PACKAGES = "${PN}"
do_install () {
install -d ${D}${sbindir}
install -m 0755 ${WORKDIR}/kudo.sh ${D}${sbindir}/kudo.sh
install -m 0755 ${WORKDIR}/kudo-ras.sh ${D}${sbindir}/kudo-ras.sh
}
@@ -0,0 +1,579 @@
#!/bin/bash
# Provide source directive to shellcheck.
# shellcheck source=meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-lib.sh
source /usr/libexec/kudo-fw/kudo-lib.sh
powerState=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0xe0 b)
getGPISourceRegisters(){
REG60=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x60 w) # GPI Data Set
REG61=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x61 w) # GPI DATA Set #0
REG62=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x62 w) # GPI DATA Set #1
REG63=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x63 w) # GPI DATA Set #2
REG64=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x64 w) # GPI DATA Set #3
DS0Pres=$((REG60 & 0x0100))
DS1Pres=$((REG60 & 0x0200))
DS2Pres=$((REG60 & 0x0400))
DS3Pres=$((REG60 & 0x0800))
}
getErrorCount() {
MemCE=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x90 w)
MemUE=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x93 w)
CoreCE=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x80 w)
CoreUE=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x83 w)
PCIeCE=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0xc0 w)
PCIeUE=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0xc2 w)
OtherCE=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0xd0 w)
OtherUE=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0xd8 w)
}
getReg61Vals() {
REG61_0800=$((REG61 & 0x0800))
REG61_0800_VAL=$((REG61_0800 >> 8))
REG61_1000=$((REG61 & 0x1000))
REG61_1000_VAL=$((REG61_1000 >> 12))
}
getReg62Vals() {
REG62_0100=$((REG62 & 0x0100))
REG62_0100_VAL=$((REG62_0100 >> 8))
REG62_0200=$((REG62 & 0x0200))
REG62_0200_VAL=$((REG62_0200 >> 9))
REG62_0400=$((REG62 & 0x0400))
REG62_0400_VAL=$((REG62_0400 >> 10))
}
getReg63Vals() {
REG63_0100=$((REG63 & 0x0100))
REG63_0100_VAL=$((REG63_0100 >> 8))
}
getReg64Vals() {
REG64_0100=$((REG64 & 0x0100))
REG64_0100_VAL=$((REG64_0100 >> 8))
REG64_0200=$((REG64 & 0x0200))
REG64_0200_VAL=$((REG64_0200 >> 9))
REG64_0800=$((REG64 & 0x0800))
REG64_0800_VAL=$((REG64_0800 >> 11))
REG64_2000=$((REG64 & 0x2000))
REG64_2000_VAL=$((REG64_2000 >> 13))
REG64_4000=$((REG64 & 0x4000))
REG64_4000_VAL=$((REG64_4000 >> 14))
REG64_8000=$((REG64 & 0x8000))
REG64_8000_VAL=$((REG64_8000 >> 15))
REG64_0001=$((REG64 & 0x0001))
REG64_0001_VAL=$((REG64_0001))
}
getGPIStatusRegisters(){
REG70=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x70 w) # Core, DIMM, SLC, PCIe, and Other errors
REG78=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x78 w) # VRD Fault/Warning Error
REG79=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x79 w) # VRD Hot
REG7A=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x7A w) # DIMM Hot Error
REG7B=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x7B w) # Boot #1 Error
REG7C=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x7C w) # Boot #2 Error
REG7D=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x7D w) # Watchdog/Other Status
REG7E=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x7E w) # RAS internal error
}
getReg70Vals() {
REG70_0100=$((REG70 & 0x0100))
REG70_0100_VAL=$((REG70_0100 >> 8))
REG70_0200=$((REG70 & 0x0200))
REG70_0200_VAL=$((REG70_0200 >> 9))
REG70_0400=$((REG70 & 0x0400))
REG70_0400_VAL=$((REG70_0400 >> 10))
REG70_0800=$((REG70 & 0x0800))
REG70_0800_VAL=$((REG70_0800 >> 11))
REG70_4000=$((REG70 & 0x4000))
REG70_4000_VAL=$((REG70_4000 >> 14))
REG70_8000=$((REG70 & 0x8000))
REG70_8000_VAL=$((REG70_8000 >> 15))
REG70_0001=$((REG70 & 0x0001))
REG70_0001_VAL=$((REG70_0001))
REG70_0002=$((REG70 & 0x0002))
REG70_0002_VAL=$((REG70_0002 >> 1))
}
getReg78Vals() {
REG78_0100=$((REG78 & 0x0100))
REG78_0100_VAL=$((REG78_0100 >> 8))
REG78_0200=$((REG78 & 0x0200))
REG78_0200_VAL=$((REG78_0200 >> 9))
REG78_0400=$((REG78 & 0x0400))
REG78_0400_VAL=$((REG78_0400 >> 10))
REG78_0800=$((REG78 & 0x0800))
REG78_0800_VAL=$((REG78_0800 >> 11))
REG78_1000=$((REG78 & 0x1000))
REG78_1000_VAL=$((REG78_1000 >> 12))
REG78_2000=$((REG78 & 0x2000))
REG78_2000_VAL=$((REG78_2000 >> 13))
REG78_4000=$((REG78 & 0x4000))
REG78_4000_VAL=$((REG78_4000 >> 14))
REG78_8000=$((REG78 & 0x8000))
REG78_8000_VAL=$((REG78_8000 >> 15))
REG78_0001=$((REG78 & 0x0001))
REG78_0001_VAL=$((REG78_0001))
REG78_0002=$((REG78 & 0x0002))
REG78_0002_VAL=$((REG78_0002 >> 1))
REG78_0004=$((REG78 & 0x0004))
REG78_0004_VAL=$((REG78_0004 >> 2))
REG78_0008=$((REG78 & 0x0008))
REG78_0008_VAL=$((REG78_0008 >> 3))
}
getReg79Vals() {
REG79_0100=$((REG79 & 0x0100))
REG79_0100_VAL=$((REG79_0100 >> 8))
REG79_1000=$((REG79 & 0x1000))
REG79_1000_VAL=$((REG79_1000 >> 12))
REG79_2000=$((REG79 & 0x2000))
REG79_2000_VAL=$((REG79_2000 >> 13))
REG79_4000=$((REG79 & 0x4000))
REG79_4000_VAL=$((REG79_4000 >> 14))
REG79_0001=$((REG79 & 0x0001))
REG79_0001_VAL=$((REG79_0001))
REG79_0002=$((REG79 & 0x0002))
REG79_0002_VAL=$((REG79_0002 >> 1))
REG79_0004=$((REG79 & 0x0004))
REG79_0004_VAL=$((REG79_0004 >> 2))
REG79_0008=$((REG79 & 0x0008))
REG79_0008_VAL=$((REG79_0008 >> 3))
}
getReg7AVals() {
REG7A_0100=$((REG7A & 0x0100))
REG7A_0100_VAL=$((REG7A_0100 >> 8))
REG7A_0200=$((REG7A & 0x0200))
REG7A_0200_VAL=$((REG7A_0200 >> 9))
REG7A_0400=$((REG7A & 0x0400))
REG7A_0400_VAL=$((REG7A_0400 >> 10))
REG7A_0800=$((REG7A & 0x0800))
REG7A_0800_VAL=$((REG7A_0800 >> 11))
REG7A_1000=$((REG7A & 0x1000))
REG7A_1000_VAL=$((REG7A_1000 >> 12))
REG7A_2000=$((REG7A & 0x2000))
REG7A_2000_VAL=$((REG7A_2000 >> 13))
REG7A_4000=$((REG7A & 0x4000))
REG7A_4000_VAL=$((REG7A_4000 >> 14))
REG7A_8000=$((REG7A & 0x8000))
REG7A_8000_VAL=$((REG7A_8000 >> 15))
}
getReg7DVals() {
REG7D_0100=$((REG7D & 0x0100))
REG7D_0100_VAL=$((REG7D_0100 >> 8))
REG7D_0200=$((REG7D & 0x0200))
REG7D_0200_VAL=$((REG7D_0200 >> 9))
REG7D_0400=$((REG7D & 0x0400))
REG7D_0400_VAL=$((REG7D_0400 >> 10))
}
getReg7EVals() {
REG7E_0100=$((REG7E & 0x0100))
REG7E_0100_VAL=$((REG7E_0100 >> 8))
REG7E_0200=$((REG7E & 0x0200))
REG7E_0200_VAL=$((REG7E_0200 >> 9))
}
getGPIMaskRegisters(){
REG50=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x50 w) # GPI Control #0
REG51=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x51 w) # GPI Control #1
REG52=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x52 w) # GPI Control #2
REG53=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x53 w) # GPI Control #3
REG54=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x54 w) # GPI CE/UE Mask
}
getReg50Vals() {
REG50_0400=$((REG50 & 0x0400))
REG50_0400_VAL=$((REG50_0400 >> 10))
REG50_0800=$((REG50 & 0x0800))
REG50_0800_VAL=$((REG50_0800 >> 11))
}
getReg51Vals() {
REG51_0100=$((REG51 & 0x0100))
REG51_0100_VAL=$((REG51_0100 >> 8))
REG51_0200=$((REG51 & 0x0200))
REG51_0200_VAL=$((REG51_0200 >> 9))
REG51_0400=$((REG51 & 0x0400))
REG51_0400_VAL=$((REG51_0400 >> 10))
}
getReg52Vals() {
REG52_0100=$((REG52 & 0x0100))
REG52_0100_VAL=$((REG52_0100 >> 8))
}
getReg53Vals() {
REG53_0100=$((REG53 & 0x0100))
REG53_0100_VAL=$((REG53_0100 >> 8))
REG53_0200=$((REG53 & 0x0200))
REG53_0200_VAL=$((REG53_0200 >> 9))
REG53_0800=$((REG53 & 0x0800))
REG53_0800_VAL=$((REG53_0800 >> 11))
REG53_2000=$((REG53 & 0x2000))
REG53_2000_VAL=$((REG53_2000 >> 13))
REG53_4000=$((REG53 & 0x4000))
REG53_4000_VAL=$((REG53_4000 >> 14))
REG53_8000=$((REG53 & 0x8000))
REG53_8000_VAL=$((REG53_8000 >> 15))
REG53_0001=$((REG53 & 0x0001))
REG53_0001_VAL=$((REG53_0001))
}
getReg54Vals() {
REG54_0100=$((REG54 & 0x0100))
REG54_0100_VAL=$((REG54_0100 >> 8))
REG54_0200=$((REG54 & 0x0200))
REG54_0200_VAL=$((REG54_0200 >> 9))
REG54_0001=$((REG54 & 0x0001))
REG54_0001_VAL=$((REG54_0001))
REG54_0002=$((REG54 & 0x0002))
REG54_0002_VAL=$((REG54_0002 >> 1))
REG54_0004=$((REG54 & 0x0004))
REG54_0004_VAL=$((REG54_0004 >> 2))
REG54_0008=$((REG54 & 0x0008))
REG54_0008_VAL=$((REG54_0008 >> 3))
REG54_0010=$((REG54 & 0x0010))
REG54_0010_VAL=$((REG54_0010 >> 4))
REG54_0020=$((REG54 & 0x0020))
REG54_0020_VAL=$((REG54_0020 >> 5))
}
if [ -z "${powerState}" ]
then
echo "System is currently Powered off S6"
else
echo "System is currently in ${powerState} "
# Get Error Count
getErrorCount
echo " "
echo " Error Count: "
echo " Memory Errors: Correctable $((MemCE >> 8)) Uncorrectable $((MemUE >> 8)) "
echo " Core Errors: Correctable $((CoreCE >> 8)) Uncorrectable $((CoreUE >> 8))"
echo " PCIe Errors: Correctable $((PCIeCE >> 8)) Uncorrectable $((PCIeUE >> 8)) "
echo " Other Errors: Correctable $((OtherCE >> 8)) Uncorrectable $((OtherUE >> 8)) "
# GPI Source Registers
getGPISourceRegisters
echo " "
echo " GPI Source Registers: "
echo " GPI Data Set #0 Present: $((DS0Pres >> 8)) "
echo " GPI Data Set #1 Present: $((DS1Pres >> 9)) "
echo " GPI Data Set #2 Present: $((DS2Pres >> 10)) "
echo " GPI Data Set #3 Present: $((DS3Pres >> 11)) "
# REG61 Data Set#0
getReg61Vals
echo " "
echo " GPI Data Set#0: "
if [[ "$REG61_0800_VAL" != 0 ]]; then
echo " Platform Booting "
fi
if [[ "$REG61_1000_VAL" != 0 ]]; then
echo " Critical Stop "
fi
# REG62 Data Set#1
getReg62Vals
echo " "
echo " GPI Data Set#1: "
if [[ "$REG62_0100_VAL" != 0 ]]; then
echo " SoC VR HOT/Warn/Fault "
fi
if [[ "$REG62_0200_VAL" != 0 ]]; then
echo " Core VR HOT/Warn/Fault "
fi
if [[ "$REG62_0400_VAL" != 0 ]]; then
echo " DIMM HOT/Warn/Fault "
fi
# REG63 Data Set#2
getReg63Vals
echo " "
echo " GPI Data Set#2: "
if [[ "$REG63_0100_VAL" != 0 ]]; then
echo " DIMM HOT "
fi
# REG64 Data Set#3
getReg64Vals
echo " "
echo " GPI Data Set#3: "
if [[ "$REG64_0100_VAL" != 0 ]]; then
echo " Core Errors "
fi
if [[ "$REG64_0200_VAL" != 0 ]]; then
echo " Memory Errors "
fi
if [[ "$REG64_0800_VAL" != 0 ]]; then
echo " PCIe Errors "
fi
if [[ "$REG64_2000_VAL" != 0 ]]; then
echo " Other Errors "
fi
if [[ "$REG64_4000_VAL" != 0 ]]; then
echo " ACPI State Change "
fi
if [[ "$REG64_8000_VAL" != 0 ]]; then
echo " Boot Errors "
fi
if [[ "$REG64_0001_VAL" != 0 ]]; then
echo " RAS Internal Error "
fi
# GPI Status Regs
getGPIStatusRegisters
echo " "
echo " GPI Status Regs "
getReg70Vals
echo " "
echo " Core, DIMM, SLC, PCIe, and Other errors: "
if [[ "$REG70_0100_VAL" != 0 ]]; then
echo " Core CE Error "
fi
if [[ "$REG70_0200_VAL" != 0 ]]; then
echo " Core UE Error "
fi
if [[ "$REG70_0400_VAL" != 0 ]]; then
echo " DIMM CE Error "
fi
if [[ "$REG70_0800_VAL" != 0 ]]; then
echo " DIMM UE Error "
fi
if [[ "$REG70_4000_VAL" != 0 ]]; then
echo " PCIe CE Error "
fi
if [[ "$REG70_8000_VAL" != 0 ]]; then
echo " PCIe UE Error "
fi
if [[ "$REG70_0001_VAL" != 0 ]]; then
echo " Other CE Error "
fi
if [[ "$REG70_0002_VAL" != 0 ]]; then
echo " Other UE Error "
fi
getReg78Vals
echo " "
echo " VRD Fault/Warning Error: "
if [[ "$REG78_0100_VAL" != 0 ]]; then
echo " SoC VRD fault/warning "
fi
if [[ "$REG78_0200_VAL" != 0 ]]; then
echo " Core VRD1 fault/warning "
fi
if [[ "$REG78_0400_VAL" != 0 ]]; then
echo " Core VRD2 fault/warning "
fi
if [[ "$REG78_0800_VAL" != 0 ]]; then
echo " Core VRD3 fault/warning "
fi
if [[ "$REG78_1000_VAL" != 0 ]]; then
echo " DIMM VRD1 fault/warning "
fi
if [[ "$REG78_2000_VAL" != 0 ]]; then
echo " DIMM VRD2 fault/warning "
fi
if [[ "$REG78_4000_VAL" != 0 ]]; then
echo " DIMM VRD3 fault/warning "
fi
if [[ "$REG78_8000_VAL" != 0 ]]; then
echo " DIMM VRD3 fault/warning "
fi
if [[ "$REG78_0001_VAL" != 0 ]]; then
echo " DIMM fault/warning "
fi
if [[ "$REG78_0002_VAL" != 0 ]]; then
echo " DIMM fault/warning "
fi
if [[ "$REG78_0004_VAL" != 0 ]]; then
echo " DIMM fault/warning "
fi
if [[ "$REG78_0008_VAL" != 0 ]]; then
echo " DIMM fault/warning "
fi
getReg79Vals
echo " "
echo " VRD Hot: "
if [[ "$REG79_0100_VAL" != 0 ]]; then
echo " SoC VRD is HOT "
fi
if [[ "$REG79_1000_VAL" != 0 ]]; then
echo " Core VRD1 is HOT "
fi
if [[ "$REG79_2000_VAL" != 0 ]]; then
echo " Core VRD2 is HOT "
fi
if [[ "$REG79_4000_VAL" != 0 ]]; then
echo " Core VRD3 is HOT "
fi
if [[ "$REG79_0001_VAL" != 0 ]]; then
echo " DIMM VRD1 is HOT "
fi
if [[ "$REG79_0002_VAL" != 0 ]]; then
echo " DIMM VRD2 is HOT "
fi
if [[ "$REG79_0004_VAL" != 0 ]]; then
echo " DIMM VRD3 is HOT "
fi
if [[ "$REG79_0008_VAL" != 0 ]]; then
echo " DIMM VRD4 is HOT "
fi
getReg7AVals
echo " "
echo " DIMM Hot Error: "
if [[ "$REG7A_0100_VAL" != 0 ]]; then
echo " DIMM channel 0 is HOT "
fi
if [[ "$REG7A_0200_VAL" != 0 ]]; then
echo " DIMM channel 1 is HOT "
fi
if [[ "$REG7A_0400_VAL" != 0 ]]; then
echo " DIMM channel 2 is HOT "
fi
if [[ "$REG7A_0800_VAL" != 0 ]]; then
echo " DIMM channel 3 is HOT "
fi
if [[ "$REG7A_1000_VAL" != 0 ]]; then
echo " DIMM channel 4 is HOT "
fi
if [[ "$REG7A_2000_VAL" != 0 ]]; then
echo " DIMM channel 5 is HOT "
fi
if [[ "$REG7A_4000_VAL" != 0 ]]; then
echo " DIMM channel 6 is HOT "
fi
if [[ "$REG7A_8000_VAL" != 0 ]]; then
echo " DIMM channel 7 is HOT "
fi
echo " "
echo " Boot #1 Error: $((REG7B >> 8)) "
echo " Boot #2 Error: $((REG7C >> 8)) "
getReg7DVals
echo " "
echo " Watchdog/Other Status: "
if [[ "$REG7D_0100_VAL" != 0 ]]; then
echo " Non-secure WDT expired "
fi
if [[ "$REG7D_0200_VAL" != 0 ]]; then
echo " Secure WDT expired "
fi
if [[ "$REG7D_0400_VAL" != 0 ]]; then
echo " Firmware WDT expired "
fi
getReg7EVals
echo " "
echo " RAS internal error: "
if [[ "$REG7E_0100_VAL" != 0 ]]; then
echo " Error from SMpro "
fi
if [[ "$REG7E_0200_VAL" != 0 ]]; then
echo " Error from PMpro "
fi
# GPI Mask Regs
getGPIMaskRegisters
echo " "
echo " GPI Mask Regs "
getReg50Vals
echo " "
echo " GPI Control #0: "
if [[ "$REG50_0400_VAL" != 0 ]]; then
echo " Platform Booting "
fi
if [[ "$REG50_0800_VAL" != 0 ]]; then
echo " Critical Stop "
fi
getReg51Vals
echo " "
echo " GPI Control #1: "
if [[ "$REG51_0100_VAL" != 0 ]]; then
echo " SoC VR HOT/Warn/Fault "
fi
if [[ "$REG51_0200_VAL" != 0 ]]; then
echo " Core VR HOT/Warn/Fault "
fi
if [[ "$REG51_0400_VAL" != 0 ]]; then
echo " DIMM VRD HOT/Warn/Fault "
fi
getReg52Vals
echo " "
echo " GPI Control #2: "
if [[ "$REG52_0100_VAL" != 0 ]]; then
echo " DIMM HOT "
fi
getReg53Vals
echo " "
echo " GPI Control #3: "
if [[ "$REG53_0100_VAL" != 0 ]]; then
echo " Core Errors "
fi
if [[ "$REG53_0200_VAL" != 0 ]]; then
echo " Memory Errors "
fi
if [[ "$REG53_0800_VAL" != 0 ]]; then
echo " PCIe Errors "
fi
if [[ "$REG53_2000_VAL" != 0 ]]; then
echo " Other SoC Errors "
fi
if [[ "$REG53_4000_VAL" != 0 ]]; then
echo " ACPI State Change "
fi
if [[ "$REG53_8000_VAL" != 0 ]]; then
echo " Boot Errors "
fi
if [[ "$REG53_0001_VAL" != 0 ]]; then
echo " RAS Internal Error "
fi
getReg54Vals
echo " "
echo " GPI CE/UE Mask: "
if [[ "$REG54_0100_VAL" != 0 ]]; then
echo " Core CE "
fi
if [[ "$REG54_0200_VAL" != 0 ]]; then
echo " Core UE "
fi
if [[ "$REG54_0001_VAL" != 0 ]]; then
echo " DIMM CE "
fi
if [[ "$REG54_0002_VAL" != 0 ]]; then
echo " DIMM UE "
fi
if [[ "$REG54_0004_VAL" != 0 ]]; then
echo " PCIe CE "
fi
if [[ "$REG54_0008_VAL" != 0 ]]; then
echo " PCIe UE "
fi
if [[ "$REG54_0010_VAL" != 0 ]]; then
echo " Other CE "
fi
if [[ "$REG54_0020_VAL" != 0 ]]; then
echo " Other UE "
fi
fi
@@ -0,0 +1,312 @@
#!/bin/bash
# help information
# Provide source directive to shellcheck.
# shellcheck source=meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-lib.sh
source /usr/libexec/kudo-fw/kudo-lib.sh
function usage_rst() {
echo " kudo rst [parameter]"
echo " hotswap --> reset the whole kudo node"
echo " system --> reset the host"
echo " btn --> trigger a power button event"
echo " shutdown --> send out shutdown signal to CPU"
echo " display --> "
}
function usage_led() {
echo " kudo led 'att'/'boot' [parameter]"
echo " on --> change to CPU console"
echo " off --> change to CPU 0 SCP console"
echo " status --> change to CPU 1 SCP console"
}
function usage_uart() {
echo " kudo uart [parameter]"
echo " host --> show CPU console"
echo " scp --> show SCP0 console"
echo " swhost --> change to CPU console to ttyS1"
echo " swscp1 --> change to CPU 0 SCP console to ttyS3"
echo " swscp2 --> change to CPU 1 SCP console"
echo " swhosthr --> change CPU console to header"
echo " swscphr --> change SCP console to header"
echo " display --> "
}
function usage() {
echo " kudo BMC console system utilities"
echo " kudo [optional] [parameter]"
echo " rst --> reset traget device"
echo " fw --> get version"
echo " uart --> control the uart mux"
echo " led --> control the leds"
}
function reset() {
case $1 in
hotswap)
# Virtual reset
set_gpio_ctrl HOTSWAP 1
;;
system)
# S0 system reset
set_gpio_ctrl S0_SYSRESET 0
sleep 1
set_gpio_ctrl S0_SYSRESET 1
;;
btn)
# virtual power button
set_gpio_ctrl POWER_OUT 1
sleep 1
set_gpio_ctrl POWER_OUT 0
;;
shutdown)
# BMC_CPU_SHD_REQ
set_gpio_ctrl S0_SHD_REQ 0
sleep 3
set_gpio_ctrl S0_SHD_REQ 1
;;
forceOff)
# virtual power button
set_gpio_ctrl POWER_OUT 1
sleep 6
set_gpio_ctrl POWER_OUT 0
;;
display)
echo "Virtual reset #$(get_gpio_num HOTSWAP)" "$(get_gpio_ctrl HOTSWAP)"
echo "S0 System reset #$(get_gpio_num S0_SYSRESET)" "$(get_gpio_ctrl S0_SYSRESET)"
echo "Power Button #$(get_gpio_num POWER_OUT)" "$(get_gpio_ctrl POWER_OUT)"
echo "BMC_CPU SHD Req #$(get_gpio_num S0_SHD_REQ)" "$(get_gpio_ctrl S0_SHD_REQ)"
;;
*)
usage_rst
;;
esac
}
function fw_rev() {
BMC_CPLD_VER_FILE="/run/cpld0.version"
MB_CPLD_VER_FILE="/run/cpld1.version"
cmd=$(cat ${BMC_CPLD_VER_FILE})
echo " BMC_CPLD: " "${cmd}"
cmd=$(cat ${MB_CPLD_VER_FILE})
echo " MB_CPLD: " "${cmd}"
# BMC Version
# Save VERSION_ID line in string "VERSION_ID=vXX.XX-XX-kudo"
StringVersion=$(awk '/VERSION_ID/' /etc/os-release)
#Save Major Version value between v and . "vXX." then convert Hex to Decimal
MajorVersion=${StringVersion#*v}
MajorVersion=$(( 10#${MajorVersion%.*}))
#Save SubMajor Version valeu between . and - ".XX-" then convert Hex to Decimal
SubMajorVersion=${StringVersion##*.}
SubMajorVersion=$(( 10#${SubMajorVersion%%-*}))
#Save Minor Version value between - and - "-XX-" then convert Hex to Decimal
MinorVersion=${StringVersion#*-}
MinorVersion=$(( 10#${MinorVersion%-*}))
echo " BMC: " ${MajorVersion}.${SubMajorVersion}.${MinorVersion}
#BMC PWR Sequencer
i2cset -y -f -a "${I2C_BMC_PWRSEQ[0]}" 0x"${I2C_BMC_PWRSEQ[1]}" 0xfe 0x0000 w
cmd=$(i2cget -y -f -a "${I2C_BMC_PWRSEQ[0]}" 0x"${I2C_BMC_PWRSEQ[1]}" 0xfe i 2 | awk '{print substr($0,3)}')
echo " BMC PowerSequencer : ${cmd}"
#only display with smbios exists
if [[ -e /var/lib/smbios/smbios2 ]]; then
cmd=$(busctl introspect xyz.openbmc_project.Smbios.MDR_V2 \
/xyz/openbmc_project/inventory/system/chassis/motherboard/bios | grep Version | awk '{print $4}')
echo " Bios: $cmd"
fi
cmd=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x1 w);
echo " SCP Firmware: ${cmd}"
get_scp_eeprom
adm1266_ver "${I2C_MB_PWRSEQ1[0]}" | grep REVISION
}
function uartmux() {
case $1 in
host)
if [ "$(tty)" == "/dev/ttyS0" ]; then
echo "Couldn't redirect to the host console within BMC local console"
else
echo "Entering Console use 'shift ~~..' to quit"
obmc-console-client -c /etc/obmc-console/server.ttyS1.conf
fi
;;
scp)
if [ "$(tty)" == "/dev/ttyS0" ]; then
echo "Couldn't redirect to the scp console within BMC local console"
else
echo "Entering Console use 'shift ~~..' to quit"
obmc-console-client -c /etc/obmc-console/server.ttyS3.conf
fi
;;
swhost)
set_gpio_ctrl S0_UART0_BMC_SEL 1
;;
swscp1)
set_gpio_ctrl S0_UART1_BMC_SEL 1
set_gpio_ctrl S1_UART0_BMC_SEL 1
set_gpio_ctrl S1_UART1_BMC_SEL 0
;;
swscp2)
set_gpio_ctrl S0_UART1_BMC_SEL 1
set_gpio_ctrl S1_UART0_BMC_SEL 1
set_gpio_ctrl S1_UART1_BMC_SEL 1
;;
swhosthr)
set_gpio_ctrl S0_UART0_BMC_SEL 0
;;
swscphr)
set_gpio_ctrl S0_UART1_BMC_SEL 0
set_gpio_ctrl S1_UART0_BMC_SEL 0
;;
display)
if [ "$(get_gpio_ctrl S0_UART0_BMC_SEL)" -eq 1 ]; then
echo " CPU host to BMC console"
else
echo " CPU host to header"
fi
if [ "$(get_gpio_ctrl S0_UART1_BMC_SEL)" -eq 1 ] && [ "$(get_gpio_ctrl S1_UART0_BMC_SEL)" -eq 1 ]; then
if [ "$(get_gpio_ctrl S1_UART1_BMC_SEL)" -eq 1 ]; then
echo " SCP2 host to BMC console"
else
echo " SCP1 host to BMC console"
fi
elif [ "$(get_gpio_ctrl S0_UART1_BMC_SEL)" -eq 0 ] && [ "$(get_gpio_ctrl S1_UART0_BMC_SEL)" -eq 0 ]; then
if [ "$(get_gpio_ctrl S1_UART1_BMC_SEL)" -eq 1 ]; then
echo " SCP2 host to Header"
else
echo " SCP1 host to Header"
fi
else
echo "It's unknown status"
echo "S0_UART0_BMC_SEL $(get_gpio_ctrl S0_UART0_BMC_SEL)"
echo "S0_UART1_BMC_SEL $(get_gpio_ctrl S0_UART1_BMC_SEL)"
echo "S1_UART0_BMC_SEL $(get_gpio_ctrl S1_UART0_BMC_SEL)"
echo "S1_UART1_BMC_SEL $(get_gpio_ctrl S1_UART1_BMC_SEL)"
fi
;;
*)
usage_uart
;;
esac
}
function ledtoggle() {
CurrentLED=$( i2cget -y -f -a "${I2C_MB_CPLD[0]}" 0x"${I2C_MB_CPLD[1]}" 0x05 i 1 | cut -d ' ' -f 2)
case $1 in
boot)
cmd=$(((CurrentLED & 0x40) != 0))
case $2 in
on)
#turn on LED
if [[ $cmd -eq 0 ]]; then
setValue=$(( 0x40 + CurrentLED ))
i2cset -y -f -a "${I2C_MB_CPLD[0]}" 0x"${I2C_MB_CPLD[1]}" 0x10 $setValue
fi
;;
off)
#turn off led
if [[ $cmd -eq 1 ]]; then
setValue=$(( 0x80 & CurrentLED ))
i2cset -y -f -a "${I2C_MB_CPLD[0]}" 0x"${I2C_MB_CPLD[1]}" 0x10 $setValue
fi
;;
toggle)
#turn on LED
setValue=$(( 0x40 ^ CurrentLED ))
i2cset -y -f -a "${I2C_MB_CPLD[0]}" 0x"${I2C_MB_CPLD[1]}" 0x10 $setValue
;;
status)
#displayLED status
if [[ $cmd -eq 1 ]]; then
echo "on"
else
echo "off"
fi
;;
*)
usage_led
;;
esac
;;
att)
cmd=$(((CurrentLED & 0x80) != 0))
case $2 in
on)
#turn on LED
if [[ $cmd -eq 0 ]]; then
setValue=$(( 0x80 + CurrentLED ))
i2cset -y -f -a "${I2C_MB_CPLD[0]}" 0x"${I2C_MB_CPLD[1]}" 0x10 $setValue
fi
;;
off)
#turn off led
if [[ $cmd -eq 1 ]]; then
setValue=$(( 0x40 & CurrentLED ))
i2cset -y -f -a "${I2C_MB_CPLD[0]}" 0x"${I2C_MB_CPLD[1]}" 0x10 $setValue
fi
;;
toggle)
#turn on LED
setValue=$(( 0x80 ^ CurrentLED ))
i2cset -y -f -a "${I2C_MB_CPLD[0]}" 0x"${I2C_MB_CPLD[1]}" 0x10 $setValue
;;
status)
#displayLED status
if [[ $cmd -eq 1 ]]; then
echo "on"
else
echo "off"
fi
;;
*)
usage_led
;;
esac
;;
*)
usage_led
;;
esac
}
function usblist() {
for i in {5..9}
do
cmd=$(devmem 0xf083"${i}"154)
printf "udc%d : 0xF083%d154-" "${i}" "${i}"
echo "$cmd"
done
}
case $1 in
rst)
reset "$2"
;;
fw)
fw_rev
;;
uart)
uartmux "$2"
;;
usb)
usblist
;;
led)
ledtoggle "$2" "$3"
;;
*)
usage
;;
esac
@@ -0,0 +1,16 @@
UMMARY = "Kudo IPMI Entity association mapping."
PR = "r1"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
SRC_URI += "file://kudo_entity_association_map.json"
FILES:${PN} = " \
${datadir}/ipmi-entity-association/entity_association_map.json \
"
do_install() {
install -d ${D}${datadir}/ipmi-entity-association
install -m 0644 -D ${WORKDIR}/kudo_entity_association_map.json \
${D}${datadir}/ipmi-entity-association/entity_association_map.json
}
@@ -0,0 +1,35 @@
{
"system_board": [
{"instance": 1, "name": "/"}
],
"system_internal_expansion_board": [
{"instance": 1, "name": "/"}
],
"power_system_board": [
{"instance": 1, "name": "/"}
],
"add_in_card": [
{"instance": 3, "name": "/PE0"},
{"instance": 5, "name": "/PE1"},
{"instance": 6, "name": "/PE2"},
{"instance": 7, "name": "/PE3"},
{"instance": 8, "name": "/PE4"},
{"instance": 9, "name": "/PE5"},
{"instance": 10, "name": "/PE6"},
{"instance": 11, "name": "/PE7"}
],
"fan": [
{"instance": 0, "name": "/fan0"},
{"instance": 1, "name": "/fan1"},
{"instance": 2, "name": "/fan2"},
{"instance": 3, "name": "/fan3"},
{"instance": 4, "name": "/fan4"},
{"instance": 5, "name": "/fan5"}
],
"cooling_unit": [
{"instance": 0, "name": "/ZONE0"},
{"instance": 1, "name": "/ZONE1"},
{"instance": 2, "name": "/ZONE2"},
{"instance": 3, "name": "/ZONE3"}
]
}
@@ -0,0 +1,29 @@
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
inherit allarch systemd
DEPENDS += "systemd"
RDEPENDS:${PN} += "libsystemd"
RDEPENDS:${PN} += "bash"
SRC_URI +=" \
file://usb_network.sh \
file://usb_network.service \
file://00-bmc-usb0.network \
"
SYSTEMD_PACKAGES = "${PN}"
SYSTEMD_SERVICE:${PN} += " usb_network.service"
FILES:${PN} += "${sysconfdir_native}/systemd/network/00-bmc-usb0.network"
do_install() {
install -d ${D}${libexecdir}/${PN}
install -m 0755 ${WORKDIR}/usb_network.sh ${D}${libexecdir}/${PN}/usb_network.sh
install -d ${D}${systemd_unitdir}/system/
install -m 0644 ${WORKDIR}/usb_network.service ${D}${systemd_unitdir}/system
install -d ${D}${sysconfdir_native}/systemd/network/
install -m 0644 ${WORKDIR}/00-bmc-usb0.network ${D}${sysconfdir_native}/systemd/network
}
@@ -0,0 +1,7 @@
[Match]
Name=usb0
[Address]
Address=169.254.95.118/16
[Network]
LinkLocalAddressing=ipv6
IPv6AcceptRA=no
@@ -0,0 +1,10 @@
[Unit]
Description=enable usb network
After=phosphor-ipmi-host.service
[Service]
Type=oneshot
ExecStart=/bin/bash -c '/usr/libexec/usb-network/usb_network.sh'
[Install]
WantedBy=multi-user.target
@@ -0,0 +1,27 @@
#!/bin/bash
cd /sys/kernel/config/usb_gadget || exit 1
if [ ! -f "g1" ]; then
mkdir g1
cd g1 || exit 1
echo 0x1d6b > idVendor # Linux foundation
echo 0x0104 > idProduct # Multifunction composite gadget
mkdir -p strings/0x409
echo "Linux" > strings/0x409/manufacturer
echo "Ethernet/ECM gadget" > strings/0x409/product
mkdir -p configs/c.1
echo 100 > configs/c.1/MaxPower
mkdir -p configs/c.1/strings/0x409
echo "ECM" > configs/c.1/strings/0x409/configuration
mkdir -p functions/ecm.usb0
ln -s functions/ecm.usb0 configs/c.1
echo f0835000.udc > UDC
fi
exit 0
@@ -0,0 +1,62 @@
SUMMARY = "OpenBMC for kudo system - Applications"
PR = "r1"
inherit packagegroup
PROVIDES = "${PACKAGES}"
PACKAGES = " \
${PN}-kudo-chassis \
${PN}-kudo-system \
${PN}-kudo-fw \
${PN}-fan-mgmt \
"
PROVIDES += "virtual/obmc-chassis-mgmt"
PROVIDES += "virtual/obmc-system-mgmt"
PROVIDES += "virtual/obmc-fan-mgmt"
RPROVIDES:${PN}-kudo-chassis += "virtual-obmc-chassis-mgmt"
RPROVIDES:${PN}-kudo-system += "virtual-obmc-system-mgmt"
RPROVIDES:${PN}-kudo-fw += "virtual-obmc-flash-mgmt"
RPROVIDES:${PN}-fan-mgmt += "virtual-obmc-fan-mgmt"
SUMMARY:${PN}-kudo-chassis = "kudo chassis"
RDEPENDS:${PN}-kudo-chassis = " \
phosphor-skeleton-control-power \
obmc-phosphor-buttons-signals \
obmc-phosphor-buttons-handler \
"
SUMMARY:${PN}-kudo-system = "kudo System"
RDEPENDS:${PN}-kudo-system = " \
ipmitool \
ethtool \
memtester \
loadsvf \
fii-ipmi-oem \
kudo-entity-association-map \
hotswap-power-cycle \
obmc-console \
usb-network \
ncsid \
gbmc-mac-config \
kudo-boot \
kudo-cmd \
phosphor-state-manager \
smbios-mdr \
"
SUMMARY:${PN}-kudo-fw = "kudo Firmware"
RDEPENDS:${PN}-kudo-fw = " \
kudo-fw \
kudo-bios-update \
kudo-bmc-update \
kudo-cpld-update \
kudo-scp-update \
"
SUMMARY:${PN}-fan-mgmt = "kudo fan mgmt"
RDEPENDS:${PN}-fan-mgmt = " \
pwm-init \
phosphor-pid-control \
"