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
+11
View File
@@ -0,0 +1,11 @@
# We have a conf and classes directory, add to BBPATH
BBPATH .= ":${LAYERDIR}"
# We have recipes-* directories, add to BBFILES
BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
${LAYERDIR}/recipes-*/*/*.bbappend"
BBFILE_COLLECTIONS += "mitchell-layer"
BBFILE_PATTERN_mitchell-layer := "^${LAYERDIR}/"
LAYERSERIES_COMPAT_mitchell-layer = "langdale mickledore"
@@ -0,0 +1,48 @@
KMACHINE = "aspeed"
KERNEL_DEVICETREE = "${KMACHINE}-bmc-ampere-mtmitchell.dtb"
UBOOT_DEVICETREE = "ast2600-bletchley"
UBOOT_MACHINE = "ast2600_openbmc_spl_defconfig"
SPL_BINARY = "spl/u-boot-spl.bin"
SOCSEC_SIGN_ENABLE = "0"
SERIAL_CONSOLES = "115200;ttyS4"
require conf/machine/include/ast2600.inc
require conf/machine/include/obmc-bsp-common.inc
FLASH_SIZE = "65536"
VOLATILE_LOG_DIR = "no"
MACHINE_FEATURES += "\
obmc-bmc-state-mgmt \
obmc-chassis-state-mgmt \
obmc-host-ipmi \
obmc-host-state-mgmt \
obmc-phosphor-chassis-mgmt \
obmc-phosphor-flash-mgmt \
"
OBMC_IMAGE_EXTRA_INSTALL:append = " \
ampere-utils \
ampere-usbnet \
phosphor-misc-usb-ctrl \
ampere-platform-init \
ampere-ipmi-oem \
ampere-hostctrl \
ampere-driver-binder \
ampere-mac-update \
phosphor-gpio-monitor-monitor \
phosphor-ipmi-blobs \
phosphor-ipmi-blobs-binarystore \
util-linux \
ampere-sysfw-hang-handler \
ampere-fault-monitor \
"
PREFERRED_PROVIDER_virtual/obmc-chassis-mgmt = "packagegroup-obmc-ampere-apps"
PREFERRED_PROVIDER_virtual/obmc-system-mgmt = "packagegroup-obmc-ampere-apps"
PREFERRED_PROVIDER_virtual/obmc-flash-mgmt = "packagegroup-obmc-ampere-apps"
PREFERRED_PROVIDER_virtual/obmc-host-ipmi-hw = "phosphor-ipmi-ssif"
PREFERRED_PROVIDER_virtual/phosphor-led-manager-config-native = "ampere-led-manager-config-native"
OVERRIDES .= ":ampere"
@@ -0,0 +1,31 @@
# LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf
# changes incompatibly
LCONF_VERSION = "8"
BBPATH = "${TOPDIR}"
BBFILES ?= ""
BBLAYERS ?= " \
##OEROOT##/meta \
##OEROOT##/meta-openembedded/meta-oe \
##OEROOT##/meta-openembedded/meta-networking \
##OEROOT##/meta-openembedded/meta-perl \
##OEROOT##/meta-openembedded/meta-python \
##OEROOT##/meta-security \
##OEROOT##/meta-phosphor \
##OEROOT##/meta-aspeed \
##OEROOT##/meta-ampere \
##OEROOT##/meta-ampere/meta-mitchell \
"
BBLAYERS_NON_REMOVABLE ?= " \
##OEROOT##/meta \
##OEROOT##/meta-openembedded/meta-oe \
##OEROOT##/meta-openembedded/meta-networking \
##OEROOT##/meta-openembedded/meta-perl \
##OEROOT##/meta-openembedded/meta-python \
##OEROOT##/meta-security \
##OEROOT##/meta-phosphor \
##OEROOT##/meta-aspeed \
##OEROOT##/meta-ampere \
##OEROOT##/meta-ampere/meta-mitchell \
"
@@ -0,0 +1,2 @@
Common targets are:
obmc-phosphor-image
@@ -0,0 +1,214 @@
#
# This file is your local configuration file and is where all local user settings
# are placed. The comments in this file give some guide to the options a new user
# to the system might want to change but pretty much any configuration option can
# be set in this file.
#
# Lines starting with the '#' character are commented out and in some cases the
# default values are provided as comments to show people example syntax. Enabling
# the option is a question of removing the # character and making any change to the
# variable as required.
#
# Machine Selection
#
MACHINE ??= "mtmitchell"
#
# Where to place downloads
#
# During a first build the system will download many different source code tarballs
# from various upstream projects. This can take a while, particularly if your network
# connection is slow. These are all stored in DL_DIR. When wiping and rebuilding you
# can preserve this directory to speed up this part of subsequent builds. This directory
# is safe to share between multiple builds on the same machine too.
#
# The default is a downloads directory under TOPDIR which is the build directory.
#
#DL_DIR ?= "${TOPDIR}/downloads"
#
# Where to place shared-state files
#
# BitBake has the capability to accelerate builds based on previously built output.
# This is done using "shared state" files which can be thought of as cache objects
# and this option determines where those files are placed.
#
# You can wipe out TMPDIR leaving this directory intact and the build would regenerate
# from these files if no changes were made to the configuration. If changes were made
# to the configuration, only shared state files where the state was still valid would
# be used (done using checksums).
#
# The default is a sstate-cache directory under TOPDIR.
#
#SSTATE_DIR ?= "${TOPDIR}/sstate-cache"
#
# Where to place the build output
#
# This option specifies where the bulk of the building work should be done and
# where BitBake should place its temporary files and output. Keep in mind that
# this includes the extraction and compilation of many applications and the toolchain
# which can use Gigabytes of hard disk space.
#
# The default is a tmp directory under TOPDIR.
#
#TMPDIR = "${TOPDIR}/tmp"
#
# Default policy config
#
# The distribution setting controls which policy settings are used as defaults.
# The default value is fine for general Yocto project use, at least initially.
# Ultimately when creating custom policy, people will likely end up subclassing
# these defaults.
#
DISTRO ?= "openbmc-phosphor"
# As an example of a subclass there is a "bleeding" edge policy configuration
# where many versions are set to the absolute latest code from the upstream
# source control systems. This is just mentioned here as an example, its not
# useful to most new users.
# DISTRO ?= "poky-bleeding"
#
# Package Management configuration
#
# This variable lists which packaging formats to enable. Multiple package backends
# can be enabled at once and the first item listed in the variable will be used
# to generate the root filesystems.
# Options are:
# - 'package_deb' for debian style deb files
# - 'package_ipk' for ipk files are used by opkg (a debian style embedded package manager)
# - 'package_rpm' for rpm style packages
# E.g.: PACKAGE_CLASSES ?= "package_rpm package_deb package_ipk"
# We default to ipk:
PACKAGE_CLASSES ?= "package_ipk"
#
# SDK/ADT target architecture
#
# This variable specifies the architecture to build SDK/ADT items for and means
# you can build the SDK packages for architectures other than the machine you are
# running the build on (i.e. building i686 packages on an x86_64 host).
# Supported values are i686 and x86_64
#SDKMACHINE ?= "i686"
SANITY_TESTED_DISTROS:append ?= " *"
#
# Extra image configuration defaults
#
# The EXTRA_IMAGE_FEATURES variable allows extra packages to be added to the generated
# images. Some of these options are added to certain image types automatically. The
# variable can contain the following options:
# "dbg-pkgs" - add -dbg packages for all installed packages
# (adds symbol information for debugging/profiling)
# "dev-pkgs" - add -dev packages for all installed packages
# (useful if you want to develop against libs in the image)
# "ptest-pkgs" - add -ptest packages for all ptest-enabled packages
# (useful if you want to run the package test suites)
# "tools-sdk" - add development tools (gcc, make, pkgconfig etc.)
# "tools-debug" - add debugging tools (gdb, strace)
# "eclipse-debug" - add Eclipse remote debugging support
# "tools-profile" - add profiling tools (oprofile, exmap, lttng, valgrind)
# "tools-testapps" - add useful testing tools (ts_print, aplay, arecord etc.)
# "debug-tweaks" - make an image suitable for development
# e.g. ssh root access has a blank password
# There are other application targets that can be used here too, see
# meta/classes/image.bbclass and meta/classes/core-image.bbclass for more details.
# We default to enabling the debugging tweaks.
EXTRA_IMAGE_FEATURES ?= "debug-tweaks"
#
# Additional image features
#
# The following is a list of additional classes to use when building images which
# enable extra features. Some available options which can be included in this variable
# are:
# - 'buildstats' collect build statistics
# - 'image-swab' to perform host system intrusion detection
# NOTE: if listing mklibs & prelink both, then make sure mklibs is before prelink
# NOTE: mklibs also needs to be explicitly enabled for a given image, see local.conf.extended
USER_CLASSES ?= "buildstats"
#
# Runtime testing of images
#
# The build system can test booting virtual machine images under qemu (an emulator)
# after any root filesystems are created and run tests against those images. To
# enable this uncomment this line. See classes/testimage(-auto).bbclass for
# further details.
#TEST_IMAGE = "1"
#
# Interactive shell configuration
#
# Under certain circumstances the system may need input from you and to do this it
# can launch an interactive shell. It needs to do this since the build is
# multithreaded and needs to be able to handle the case where more than one parallel
# process may require the user's attention. The default is iterate over the available
# terminal types to find one that works.
#
# Examples of the occasions this may happen are when resolving patches which cannot
# be applied, to use the devshell or the kernel menuconfig
#
# Supported values are auto, gnome, xfce, rxvt, screen, konsole (KDE 3.x only), none
# Note: currently, Konsole support only works for KDE 3.x due to the way
# newer Konsole versions behave
#OE_TERMINAL = "auto"
# By default disable interactive patch resolution (tasks will just fail instead):
PATCHRESOLVE = "noop"
#
# Disk Space Monitoring during the build
#
# Monitor the disk space during the build. If there is less that 1GB of space or less
# than 100K inodes in any key build location (TMPDIR, DL_DIR, SSTATE_DIR), gracefully
# shutdown the build. If there is less that 100MB or 1K inodes, perform a hard abort
# of the build. The reason for this is that running completely out of space can corrupt
# files and damages the build in ways which may not be easily recoverable.
# It's necessary to monitor /tmp, if there is no space left the build will fail
# with very exotic errors.
BB_DISKMON_DIRS ??= "\
STOPTASKS,${TMPDIR},1G,100K \
STOPTASKS,${DL_DIR},1G,100K \
STOPTASKS,${SSTATE_DIR},1G,100K \
STOPTASKS,/tmp,100M,100K \
HALT,${TMPDIR},100M,1K \
HALT,${DL_DIR},100M,1K \
HALT,${SSTATE_DIR},100M,1K \
HALT,/tmp,10M,1K"
#
# Shared-state files from other locations
#
# As mentioned above, shared state files are prebuilt cache data objects which can
# used to accelerate build time. This variable can be used to configure the system
# to search other mirror locations for these objects before it builds the data itself.
#
# This can be a filesystem directory, or a remote url such as http or ftp. These
# would contain the sstate-cache results from previous builds (possibly from other
# machines). This variable works like fetcher MIRRORS/PREMIRRORS and points to the
# cache locations to check for the shared objects.
# NOTE: if the mirror uses the same structure as SSTATE_DIR, you need to add PATH
# at the end as shown in the examples below. This will be substituted with the
# correct path within the directory structure.
#SSTATE_MIRRORS ?= "\
#file://.* http://someserver.tld/share/sstate/PATH;downloadfilename=PATH \n \
#file://.* file:///some/local/dir/sstate/PATH"
#
# Qemu configuration
#
# By default qemu will build with a builtin VNC server where graphical output can be
# seen. The two lines below enable the SDL backend too. This assumes there is a
# libsdl library available on your build system.
#PACKAGECONFIG_append_pn-qemu-native = " sdl"
#PACKAGECONFIG_append_pn-nativesdk-qemu = " sdl"
#ASSUME_PROVIDED += "libsdl-native"
# CONF_VERSION is increased each time build/conf/ changes incompatibly and is used to
# track the version of this file when it was generated. This can safely be ignored if
# this doesn't mean anything to you.
CONF_VERSION = "2"
@@ -0,0 +1,31 @@
SUMMARY = "Ampere Computing LLC System Firmware Hang Handler"
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
RDEPENDS:${PN} = "bash"
FILESEXTRAPATHS:append := "${THISDIR}/${PN}:"
SYSTEMD_PACKAGES = "${PN}"
SRC_URI = " \
file://ampere-sysfw-hang-handler.service \
file://ampere_sysfw_hang_handler.sh \
"
SYSTEMD_SERVICE:${PN} += "ampere-sysfw-hang-handler.service"
SYSFW_HANG_TGT = "ampere-sysfw-hang-handler.service"
SYSFW_HANG_INSTMPL = "ampere-sysfw-hang-handler.service"
AMPER_HOST_RUNNING = "obmc-host-already-on@{0}.target"
SYSFW_HANG_TARGET_FMT = "../${SYSFW_HANG_TGT}:${AMPER_HOST_RUNNING}.wants/${SYSFW_HANG_INSTMPL}"
SYSTEMD_LINK:${PN} += "${@compose_list_zip(d, 'SYSFW_HANG_TARGET_FMT', 'OBMC_HOST_INSTANCES')}"
do_install() {
install -d ${D}/usr/sbin
install -m 0755 ${WORKDIR}/ampere_sysfw_hang_handler.sh ${D}/${sbindir}/
}
@@ -0,0 +1,10 @@
[Unit]
Description=Ampere System Firmware Hang Handler
After=obmc-host-already-on@0.target
BindTo=obmc-host-already-on@0.target
ConditionPathExists=!/var/ampere/sysfw-hang-disable
[Service]
Type=simple
ExecStart=/usr/sbin/ampere_sysfw_hang_handler.sh
SyslogIdentifier=ampere_sysfw_hang
@@ -0,0 +1,42 @@
#!/bin/bash
# shellcheck source=meta-ampere/meta-mitchell/recipes-ampere/platform/ampere-platform-init/gpio-lib.sh
source /usr/sbin/gpio-lib.sh
# Do event trigger
function sel_trigger()
{
echo "Error: system firmware hang, trigger sel"
ampere_add_redfishevent.sh OpenBMC.0.1.SystemPowerOnFailed.Critical
}
# Do reset the system
function reset_system()
{
echo "Error: system firmware hang, reset the system"
ipmitool chassis power reset
}
s0_last_hb_state=0
cnt=-1
while true
do
# Monitor heart beat GPIO value, GPIOF4 for Socket 0
s0_hb_state=$(gpio_name_get s0-heartbeat)
if [ "$s0_last_hb_state" != "$s0_hb_state" ]; then
cnt=0
else
cnt=$((cnt + 1))
fi
if [ "$cnt" -ge 6 ]; then
echo "Error: system firmware hang"
sel_trigger
reset_system
exit 0
fi
s0_last_hb_state="$s0_hb_state"
sleep 0.5
done
exit 0
@@ -0,0 +1,42 @@
SUMMARY = "OpenBMC for Ampere - Applications"
PR = "r1"
inherit packagegroup
PROVIDES = "${PACKAGES}"
PACKAGES = " \
${PN}-chassis \
${PN}-flash \
${PN}-system \
"
PROVIDES += "virtual/obmc-chassis-mgmt"
PROVIDES += "virtual/obmc-flash-mgmt"
PROVIDES += "virtual/obmc-system-mgmt"
RPROVIDES:${PN}-chassis += "virtual-obmc-chassis-mgmt"
RPROVIDES:${PN}-flash += "virtual-obmc-flash-mgmt"
RPROVIDES:${PN}-system += "virtual-obmc-system-mgmt"
SUMMARY:${PN}-chassis = "Ampere Chassis"
RDEPENDS:${PN}-chassis = " \
obmc-phosphor-buttons-signals \
obmc-phosphor-buttons-handler \
phosphor-skeleton-control-power \
ampere-hostctrl \
phosphor-hostlogger \
phosphor-sel-logger \
phosphor-logging \
phosphor-post-code-manager \
phosphor-host-postd \
"
SUMMARY:${PN}-system = "Ampere System"
RDEPENDS:${PN}-system = " \
smbios-mdr \
"
SUMMARY:${PN}-flash = "Ampere Flash"
RDEPENDS:${PN}-flash = " \
phosphor-software-manager \
"
@@ -0,0 +1,14 @@
FILESEXTRAPATHS:append := "${THISDIR}/${PN}:"
RDEPENDS:${PN} = "bash"
SRC_URI += " \
file://ampere_fault_monitor.sh \
file://ampere_check_gpio_fault.sh \
"
do_install() {
install -d ${D}/${sbindir}
install -m 755 ${WORKDIR}/ampere_fault_monitor.sh ${D}/${sbindir}/
install -m 755 ${WORKDIR}/ampere_check_gpio_fault.sh ${D}/${sbindir}/
}
@@ -0,0 +1,351 @@
#!/bin/bash
# This script monitors S0/S1 GPIO fault and detects errors from CPUs
#
# So far, there is no specification describes the behavior of LED when an error (a pattern is detected) occurs.
# So when detecting a pattern, we simply set the gpio fault flag and turn on the SYS LED.
#
# The Parttern will in the format:
# <minor_byte> <quite_gap_1second> <major_byte> <stop_condition_low_for_3seconds>
#
# Ex: pattern minor_byte=0x03, major_byte=0x02, you will see the waveform like
# _1010100...(quite gap, low for 1 second)..0111111111000000000111111111110000000000...(stop condition, low for 3 seconds)..
#
# Usage: <app_name> <socket 0/1>
#
# shellcheck source=/dev/null
source /usr/sbin/gpio-lib.sh
# global variables
error_flag='/tmp/gpio_fault'
# the command "cat /sys/class/gpio/gpio"$gpio_Id"/value" itself, takes 10ms~35ms to complete, depends on CPU loading
polling_minor_byte_rate=0
polling_major_byte_rate=200000
polling_rate=$polling_minor_byte_rate
# the mount of low to ensure that already get out of minor_byte and is in quite gap
# this value depends on the polling_minor_byte_rate
max_low_in_minor_byte=9
# the mount of low to ensure that already get out of major_byte and is in stop condition
# this value depends on the polling_major_byte_rate
max_low_in_major_byte=9
max_low=$max_low_in_minor_byte
# state machines:
# detecting_minor_byte=0
# detecting_major_byte=1
curr_state=0
minor_byte=0
major_byte=0
gpio_status=0
socket=$1
socket1_present=151
socket1_status=1
S0_fault_gpio='s0-fault-alert'
S1_fault_gpio='s1-fault-alert'
map_event_name() {
case $major_byte in
2)
event_major="FAULT_LED_BOOT_ERROR"
case $minor_byte in
1)
event_minor="SOC_BOOTDEV_INIT_SEC_ERROR"
;;
2)
event_minor="SECJMP_FAIL_ERROR"
;;
3)
event_minor="UART_INIT_WARN"
;;
4)
event_minor="UART_TX_WARN"
;;
5)
event_minor="SOC_ROMPATCH_BAD_ERROR"
;;
6)
event_minor="SOC_ROMPATCH_RANGE_ERROR"
;;
7)
event_minor="SPI_INIT_ERROR"
;;
8)
event_minor="SPI_TX_ERROR"
;;
9)
event_minor="SPINOR_UNKNOW_DEVICE_WARN"
;;
10)
event_minor="EEPROM_BAD_NVP_HEADER_WARN"
;;
11)
event_minor="EEPROM_BAD_NVP_FIELD_WARN"
;;
12)
event_minor="EEPROM_BAD_CHECKSUM_ERROR_WARN"
;;
13)
event_minor="I2C_DMA_ERROR"
;;
14)
event_minor="I2C_TIMEOUT_ERROR"
;;
15)
event_minor="SOC_BOOTDEV_SPI_LOAD_ERROR"
;;
16)
event_minor="SOC_BOOTDEV_AUTHENTICATION_ERROR"
;;
17)
event_minor="PCP_POWERUP_FAILED"
;;
18)
event_minor="PCP_POWERDOWN_FAILED"
;;
19)
event_minor="CPUPLL_INIT_FAILED"
;;
20)
event_minor="MESHPLL_INIT_FAILED"
;;
*)
event_minor="NOT_SUPPORT"
esac
;;
3)
event_major="FAULT_LED_FW_LOAD_ERROR"
case $minor_byte in
9)
event_minor="LFS_ERROR"
;;
*)
event_minor="NOT_SUPPORT"
esac
;;
4)
event_major="FAULT_LED_SECURITY_ERROR"
case $minor_byte in
1)
event_minor="SEC_INVALID_KEY_CERT"
;;
2)
event_minor="SEC_INVALID_CONT_CERT"
;;
3)
event_minor="SEC_INVALID_ROOT_KEY"
;;
4)
event_minor="SEC_INVALID_SECPRO_KEY"
;;
5)
event_minor="SEC_INVALID_KEY_CERT_SIG"
;;
6)
event_minor="SEC_INVALID_CONT_CERT_SIG"
;;
7)
event_minor="SEC_INVALID_IMAGE_HASH"
;;
8)
event_minor="SEC_INVALID_PRI_VERSION"
;;
9)
event_minor="SEC_HUK_MISMATCH"
;;
10)
event_minor="SEC_FUSE_BLOW_CERT_WITHOUT_SPECIAL_BOOT_PIN"
;;
11)
event_minor="SEC_INVALID_CERT_SUBTYPE_STRUCT"
;;
12)
event_minor="SEC_TMMCFG_FAIL"
;;
13)
event_minor="SEC_INVALID_LCS_FROM_EFUSE"
;;
14)
event_minor="SEC_EFUSE_WRITE_FAILED"
;;
15)
event_minor="SEC_INVALID_CERT_VALUE"
;;
16)
event_minor="SEC_INVALID_CERT_VERSION"
;;
*)
event_minor="NOT_SUPPORT"
;;
esac
;;
5)
event_major="FAULT_LED_EXCEPTION_ERROR"
case $minor_byte in
1)
event_minor="KERNEL_EXCEPTION_UNKNOWN_REASON_ERROR"
;;
2)
event_minor="KERNEL_EXCEPTION_HARD_FAULT_ERROR"
;;
3)
event_minor="KERNEL_EXCEPTION_BUS_FAULT_ERROR"
;;
4)
event_minor="KERNEL_EXCEPTION_MEMMANAGE_FAULT_ERROR"
;;
5)
event_minor="KERNEL_EXCEPTION_USAGE_FAULT_ERROR"
;;
*)
event_minor="NOT_SUPPORT"
;;
esac
;;
*)
event_major="NOT_SUPPORT"
;;
esac
}
set_unset_gpio_fault_flag() {
if [ ! -f $error_flag ] && [ "$1" == 1 ] ; then
touch $error_flag
elif [ -f $error_flag ] && [ "$1" == 0 ]; then
rm $error_flag
fi
}
toggle_state() {
if [ "$curr_state" == 0 ]; then
curr_state=1
polling_rate=$polling_major_byte_rate
else
curr_state=0
polling_rate=$polling_minor_byte_rate
map_event_name
echo "detected major_byte=$event_major, minor_byte=$event_minor"
set_unset_gpio_fault_flag 1
fi
}
save_pulse_of_byte() {
if [ "$curr_state" == 0 ]; then
minor_byte=$1
#echo "minor_byte=$1"
else
major_byte=$1
#echo "major_byte=$1"
fi
}
# we do not care the pulse is 50ms or 500ms, what we care is that the number of high pulses
cnt_falling_edge_in_byte() {
local cnt_falling_edge=0
local cnt_low=0
local prev=0
local curr=0
while true
do
prev=$curr
curr=$gpio_status
# count the falling edges, if they occur, just reset cnt_low
if [ "$prev" == 1 ] && [ "$curr" == 0 ]; then
cnt_falling_edge=$(( cnt_falling_edge + 1 ))
cnt_low=0
continue
# check if we are in the quite gap or stop condition
elif [ "$prev" == 0 ] && [ "$curr" == 0 ]; then
cnt_low=$(( cnt_low + 1 ))
if [ "$cnt_low" == "$max_low" ]; then
save_pulse_of_byte "$cnt_falling_edge"
toggle_state
break
fi
fi
usleep $polling_rate
gpio_status=$(cat /sys/class/gpio/gpio"$gpio_Id"/value)
done
}
gpio_config_input() {
echo "$gpio_Id" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio"${gpio_Id}"/direction
}
gpio_number() {
local offset
local gpioPin
local str
str=$(gpiofind "$1")
if [ "$?" == '1' ]; then
echo -1
else
gpioid=$(echo "$str"|cut -c 9)
offset=$(echo "$str"|cut -d " " -f 2)
gpioPin=$(("$offset" + ${AST2600_GPIO_BASE[$gpioid]}))
echo "$gpioPin"
fi
}
init_sysfs_fault_gpio() {
gpio_Id=$(gpio_number "$fault_gpio")
if [ "$gpio_Id" == "-1" ]; then
echo "Invalid GPIO number"
exit 1
fi
if [ -d /sys/class/gpio/gpio"$gpio_Id" ]; then
return
fi
gpio_config_input "$gpio_Id"
}
# init
if [ "$socket" == "0" ]; then
fault_gpio="$S0_fault_gpio"
else
socket1_status=$(gpioget 0 "$socket1_present")
if [ "$socket1_status" == 1 ]; then
echo "socket 1 not present"
exit 0
fi
fault_gpio=$S1_fault_gpio
fi
init_sysfs_fault_gpio
# daemon start
while true
do
# detect when pattern starts
if [ "$gpio_status" == 1 ]; then
if [ "$curr_state" == 0 ]; then
# detecting minor byte, set up minor byte variables
max_low=$max_low_in_minor_byte
polling_rate=$polling_minor_byte_rate
else
# detecting major byte, set up major byte variables
max_low=$max_low_in_major_byte
polling_rate=$polling_major_byte_rate
fi
# now, there is something on gpio, check if that is a byte pattern
cnt_falling_edge_in_byte
fi
usleep $polling_rate
gpio_status=$(cat /sys/class/gpio/gpio"$gpio_Id"/value)
done
exit 1
@@ -0,0 +1,218 @@
#!/bin/bash
# This script monitors fan, over-temperature, PSU, CPU/SCP failure and update fault LED status
# shellcheck disable=SC2004
# shellcheck source=/dev/null
source /usr/sbin/gpio-lib.sh
# common variables
on=1
off=0
overtemp_fault_flag='/tmp/fault_overtemp'
# gpio fault
gpio_fault="false"
gpio_fault_flag="/tmp/gpio_fault"
# fan variables
fan_failed="false"
fan_failed_flag='/tmp/fan_failed'
# PSU variables
psu_failed="false"
psu_bus=2
psu0_addr=0x58
psu1_addr=0x59
status_word_cmd=0x79
# Following the PMBus Specification
# Bit[1]: CML faults
# Bit[2]: Over temperature faults
# Bit[3]: Under voltage faults
# Bit[4]: Over current faults
# Bit[5]: Over voltage fault
# Bit[10]: Fan faults
psu_fault_bitmask=0x43e
# led variables
fan_fault_led_status=$off
psu_fault_led_status=$off
led_bus=15
led_addr=0x22
led_port0_config=0x06
led_port0_output=0x02
# functions declaration
check_fan_failed() {
if [[ -f $fan_failed_flag ]]; then
fan_failed="true"
else
fan_failed="false"
fi
}
turn_on_off_fan_fault_led() {
# Control fan fault led via CPLD's I2C at slave address 0x22, I2C16.
# Get Port0 value
p0_val=$(i2cget -f -y $led_bus $led_addr $led_port0_config)
p0_val=$(("$p0_val" & ~1))
# Config CPLD's IOepx Port0[0] from input to output, clear IOepx Port0[0].
i2cset -f -y $led_bus $led_addr $led_port0_config $p0_val
# Get led value
led_st=$(i2cget -f -y $led_bus $led_addr $led_port0_output)
if [ "$1" == $on ]; then
led_st=$(("$led_st" | 1))
else
led_st=$(("$led_st" & ~1))
fi
# Turn on/off fan fault led
i2cset -f -y $led_bus $led_addr $led_port0_output $led_st
}
turn_on_off_psu_fault_led() {
# Control psu fault led via CPLD's I2C at slave address 0x22, I2C16.
# Get Port1 value
p1_val=$(i2cget -f -y $led_bus $led_addr $led_port0_config)
p1_val=$(("$p1_val" & ~2))
# Config CPLD's IOepx Port0[1] from input to output, clear IOepx Port0[1].
i2cset -f -y $led_bus $led_addr $led_port0_config $p1_val
# Get led value
led_st=$(i2cget -f -y $led_bus $led_addr $led_port0_output)
if [ "$1" == $on ]; then
led_st=$(("$led_st" | 2))
else
led_st=$(("$led_st" & ~2))
fi
# Turn on/off psu fault led
i2cset -f -y $led_bus $led_addr $led_port0_output $led_st
}
control_fan_fault_led() {
if [ "$fan_failed" == "true" ]; then
if [ "$fan_fault_led_status" == $off ]; then
turn_on_off_fan_fault_led $on
fan_fault_led_status=$on
fi
else
if [ "$fan_fault_led_status" == $on ]; then
turn_on_off_fan_fault_led $off
fan_fault_led_status=$off
fi
fi
}
check_psu_failed() {
local psu0_presence
local psu1_presence
local psu0_value
local psu1_value
psu0_presence=$(gpio_name_get presence-ps0)
psu0_failed="true"
if [ "$psu0_presence" == "0" ]; then
# PSU0 presence, monitor the PSUs using pmbus, check the STATUS_WORD
psu0_value=$(i2cget -f -y $psu_bus $psu0_addr $status_word_cmd w)
psu0_bit_fault=$(($psu0_value & $psu_fault_bitmask))
if [ "$psu0_bit_fault" == "0" ]; then
psu0_failed="false"
fi
fi
psu1_presence=$(gpio_name_get presence-ps1)
psu1_failed="true"
if [ "$psu1_presence" == "0" ]; then
# PSU1 presence, monitor the PSUs using pmbus, check the STATUS_WORD
psu1_value=$(i2cget -f -y $psu_bus $psu1_addr $status_word_cmd w)
psu1_bit_fault=$(($psu1_value & $psu_fault_bitmask))
if [ "$psu1_bit_fault" == "0" ]; then
psu1_failed="false"
fi
fi
if [ "$psu0_failed" == "true" ] || [ "$psu1_failed" == "true" ]; then
psu_failed="true"
else
psu_failed="false"
fi
}
control_psu_fault_led() {
if [ "$psu_failed" == "true" ]; then
if [ "$psu_fault_led_status" == $off ]; then
turn_on_off_psu_fault_led $on
psu_fault_led_status=$on
fi
else
if [ "$psu_fault_led_status" == $on ]; then
turn_on_off_psu_fault_led $off
psu_fault_led_status=$off
fi
fi
}
check_overtemp_occured() {
if [[ -f $overtemp_fault_flag ]]; then
echo "Over temperature occured, turn on fault LED"
overtemp_occured="true"
else
overtemp_occured="false"
fi
}
check_gpio_fault() {
if [[ -f $gpio_fault_flag ]]; then
echo "GPIO fault event(s) occured, turn on fault LED"
gpio_fault="true"
else
gpio_fault="false"
fi
}
check_fault() {
if [[ "$fan_failed" == "true" ]] || [[ "$psu_failed" == "true" ]] \
|| [[ "$overtemp_occured" == "true" ]] \
|| [[ "$gpio_fault" == "true" ]]; then
fault="true"
else
fault="false"
fi
}
# The System Fault Led turns on upon the system error, update the System Fault Led
# based on the Fan fault status and PSU fault status
control_sys_fault_led() {
# Turn on/off the System Fault Led
if [ "$fault" == "true" ]; then
gpio_name_set led-fault $on
else
gpio_name_set led-fault $off
fi
}
# daemon start
while true
do
# Monitors Fan speeds
check_fan_failed
# Monitors PSU presence
check_psu_failed
check_overtemp_occured
check_gpio_fault
# Check fault to update fail
check_fault
control_sys_fault_led
control_fan_fault_led
control_psu_fault_led
sleep 2
done
exit 1
@@ -0,0 +1,18 @@
SUMMARY = "Ampere Computing LLC Update MAC Address from FRU Inventory Information"
DESCRIPTION = "Update MAC Address from FRU Inventory Information for Ampere 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
DEPENDS = "systemd"
RDEPENDS:${PN} = "bash"
FILESEXTRAPATHS:append := "${THISDIR}/${PN}:"
SYSTEMD_SERVICE:${PN} = "ampere_update_mac.service"
@@ -0,0 +1,16 @@
[Unit]
Description=Updating MAC Address Service From FRU inventory
Requires=xyz.openbmc_project.EntityManager.service
After=xyz.openbmc_project.EntityManager.service
StartLimitInterval=25
StartLimitBurst=5
[Service]
ExecStart=/usr/sbin/ampere_update_mac.sh eth0 14 80
SyslogIdentifier=ampere_update_mac.sh
RemainAfterExit=yes
Restart=on-failure
RestartSec=5
[Install]
WantedBy={SYSTEMD_DEFAULT_TARGET}
@@ -0,0 +1,39 @@
SUMMARY = "Phosphor OpenBMC Platform Init Service"
DESCRIPTION = "Phosphor OpenBMC Platform Init 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://ampere-platform-init.service \
file://ampere-bmc-heartbeat.service \
file://ampere_platform_init.sh \
file://ampere_bmc_heartbeat.sh \
file://mtmitchell_platform_gpios_init.sh \
file://gpio-lib.sh \
file://ampere_uart_console_setup.sh \
file://ampere_uartmux_ctrl.sh \
"
SYSTEMD_PACKAGES = "${PN}"
SYSTEMD_SERVICE:${PN} = "ampere-platform-init.service ampere-bmc-heartbeat.service"
do_install () {
install -d ${D}${sbindir}
install -m 0755 ${WORKDIR}/gpio-lib.sh ${D}${sbindir}/
install -m 0755 ${WORKDIR}/ampere_platform_init.sh ${D}${sbindir}/
install -m 0755 ${WORKDIR}/ampere_bmc_heartbeat.sh ${D}${sbindir}/
install -m 0755 ${WORKDIR}/mtmitchell_platform_gpios_init.sh ${D}${sbindir}/platform_gpios_init.sh
install -m 0755 ${WORKDIR}/ampere_uart_console_setup.sh ${D}${sbindir}/
install -m 0755 ${WORKDIR}/ampere_uartmux_ctrl.sh ${D}/${sbindir}/
install -d ${D}${systemd_unitdir}/system/
install -m 0644 ${WORKDIR}/ampere-platform-init.service ${D}${systemd_unitdir}/system
}
@@ -0,0 +1,12 @@
[Unit]
Description=Ampere BMC heartbeat service
[Service]
Type=simple
Restart=always
ExecStart=/usr/sbin/ampere_bmc_heartbeat.sh
SyslogIdentifier = "ampere-bmc-heartbeat"
[Install]
WantedBy=multi-user.target
@@ -0,0 +1,11 @@
[Unit]
Description = Ampere Platform Initialization
[Service]
Restart=no
RemainAfterExit=true
Type=oneshot
ExecStart=/usr/sbin/ampere_platform_init.sh
[Install]
WantedBy=sysinit.target
@@ -0,0 +1,19 @@
#!/bin/bash
# shellcheck source=meta-ampere/meta-mitchell/recipes-ampere/platform/ampere-platform-init/gpio-lib.sh
source /usr/sbin/gpio-lib.sh
value=0
while true;
do
if [[ $value -eq 0 ]]; then
value=1
gpio_name_set led-sw-hb 1
gpio_name_set led-bmc-hb 0
else
value=0
gpio_name_set led-sw-hb 0
gpio_name_set led-bmc-hb 1
fi
sleep 1s
done
@@ -0,0 +1,52 @@
#!/bin/bash
# shellcheck source=meta-ampere/meta-mitchell/recipes-ampere/platform/ampere-platform-init/gpio-lib.sh
source /usr/sbin/gpio-lib.sh
# shellcheck source=meta-ampere/meta-mitchell/recipes-ampere/platform/ampere-platform-init/mtmitchell_platform_gpios_init.sh
source /usr/sbin/platform_gpios_init.sh
source /usr/sbin/ampere_uart_console_setup.sh
#pre platform init function. implemented in platform_gpios_init.sh
pre-platform-init
# =======================================================
# Setting default value for device sel and mux
bootstatus=$(cat /sys/class/watchdog/watchdog0/bootstatus)
if [ "$bootstatus" == '32' ]; then
echo "CONFIGURE: gpio pins to output high after AC power"
for gpioName in "${output_high_gpios_in_ac[@]}"; do
gpio_name_set "$gpioName" 1
done
echo "CONFIGURE: gpio pins to output low after AC power"
for gpioName in "${output_low_gpios_in_ac[@]}"; do
gpio_name_set "$gpioName" 0
done
echo "CONFIGURE: gpio pins to input after AC power"
for gpioName in "${input_gpios_in_ac[@]}"; do
gpio_name_input "$gpioName"
done
fi
# =======================================================
# Setting default value for others gpio pins
echo "CONFIGURE: gpio pins to output high"
for gpioName in "${output_high_gpios_in_bmc_reboot[@]}"; do
gpio_name_set "$gpioName" 1
done
echo "CONFIGURE: gpio pins to output low"
for gpioName in "${output_low_gpios_in_bmc_reboot[@]}"; do
gpio_name_set "$gpioName" 0
done
echo "CONFIGURE: gpio pins to input"
for gpioName in "${input_gpios_in_bmc_reboot[@]}"; do
gpio_name_input "$gpioName"
done
# =======================================================
# Setting uart muxes to BMC as default
uart_console_setup
#post platform init function. implemented in platform_gpios_init.sh
post-platform-init
exit 0
@@ -0,0 +1,47 @@
#!/bin/sh -e
# shellcheck disable=SC2039
# shellcheck disable=SC2112
# shellcheck disable=SC3010
# shellcheck disable=SC3030
# shellcheck disable=SC3054
export obmc_console_tty=("ttyS0" "ttyS1" "ttyS2" "ttyS3" "ttyS7" "ttyS8")
function get_uart_port()
{
tty=$1
case "${tty}" in
"ttyS0") uart=1
;;
"ttyS1") uart=2
;;
"ttyS2") uart=3
;;
"ttyS3") uart=4
;;
"ttyS7") uart=0
;;
"ttyS8") uart=0
;;
*) echo "Invalid tty passed to $0. Exiting!"
exit 1;
;;
esac
echo $uart
}
function uart_console_setup()
{
# Default the host routing through the mux to use the BMC (2)
# This allows the SoL console in webui, and the ssh port 2200, to work
# upon startup. If UART transcievers are installed on the header and required,
# this value should be set to 1
for tty in "${obmc_console_tty[@]}"; do
uart=$(get_uart_port "$tty")
if [ "${uart}" -ne 0 ]
then
/usr/sbin/ampere_uartmux_ctrl.sh "${uart}" 2
fi
done
}
@@ -0,0 +1,44 @@
#!/bin/bash
#
# shellcheck disable=SC2046
# This can be called to set uart mux manually
if [ $# -lt 2 ]; then
exit 1
fi
case "$1" in
1) GPIO_UARTx_MODE0="uart1-mode0"
GPIO_UARTx_MODE1="uart1-mode1"
;;
2) GPIO_UARTx_MODE0="uart2-mode0"
GPIO_UARTx_MODE1="uart2-mode1"
;;
3) GPIO_UARTx_MODE0="uart3-mode0"
GPIO_UARTx_MODE1="uart3-mode1"
;;
4) GPIO_UARTx_MODE0="uart4-mode0"
GPIO_UARTx_MODE1="uart4-mode1"
;;
*) echo "Invalid UART port selection"
exit 1
;;
esac
echo "Ampere UART MUX CTRL UART port $1 to mode $2"
case "$2" in
# To HDR
1) gpioset $(gpiofind "$GPIO_UARTx_MODE0")=1
gpioset $(gpiofind "$GPIO_UARTx_MODE1")=0
exit 0
;;
# To BMC
2) gpioset $(gpiofind "$GPIO_UARTx_MODE0")=0
gpioset $(gpiofind "$GPIO_UARTx_MODE1")=1
exit 0
;;
*) echo "Invalid UART mode selection"
exit 1
;;
esac
@@ -0,0 +1,69 @@
#!/bin/bash
# Configure GPIO as output and set its value
AST2600_GPIO_BASE=(
816
780
)
function gpio_configure_output() {
echo "$1" > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio"$1"/direction
echo "$2" > /sys/class/gpio/gpio"$1"/value
echo "$1" > /sys/class/gpio/unexport
}
function gpio_get_val() {
echo "$1" > /sys/class/gpio/export
cat /sys/class/gpio/gpio"$1"/value
echo "$1" > /sys/class/gpio/unexport
}
# Configure GPIO as input
function gpio_configure_input() {
echo "$1" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio"$1"/direction
echo "$1" > /sys/class/gpio/unexport
}
function gpio_name_set()
{
str=$(gpiofind "$1")
#Verify error code when run gpiofind
if [ "$?" == '1' ]; then
echo "Invalid gpio name $1"
else
gpioid=$(echo "$str"|cut -c 9)
offset=$(echo "$str"|cut -d " " -f 2)
gpioPin=$(("$offset" + ${AST2600_GPIO_BASE[$gpioid]}))
gpio_configure_output "$gpioPin" "$2"
fi
}
function gpio_name_get()
{
str=$(gpiofind "$1")
#Verify error code when run gpiofind
if [ "$?" == '1' ]; then
echo "Invalid gpio name $1"
else
offset=$(echo "$str"|cut -d " " -f 2)
gpioid=$(echo "$str"|cut -c 9)
gpioPin=$(("$offset" + ${AST2600_GPIO_BASE[$gpioid]}))
gpio_get_val "$gpioPin"
fi
}
function gpio_name_input()
{
str=$(gpiofind "$1")
#Verify error code when run gpiofind
if [ "$?" == '1' ]; then
echo "Invalid gpio name $1"
else
gpioid=$(echo "$str"|cut -c 9)
offset=$(echo "$str"|cut -d " " -f 2)
gpioPin=$(("$offset" + ${AST2600_GPIO_BASE[$gpioid]}))
gpio_configure_input "$gpioPin"
fi
}
@@ -0,0 +1,144 @@
#!/bin/bash
# shellcheck source=meta-ampere/meta-mitchell/recipes-ampere/platform/ampere-platform-init/gpio-lib.sh
source /usr/sbin/gpio-lib.sh
function bind_rtc_driver() {
# If rtc device can not present, bind the device
if [[ ! -e /dev/rtc0 ]]; then
echo "Bind rtc driver"
echo 6-0051 > /sys/bus/i2c/drivers/rtc-pcf85063/bind
fi
}
function pre-platform-init() {
echo "Do pre platform init"
}
function post-platform-init() {
# When BMC is rebooted, because PSON_L has pull up to P3V3_STB, it changes its
# value to HIGH. Add code to check P3V3_STB and recover PSON_L to correct state
# before setting BMC_RDY.
cnt=10
pgood=""
while [ $cnt -gt 0 ];
do
pgood=$(busctl get-property org.openbmc.control.Power /org/openbmc/control/power0 org.openbmc.control.Power pgood | cut -d' ' -f2)
if [[ "$pgood" != '' ]]; then
break;
fi
cnt=$(( cnt - 1 ))
sleep 1
done
if [ "$pgood" == '1' ]; then
echo "PSU is on. Setting PSON to 0"
gpio_name_set power-chassis-control 0
else
echo "pgood D-Bus property response as 0. PSU is off."
# for unknown reason when stress reboot bmc power-control.exe detect power-chassis-good is 1 (power on)
# But "busctl get-property org.openbmc.control.Power /org/openbmc/control/power0 org.openbmc.control.Power pgood" responses 0 (power off)
# Add sleep 3 seconds after the pgood dbus reponse (power off) and recheck the power-chassis-good to confirm about the PSU power state
sleep 3
pgood=$(gpio_name_get power-chassis-good)
if [ "$pgood" == '0' ]; then
echo "power-chassis-good reponse as 0. Confirm PSU is off. Setting PSON to 1."
gpio_name_set power-chassis-control 1
fi
fi
gpio_name_set host0-sysreset-n 1
# gpio-leds is controlling bmc-ready, not by gpio
echo 1 > /sys/class/leds/bmc-ready/brightness
echo "Set default FAN speed to 60%"
for filename in /sys/class/hwmon/*/pwm*
do
echo 153 > "$filename"
done
# Bind rtc driver
bind_rtc_driver
}
export output_high_gpios_in_ac=(
# add device enable, mux setting, device select gpios
"spi0-backup-sel"
"i2c-backup-sel"
)
export output_low_gpios_in_ac=(
# add device enable, mux setting, device select gpios
"spi0-program-sel"
"ocp-main-pwren"
)
export input_gpios_in_ac=(
# add device enable, mux setting, device select gpios
)
export output_high_gpios_in_bmc_reboot=(
"host0-sysreset-n"
"host0-pmin-n"
"bmc-debug-mode"
"vrd-sel"
"spd-sel"
"ext-high-temp-n"
"fpga-program-b"
"wd-disable-n"
"hpm-stby-rst-n"
"jtag-sel-s0"
"cpld-user-mode"
"jtag-srst-n"
"host0-shd-req-n"
)
export output_low_gpios_in_bmc_reboot=(
"rtc-battery-voltage-read-enable"
"s0-rtc-lock"
"hpm-fw-recovery"
"led-fault"
"spi-nor-access"
"host0-special-boot"
)
export input_gpios_in_bmc_reboot=(
"s0-vrd-fault-n"
"s1-vrd-fault-n"
"irq-n"
"presence-ps0"
"presence-ps1"
"hsc-12vmain-alt2-n"
"eth-phy-int-n"
"s0-pcp-oc-warn-n"
"s1-pcp-oc-warn-n"
"cpu-bios-recover"
"s0-heartbeat"
"hs-scout-proc-hot"
"s0-vr-hot-n"
"s1-vr-hot-n"
"hsc-12vmain-alt1-n"
"power-chassis-good"
"s0-ddr-save"
"soc-spi-nor-access"
"presence-cpu0"
"jtag-dbgr-prsnt-n"
"ps0-ac-loss-n"
"ps1-ac-loss-n"
"s1-ddr-save"
"sys-pgood"
"presence-cpu1"
"s0-fault-alert"
"s0-sys-auth-failure-n"
"host0-ready"
"ocp-pgood"
"s1-fault-alert"
"s1-fw-boot-ok"
"s0-spi-auth-fail-n"
"s1-sys-auth-failure-n"
"cpld-s1-spi-auth-fail-n"
"ps0-pgood"
"ps1-pgood"
"s0-soc-pgood"
)
@@ -0,0 +1,24 @@
FILESEXTRAPATHS:append := "${THISDIR}/${PN}:"
INSANE_SKIP:${PN} = "already-stripped"
SRC_URI:append = " \
file://ampere_power_util.sh \
file://ampere_firmware_upgrade.sh \
file://ampere_flash_bios.sh \
file://ampere_power_on_driver_binder.sh \
file://ampere_firmware_version.sh \
file://ampere_fanctrl.sh \
file://ampere_scandump_mode.sh \
"
do_install:append() {
install -d ${D}/usr/sbin
install -m 0755 ${WORKDIR}/ampere_power_util.sh ${D}/${sbindir}/
install -m 0755 ${WORKDIR}/ampere_firmware_upgrade.sh ${D}/${sbindir}/
install -m 0755 ${WORKDIR}/ampere_flash_bios.sh ${D}/${sbindir}/
install -m 0755 ${WORKDIR}/ampere_power_on_driver_binder.sh ${D}/${sbindir}/
install -m 0755 ${WORKDIR}/ampere_firmware_version.sh ${D}/${sbindir}/
install -m 0755 ${WORKDIR}/ampere_fanctrl.sh ${D}/${sbindir}/
install -m 0755 ${WORKDIR}/ampere_scandump_mode.sh ${D}/${sbindir}/
}
@@ -0,0 +1,168 @@
#!/bin/bash
fanSensorService="xyz.openbmc_project.FanSensor"
sensorPath="/xyz/openbmc_project/sensors/fan_tach/"
pwmTargetPath="/xyz/openbmc_project/control/fanpwm/"
sensorValueInterfaceName="xyz.openbmc_project.Sensor.Value"
sensorValuePropertyName="Value"
pwmTargetInterfaceName="xyz.openbmc_project.Control.FanPwm"
pwmTargetPropertyName="Target"
function stop_phosphor_fan_services() {
systemctl stop phosphor-fan-control@0.service
systemctl stop phosphor-fan-monitor@0.service
systemctl stop phosphor-fan-presence-tach@0.service
}
function start_phosphor_fan_services() {
systemctl start phosphor-fan-control@0.service
systemctl start phosphor-fan-monitor@0.service
systemctl start phosphor-fan-presence-tach@0.service
}
function read_speed() {
fan_val=$(busctl get-property "$fanSensorService" "${sensorPath}$1" "$sensorValueInterfaceName" "$sensorValuePropertyName")
busctl_error=$?
if (( busctl_error != 0 )); then
echo "Error: get-property $sensorValuePropertyName failed! "
exit 1
fi
pwm_target=$(busctl get-property "$fanSensorService" "${pwmTargetPath}$2" "$pwmTargetInterfaceName" "$pwmTargetPropertyName")
busctl_error=$?
if (( busctl_error != 0 )); then
echo "Error: get-property $pwmTargetPropertyName failed! "
exit 1
fi
fan_val=$(echo "$fan_val" | cut -d " " -f 2)
pwm_target=$(echo "$pwm_target" | cut -d " " -f 2)
# Convert fan PWM to Duty cycle, adding 127 for rounding.
pwm_duty_cyle=$(((("$pwm_target" * 100) + 127) / 255))
echo "$1, PWM: $pwm_target, Duty cycle: $pwm_duty_cyle%, Speed(RPM): $fan_val"
}
function set_pwm() {
# Convert Fan Duty cycle to PWM, adding 50 for rounding.
fan_pwm=$(((($2 * 255) + 50) / 100))
busctl set-property "$fanSensorService" "${pwmTargetPath}$1" "$pwmTargetInterfaceName" "$pwmTargetPropertyName" t "$fan_pwm"
busctl_error=$?
if (( busctl_error != 0 )); then
echo "Error: set-property $pwmTargetPropertyName failed! "
exit 255
fi
}
function getstatus() {
fan_ctl_stt=$(systemctl is-active phosphor-fan-control@0.service | grep inactive)
fan_monitor_stt=$(systemctl is-active phosphor-fan-monitor@0.service | grep inactive)
if [[ -z "$fan_ctl_stt" && -z "$fan_monitor_stt" ]]; then
echo "Thermal Control operational status: Enabled"
exit 0
else
echo "Thermal Control operational status: Disabled"
exit 1
fi
}
function setstatus() {
if [ "$1" == 0 ]; then
# Enable fan services
start_phosphor_fan_services
else
# Disable fan services
stop_phosphor_fan_services
fi
}
function setspeed() {
# Get fan_pwm value of the fan
case "$1" in
0) fan_pwm=PWM7
;;
1) fan_pwm=PWM5
;;
2) fan_pwm=PWM4
;;
3) fan_pwm=PWM3
;;
4) fan_pwm=PWM1
;;
5) fan_pwm=PWM0
;;
*) echo "fan $1 doesn't exit"
exit 1
;;
esac
set_pwm "$fan_pwm" "$2"
exit 0
}
function getspeed() {
# Mapping fan number to fan_input and fan_pwm index
case "$1" in
0) fan_input_f=FAN0_F
fan_input_r=FAN0_R
fan_pwm=PWM7
;;
1) fan_input_f=FAN1_F
fan_input_r=FAN1_R
fan_pwm=PWM5
;;
2) fan_input_f=FAN2_F
fan_input_r=FAN2_R
fan_pwm=PWM4
;;
3) fan_input_f=FAN3_F
fan_input_r=FAN3_R
fan_pwm=PWM3
;;
4) fan_input_f=FAN4_F
fan_input_r=FAN4_R
fan_pwm=PWM1
;;
5) fan_input_f=FAN5_F
fan_input_r=FAN5_F
fan_pwm=PWM0
;;
*) echo "fan $1 doesn't exit"
exit 1
;;
esac
# Get fan speed, each fan number has two values is front and rear
read_speed "$fan_input_f" "$fan_pwm"
read_speed "$fan_input_r" "$fan_pwm"
exit 0
}
# Usage of this utility
function usage() {
echo "Usage:"
echo " ampere_fanctrl.sh [getstatus] [setstatus <0|1>] [setspeed <fan> <duty>] [getspeed <fan>]"
echo " fan: 0-5"
echo " duty: 1-100"
}
if [ "$1" == "getstatus" ]; then
getstatus
elif [ "$1" == "setstatus" ]; then
setstatus "$2"
elif [ "$1" == "setspeed" ]; then
stop_phosphor_fan_services
setspeed "$2" "$3"
elif [ "$1" == "getspeed" ]; then
getspeed "$2"
else
usage
fi
@@ -0,0 +1,201 @@
#!/bin/bash
# Helper script to flash FRU and Boot EEPROM devices.
#
# Syntax for FRU:
# ampere_firmware_upgrade.sh fru <image> [<dev>]
# dev: 1 for MB FRU (default), 2 for BMC FRU.
#
# Syntax for EEPROM:
# ampere_firmware_upgrade.sh eeprom <image> [<dev>]
# dev: 1 for main Boot EEPROM (default), 2 for secondary Boot EEPROM (if supported)
#
# Syntax for Mainboard CPLD:
# ampere_firmware_upgrade.sh main_cpld <image>
#
# Syntax for BMC CPLD:
# ampere_firmware_upgrade.sh bmc_cpld <image>
#
# Syntax for Backplane CPLD:
# ampere_firmware_upgrade.sh bp_cpld <image> [<target>]
# target: 1 for Front Backplane 1
# 2 for Front Backplane 2
# 3 for Front Backplane 3
# 4 for Rear Backplane 1
# 5 for Rear Backplane 2
#
# shellcheck disable=SC2046
do_eeprom_flash() {
FIRMWARE_IMAGE=$IMAGE
BACKUP_SEL=$2
# Turn off the Host if it is currently ON
chassisstate=$(obmcutil chassisstate | awk -F. '{print $NF}')
echo "Current Chassis State: $chassisstate"
if [ "$chassisstate" == 'On' ];
then
echo "Turning the Chassis off"
obmcutil chassisoff
sleep 15
# Check if HOST was OFF
chassisstate_off=$(obmcutil chassisstate | awk -F. '{print $NF}')
if [ "$chassisstate_off" == 'On' ];
then
echo "Error : Failed turning the Chassis off"
exit 1
fi
fi
# Switch EEPROM control to BMC AST2600 I2C
# BMC_GPIOW6_SPI0_PROGRAM_SEL
gpioset $(gpiofind spi0-program-sel)=1
# BMC_GPIOX0_I2C_BACKUP_SEL (GPIO 184)
if [[ $BACKUP_SEL == 1 ]]; then
echo "Run update Primary EEPROM"
gpioset $(gpiofind i2c-backup-sel)=0
elif [[ $BACKUP_SEL == 2 ]]; then
echo "Run update Failover EEPROM"
gpioset $(gpiofind i2c-backup-sel)=1
else
echo "Please choose Primary EEPROM (1) or Failover EEPROM (2)"
exit 0
fi
# The EEPROM (AT24C64WI) with address 0x50 at BMC_I2C11 bus
# Write Firmware to EEPROM and read back for validation
ampere_eeprom_prog -b 10 -s 0x50 -p -f "$FIRMWARE_IMAGE"
# Switch to primary EEPROM
gpioset $(gpiofind i2c-backup-sel)=0
# Switch EEPROM control to CPU HOST
gpioset $(gpiofind spi0-program-sel)=0
if [ "$chassisstate" == 'On' ];
then
sleep 5
echo "Turn on the Host"
obmcutil poweron
fi
}
do_fru_flash() {
FRU_IMAGE=$1
FRU_DEV=$2
if [[ $FRU_DEV == 1 ]]; then
if [ -f /sys/bus/i2c/devices/4-0050/eeprom ]; then
FRU_DEVICE="/sys/bus/i2c/devices/4-0050/eeprom"
else
FRU_DEVICE="/sys/bus/i2c/devices/3-0050/eeprom"
fi
echo "Flash MB FRU with image $IMAGE at $FRU_DEVICE"
elif [[ $FRU_DEV == 2 ]]; then
FRU_DEVICE="/sys/bus/i2c/devices/14-0050/eeprom"
echo "Flash BMC FRU with image $IMAGE at $FRU_DEVICE"
else
echo "Please select MB FRU (1) or BMC FRU (2)"
exit 0
fi
ampere_fru_upgrade -d "$FRU_DEVICE" -f "$FRU_IMAGE"
systemctl restart xyz.openbmc_project.FruDevice.service
systemctl restart phosphor-ipmi-host.service
echo "Done"
}
do_mb_cpld_flash() {
MB_CPLD_IMAGE=$1
echo "Flashing MB CPLD"
gpioset $(gpiofind hpm-fw-recovery)=1
gpioset $(gpiofind jtag-program-sel)=1
sleep 2
ampere_cpldupdate_jtag -t 1 -p "$MB_CPLD_IMAGE"
gpioset $(gpiofind hpm-fw-recovery)=0
echo "Done"
}
do_bmc_cpld_flash() {
BMC_CPLD_IMAGE=$1
echo "Flashing BMC CPLD"
gpioset $(gpiofind jtag-program-sel)=0
sleep 2
ampere_cpldupdate_jtag -t 1 -p "$BMC_CPLD_IMAGE"
echo "Done"
}
do_bp_cpld_flash() {
BP_CPLD_IMAGE=$1
BP_TARGET=$2
if [[ $BP_TARGET == 1 ]]; then
echo "Flashing Front Backplane 1 CPLD"
ampere_cpldupdate_i2c -b 101 -s 0x40 -t 3 -p "$BP_CPLD_IMAGE"
elif [[ $BP_TARGET == 2 ]]; then
echo "Flashing Front Backplane 2 CPLD"
ampere_cpldupdate_i2c -b 102 -s 0x40 -t 3 -p "$BP_CPLD_IMAGE"
elif [[ $BP_TARGET == 3 ]]; then
echo "Flashing Front Backplane 3 CPLD"
ampere_cpldupdate_i2c -b 100 -s 0x40 -t 3 -p "$BP_CPLD_IMAGE"
elif [[ $BP_TARGET == 4 ]]; then
echo "Flashing Rear Backplane 1 CPLD"
ampere_cpldupdate_i2c -b 103 -s 0x40 -t 3 -p "$BP_CPLD_IMAGE"
elif [[ $BP_TARGET == 5 ]]; then
echo "Flashing Rear Backplane 2 CPLD"
ampere_cpldupdate_i2c -b 104 -s 0x40 -t 3 -p "$BP_CPLD_IMAGE"
fi
echo "Done"
}
if [ $# -eq 0 ]; then
echo "Usage:"
echo " - Flash Boot EEPROM"
echo " $(basename "$0") eeprom <Image file>"
echo " - Flash FRU"
echo " $(basename "$0") fru <Image file> [dev]"
echo " Where:"
echo " dev: 1 - MB FRU, 2 - BMC FRU"
echo " - Flash Mainboard CPLD"
echo " $(basename "$0") mb_cpld <Image file>"
echo " - Flash BMC CPLD (only for DC-SCM BMC board)"
echo " $(basename "$0") bmc_cpld <Image file>"
echo " - Flash Backplane CPLD"
echo " $(basename "$0") bp_cpld <Image file> <Target> "
echo " Where:"
echo " Target: 1 - FrontBP1, 2 - FrontBP2, 3 - FrontBP3"
echo " 4 - RearBP1, 5 - RearBP2"
exit 0
fi
TYPE=$1
IMAGE=$2
TARGET=$3
if [ -z "$3" ]; then
BACKUP_SEL=1
else
BACKUP_SEL=$3
fi
if [[ $TYPE == "eeprom" ]]; then
# Run EEPROM update: write/read/validation with CRC32 checksum
do_eeprom_flash "$IMAGE" "$BACKUP_SEL"
elif [[ $TYPE == "fru" ]]; then
# Run FRU update
do_fru_flash "$IMAGE" "$BACKUP_SEL"
elif [[ $TYPE == "mb_cpld" ]]; then
# Run Mainboard CPLD update
do_mb_cpld_flash "$IMAGE"
elif [[ $TYPE == "bmc_cpld" ]]; then
# Run CPLD BMC update
do_bmc_cpld_flash "$IMAGE"
elif [[ $TYPE == "bp_cpld" ]]; then
# Run Backplane CPLD update
do_bp_cpld_flash "$IMAGE" "$TARGET"
fi
exit 0
@@ -0,0 +1,99 @@
#!/bin/bash
# Helper script to report firmware version for components on the system (MB CPLD, Backplane CPLD, …)
# Author : Hieu Huynh (hieu.huynh@amperecomputing.com)
#
# Get MB CPLD firmware revision:
# ampere_firmware_version.sh mb_cpld
#
# Get BMC CPLD firmware revision:
# ampere_firmware_version.sh bmc_cpld
#
# Get Backplane CPLD firmware revision:
# ampere_firmware_version.sh bp_cpld <id>
# <id>: 1 for Front Backplane 1
# 2 for Front Backplane 2
# 3 for Front Backplane 3
# 4 for Rear Backplane 1
# 5 for Rear Backplane 2
# shellcheck disable=SC2046
do_mb_cpld_firmware_report() {
echo "MB CPLD"
gpioset $(gpiofind hpm-fw-recovery)=1
gpioset $(gpiofind jtag-program-sel)=1
sleep 1
ampere_cpldupdate_jtag -v
ampere_cpldupdate_jtag -i
}
do_bmc_cpld_firmware_report() {
echo "BMC CPLD (Only for DC-SCM board)"
gpioset $(gpiofind jtag-program-sel)=0
sleep 1
ampere_cpldupdate_jtag -v
ampere_cpldupdate_jtag -i
}
do_bp_cpld_firmware_report() {
BP_ID=$1
if [[ $BP_ID == 1 ]]; then
echo "Front Backplane 1 CPLD"
ampere_cpldupdate_i2c -b 101 -s 0x40 -t 3 -v
ampere_cpldupdate_i2c -b 101 -s 0x40 -t 3 -i
elif [[ $BP_ID == 2 ]]; then
echo "Front Backplane 2 CPLD"
ampere_cpldupdate_i2c -b 102 -s 0x40 -t 3 -v
ampere_cpldupdate_i2c -b 102 -s 0x40 -t 3 -i
elif [[ $BP_ID == 3 ]]; then
echo "Front Backplane 3 CPLD"
ampere_cpldupdate_i2c -b 100 -s 0x40 -t 3 -v
ampere_cpldupdate_i2c -b 100 -s 0x40 -t 3 -i
elif [[ $BP_ID == 4 ]]; then
echo "Rear Backplane 1 CPLD"
ampere_cpldupdate_i2c -b 103 -s 0x40 -t 3 -v
ampere_cpldupdate_i2c -b 103 -s 0x40 -t 3 -i
elif [[ $BP_ID == 5 ]]; then
echo "Rear Backplane 2 CPLD"
ampere_cpldupdate_i2c -b 104 -s 0x40 -t 3 -v
ampere_cpldupdate_i2c -b 104 -s 0x40 -t 3 -i
fi
}
if [ $# -eq 0 ]; then
echo "Usage:"
echo " - Get MB CPLD firmware revision"
echo " $(basename "$0") mb_cpld"
echo " - Get BMC CPLD firmware revision"
echo " $(basename "$0") bmc_cpld"
echo " - Get Backplane CPLD firmware revision"
echo " $(basename "$0") bp_cpld <id>"
echo " <id>:"
echo " 1 - FrontBP1"
echo " 2 - FrontBP2"
echo " 3 - FrontBP3"
echo " 4 - RearBP1"
echo " 5 - RearBP2"
exit 0
fi
TYPE=$1
ID=$2
if [[ $TYPE == "mb_cpld" ]]; then
do_mb_cpld_firmware_report
elif [[ $TYPE == "bmc_cpld" ]]; then
do_bmc_cpld_firmware_report
elif [[ $TYPE == "bp_cpld" ]]; then
if [ -z "$ID" ]; then
echo "Please choose backplanes id: 1 - FrontBP1, 2 - FrontBP2, 3 - FrontBP3, 4 - FrontBP4, 5 - FrontBP5"
exit 0
elif [[ "$ID" -ge "1" ]] && [[ "$ID" -le "5" ]]; then
do_bp_cpld_firmware_report "$ID"
else
echo "Backplanes id invalid"
fi
fi
exit 0
@@ -0,0 +1,162 @@
#!/bin/bash
# This script is used to flash the UEFI/EDKII
# Syntax: ampere_flash_bios.sh $image_file $device_sellect
# Where:
# $image_file : the image binary file
# $device_sellect : 1 - Host Main SPI Nor
# 2 - Host Second SPI Nor
# Author : Chanh Nguyen (chnguyen@amperecomputing.com)
# Note:
# BMC_GPIOW6_SPI0_PROGRAM_SEL (GPIO 182): 1 => BMC owns SPI bus for upgrading
# 0 => HOST owns SPI bus for upgrading
# BMC_GPIOW7_SPI0_BACKUP_SEL (GPIO 183) : 1 => to switch SPI_CS0_L to primary SPI Nor device
# 0 => to switch SPI_CS0_L to second SPI Nor device
# shellcheck disable=SC2046
do_flash () {
# Check the HNOR partition available
HOST_MTD=$(< /proc/mtd grep "pnor" | sed -n 's/^\(.*\):.*/\1/p')
if [ -z "$HOST_MTD" ];
then
# Check the ASpeed SMC driver binded before
HOST_SPI=/sys/bus/platform/drivers/spi-aspeed-smc/1e630000.spi
if [ -d "$HOST_SPI" ]; then
echo "Unbind the ASpeed SMC driver"
echo 1e630000.spi > /sys/bus/platform/drivers/spi-aspeed-smc/unbind
sleep 2
fi
# If the HNOR partition is not available, then bind again driver
echo "--- Bind the ASpeed SMC driver"
echo 1e630000.spi > /sys/bus/platform/drivers/spi-aspeed-smc/bind
sleep 2
HOST_MTD=$(< /proc/mtd grep "pnor" | sed -n 's/^\(.*\):.*/\1/p')
if [ -z "$HOST_MTD" ];
then
echo "Fail to probe Host SPI-NOR device"
exit 1
fi
fi
echo "--- Flashing firmware image $IMAGE to @/dev/$HOST_MTD"
flashcp -v "$IMAGE" /dev/"$HOST_MTD"
}
if [ $# -eq 0 ]; then
echo "Usage: $(basename "$0") <UEFI/EDKII image file> <DEV_SEL> [SPECIAL_BOOT]"
echo "Where:"
echo " DEV_SEL 1 is Primary SPI (by default), 2 is Second SPI"
echo " SPECIAL_BOOT: Optional, input '1' to enter & flash SPECIAL_BOOT mode. Default: 0"
exit 0
fi
IMAGE="$1"
if [ ! -f "$IMAGE" ]; then
echo "The image file $IMAGE does not exist"
exit 1
fi
if [ -z "$2" ]; then
DEV_SEL="1" # by default, select primary device
else
DEV_SEL="$2"
fi
SPECIAL_BOOT=0
if [[ "$3" == "1" ]]; then
SPECIAL_BOOT=1
fi
echo "SPECIAL_BOOT mode: $SPECIAL_BOOT"
# Turn off the Host if it is currently ON
chassisstate=$(obmcutil chassisstate | awk -F. '{print $NF}')
echo "--- Current Chassis State: $chassisstate"
if [ "$chassisstate" == 'On' ];
then
echo "--- Turning the Chassis off"
obmcutil chassisoff
sleep 10
# Check if HOST was OFF
chassisstate_off=$(obmcutil chassisstate | awk -F. '{print $NF}')
if [ "$chassisstate_off" == 'On' ];
then
echo "--- Error : Failed turning the Chassis off"
exit 1
fi
fi
# Switch the host SPI bus to BMC"
echo "--- Switch the host SPI bus to BMC."
if ! gpioset $(gpiofind spi0-program-sel)=1; then
echo "ERROR: Switch the host SPI bus to BMC. Please check gpio state"
exit 1
fi
# Switch the host SPI bus (between primary and secondary)
# 183 is BMC_GPIOW7_SPI0_BACKUP_SEL
if [[ $DEV_SEL == 1 ]]; then
echo "Run update Primary Host SPI-NOR"
gpioset $(gpiofind spi0-backup-sel)=1 # Primary SPI
elif [[ $DEV_SEL == 2 ]]; then
echo "Run update Second Host SPI-NOR"
gpioset $(gpiofind spi0-backup-sel)=0 # Second SPI
else
echo "Please choose primary SPI (1) or second SPI (2)"
exit 0
fi
# Restrict to flash Second Host SPI-NOR in case of SPECIAL_BOOT
if [ $SPECIAL_BOOT == 1 ] && [ "$DEV_SEL" == 2 ]; then
echo "Not allow to flash the Second Host SPI-NOR with SPECIAL_BOOT image"
exit
fi
# Flash the firmware
do_flash
# Assert SPECIAL_BOOT GPIO PIN
if [[ $SPECIAL_BOOT == 1 ]]; then
gpioset $(gpiofind host0-special-boot)=1
fi
# Switch the SPI bus to the primary spi device
echo "Switch to the Primary Host SPI-NOR"
gpioset $(gpiofind spi0-backup-sel)=1 # Primary SPI
# Switch the host SPI bus to HOST."
echo "--- Switch the host SPI bus to HOST."
if ! gpioset $(gpiofind spi0-program-sel)=0; then
echo "ERROR: Switch the host SPI bus to HOST. Please check gpio state"
exit 1
fi
if [ "$chassisstate" == 'On' ] || [ $SPECIAL_BOOT == 1 ];
then
sleep 5
echo "Turn on the Host"
obmcutil poweron
fi
# Deassert SPECIAL_BOOT GPIO PIN if it is being asserted
if [[ $SPECIAL_BOOT == 1 ]]; then
# Time out checking for Host ON is 60s
cnt=12
while [ "$cnt" -gt 0 ];
do
cnt=$((cnt - 1))
if systemctl status obmc-host-already-on@0.target | grep "Active: active"; then
echo "Deassert SPECIAL_BOOT GPIO PIN if it is being asserted."
gpioset $(gpiofind host0-special-boot)=0
exit 0
fi
sleep 5
done
fi
@@ -0,0 +1,50 @@
#!/bin/bash
# Each driver include driver name and driver path
declare -a DRIVER_NAMEs=(
"107-0070"
"100-0071"
"101-0071"
"102-0071"
"103-0071"
"104-0071"
"100-0050"
"101-0050"
"102-0050"
"100-004c"
"101-004c"
"102-004c"
)
# Driver path should include / at the end
declare -a DRIVER_PATHs=(
"/sys/bus/i2c/drivers/pca954x/"
"/sys/bus/i2c/drivers/pca954x/"
"/sys/bus/i2c/drivers/pca954x/"
"/sys/bus/i2c/drivers/pca954x/"
"/sys/bus/i2c/drivers/pca954x/"
"/sys/bus/i2c/drivers/pca954x/"
"/sys/bus/i2c/drivers/at24/"
"/sys/bus/i2c/drivers/at24/"
"/sys/bus/i2c/drivers/at24/"
"/sys/bus/i2c/drivers/lm75/"
"/sys/bus/i2c/drivers/lm75/"
"/sys/bus/i2c/drivers/lm75/"
)
# get length of an array
arraylength=${#DRIVER_NAMEs[@]}
# use for loop to read all values and indexes
for (( i=0; i<"${arraylength}"; i++ ));
do
bindFile="${DRIVER_PATHs[$i]}bind"
driverDir="${DRIVER_PATHs[$i]}${DRIVER_NAMEs[$i]}"
echo "binding ${DRIVER_NAMEs[$i]} path ${DRIVER_PATHs[$i]} on Chassi Power On"
if [ -d "$driverDir" ]; then
echo "Driver ${DRIVER_NAMEs[$i]} is already bound."
else
echo "${DRIVER_NAMEs[$i]}" > "$bindFile"
fi
done
exit 0
@@ -0,0 +1,131 @@
#!/bin/bash
# shellcheck source=meta-ampere/meta-mitchell/recipes-ampere/platform/ampere-platform-init/gpio-lib.sh
source /usr/sbin/gpio-lib.sh
# Usage of this utility
function usage() {
echo "usage: power-util mb [status|shutdown_ack|force_reset|soft_off|host_reboot_wa]";
}
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
gpio_name_set host0-shd-req-n 0
sleep 0.05
gpio_name_set host0-shd-req-n 1
# 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
rm -f /run/openbmc/host@0-on
echo "Triggering sysreset pin"
gpio_name_set host0-sysreset-n 0
sleep 1
gpio_name_set host0-sysreset-n 1
}
host_reboot_wa() {
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"
while ( true )
do
if systemctl status obmc-power-off@0.target | grep "Active: active"; then
break;
fi
sleep 2
done
echo "The power is already Off."
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.On"
}
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" == "host_reboot_wa" ]; then
host_reboot_wa
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;
@@ -0,0 +1,94 @@
#!/bin/bash
# Helper script to support enable/disable Scandump Mode
# Author : Hieu Huynh (hieu.huynh@amperecomputing.com)
#
# To enable Scandump mode:
# ampere_scandump_mode.sh enable
#
# To disable Scandump mode:
# ampere_scandump_mode.sh disable
#
# To get Scandump mode status:
# ampere_scandump_mode.sh getstatus
enable_scandump_mode() {
echo "Enable Scandump mode"
# Disable Mpro hang detection
systemctl stop ampere-sysfw-hang-handler.service
# Disable PLDM service
systemctl stop pldmd.service
# Enable scandump mode in CPLD
# Get Port0 value
p0_val=$(i2cget -f -y 15 0x22 0x02)
p0_val=$(("$p0_val" | (1 << 4)))
# Set Port0[4] value to "1" to mask all CPUs GPIOs, set Port0[4].
i2cset -f -y 15 0x22 0x02 $p0_val
p0_IOexp_val=$(i2cget -f -y 15 0x22 0x06)
p0_IOexp_val=$(("$p0_IOexp_val" & ~(1 << 4)))
# Config CPLD's IOepx Port0[4] from input to output, clear IOepx Port0[4].
i2cset -f -y 15 0x22 0x06 $p0_IOexp_val
}
diable_scandump_mode() {
echo "Disable Scandump mode"
# Disable scandump mode in CPLD
# Get Port0 value
p0_val=$(i2cget -f -y 15 0x22 0x02)
p0_val=$(("$p0_val" & ~(1 << 4)))
# Set Port0[4] value to "0" to unmask all CPUs GPIOs, clear Port0[4].
i2cset -f -y 15 0x22 0x02 $p0_val
p0_IOexp_val=$(i2cget -f -y 15 0x22 0x06)
p0_IOexp_val=$(("$p0_IOexp_val" | (1 << 4)))
# Config CPLD's IOepx Port0[4] from output to input, set IOepx Port0[4].
i2cset -f -y 15 0x22 0x06 $p0_IOexp_val
# Enable Mpro hang detection
systemctl start ampere-sysfw-hang-handler.service
# Enable PLDM service
systemctl start pldmd.service
}
getstatus() {
# Get CPLD's IOepx Port0[4], if this bit is "0" scandump mode is enabled.
p0_IOexp_val=$(i2cget -f -y 15 0x22 0x06)
p0_IOexp_val=$(("$p0_IOexp_val" & (1 << 4)))
if [[ "$p0_IOexp_val" == "0" ]]; then
echo "Scandump mode is enabled"
exit 1
else
echo "Scandump mode is disabled"
exit 0
fi
}
# Usage of this utility
usage() {
echo "Usage:"
echo " - To enable Scandump mode"
echo " $(basename "$0") enable"
echo " - To disable Scandump mode"
echo " $(basename "$0") disable"
echo " - To get Scandump mode status"
echo " $(basename "$0") getstatus"
exit 0
}
if [[ $1 == "enable" ]]; then
enable_scandump_mode
elif [[ $1 == "disable" ]]; then
diable_scandump_mode
elif [[ $1 == "getstatus" ]]; then
getstatus
else
echo "Invalid mode"
usage
fi
exit 0
@@ -0,0 +1,2 @@
CONFIG_PHY_NCSI=n
@@ -0,0 +1,5 @@
FILESEXTRAPATHS:append := "${THISDIR}/${PN}:"
SRC_URI += " \
file://ampere.cfg \
"
@@ -0,0 +1,45 @@
#
# BOM
#
CONFIG_RTC_DRV_PCF85063=y
CONFIG_IIO_MUX=y
CONFIG_MUX_GPIO=y
CONFIG_I2C_MUX=y
CONFIG_SENSORS_IIO_HWMON=y
CONFIG_ASPEED_ADC=y
CONFIG_SENSORS_LM75=y
CONFIG_SENSORS_EMC1403=y
CONFIG_LTC2497=y
CONFIG_I2C_SLAVE=y
CONFIG_SENSORS_ASPEED=y
CONFIG_USB_PHY=y
CONFIG_USB_GADGET=y
CONFIG_USB_CONFIGFS=y
CONFIG_USB_ASPEED_VHUB=y
CONFIG_USB_CONFIGFS_ECM=y
CONFIG_SERIAL_8250_NR_UARTS=10
CONFIG_SERIAL_8250_RUNTIME_UARTS=10
CONFIG_HWMON=y
CONFIG_PWM=y
CONFIG_PWM_SYSFS=y
CONFIG_SENSORS_PWM_FAN=y
CONFIG_SENSORS_ASPEED=y
CONFIG_SSIF_IPMI_BMC=y
CONFIG_REGULATOR_FIXED_VOLTAGE=y
CONFIG_REGULATOR=y
CONFIG_SENSORS_MAX31790=y
CONFIG_NET_NCSI=y
CONFIG_NCSI_OEM_CMD_GET_MAC=y
CONFIG_NETWORK_FILESYSTEMS=y
CONFIG_CIFS=y
CONFIG_CIFS_XATTR=y
@@ -0,0 +1,5 @@
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
SRC_URI += " \
file://ampere.cfg \
"
@@ -0,0 +1,26 @@
SUMMARY = "YAML configuration for Mt Mitchell"
PR = "r1"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
inherit allarch
SRC_URI = " \
file://mtmitchell-ipmi-sensors.yaml \
file://mtmitchell-ipmi-fru.yaml \
"
S = "${WORKDIR}"
do_install() {
install -m 0644 -D mtmitchell-ipmi-sensors.yaml \
${D}${datadir}/${BPN}/ipmi-sensors.yaml
install -m 0644 -D mtmitchell-ipmi-fru.yaml \
${D}${datadir}/${BPN}/ipmi-fru-read.yaml
}
FILES:${PN}-dev = " \
${datadir}/${BPN}/ipmi-sensors.yaml \
${datadir}/${BPN}/ipmi-fru-read.yaml \
"
ALLOW_EMPTY:${PN} = "1"
@@ -0,0 +1,551 @@
1: &TEMP_DEFAULTS
bExp: 0
entityID: 0x7
entityInstance: 1
interfaces:
xyz.openbmc_project.Sensor.Value:
Value:
Offsets:
255:
type: double
multiplierM: 1
mutability: Mutability::Write|Mutability::Read
offsetB: 0
path: /xyz/openbmc_project/sensors/temperature/OutletTemp
rExp: 0
readingType: readingData
sensorNamePattern: nameLeaf
sensorReadingType: 1
sensorType: 1
serviceInterface: org.freedesktop.DBus.Properties
unit: xyz.openbmc_project.Sensor.Value.Unit.DegreesC
2:
<<: *TEMP_DEFAULTS
entityInstance: 2
path: /xyz/openbmc_project/sensors/temperature/Psu1InletTemp2
3:
<<: *TEMP_DEFAULTS
entityInstance: 3
path: /xyz/openbmc_project/sensors/temperature/PcieZoneTemp1
4:
<<: *TEMP_DEFAULTS
entityInstance: 4
path: /xyz/openbmc_project/sensors/temperature/Psu0InletTemp2
5:
<<: *TEMP_DEFAULTS
entityInstance: 5
path: /xyz/openbmc_project/sensors/temperature/PcieZoneTemp2
7:
<<: *TEMP_DEFAULTS
entityID: 0x37
entityInstance: 1
path: /xyz/openbmc_project/sensors/temperature/SysCabInletTemp
8:
<<: *TEMP_DEFAULTS
entityID: 0x40
entityInstance: 1
path: /xyz/openbmc_project/sensors/temperature/MBInletTemp1
9:
<<: *TEMP_DEFAULTS
entityID: 0x40
entityInstance: 2
path: /xyz/openbmc_project/sensors/temperature/MBInletTemp2
10:
<<: *TEMP_DEFAULTS
entityID: 0x42
entityInstance: 1
path: /xyz/openbmc_project/sensors/temperature/AST2600CPUTemp
11:
<<: *TEMP_DEFAULTS
entityID: 0x1e
entityInstance: 1
path: /xyz/openbmc_project/sensors/temperature/NVMeM2_MaxTemp
16:
<<: *TEMP_DEFAULTS
entityID: 0x1e
entityInstance: 6
path: /xyz/openbmc_project/sensors/temperature/OCP_MaxTemp
17: &FAN_DEFAULTS
entityID: 29
entityInstance: 1
sensorType: 4
path: /xyz/openbmc_project/sensors/fan_tach/FAN0_F
sensorReadingType: 1
multiplierM: 100
offsetB: 0
rExp: 0
unit: xyz.openbmc_project.Sensor.Value.Unit.RPMS
mutability: Mutability::Write|Mutability::Read
serviceInterface: org.freedesktop.DBus.Properties
readingType: readingData
sensorNamePattern: nameLeaf
interfaces:
xyz.openbmc_project.Sensor.Value:
Value:
Offsets:
0x0:
type: double
18:
<<: *FAN_DEFAULTS
entityInstance: 2
path: /xyz/openbmc_project/sensors/fan_tach/FAN0_R
19:
<<: *FAN_DEFAULTS
entityInstance: 3
path: /xyz/openbmc_project/sensors/fan_tach/FAN1_F
20:
<<: *FAN_DEFAULTS
entityInstance: 4
path: /xyz/openbmc_project/sensors/fan_tach/FAN1_R
21:
<<: *FAN_DEFAULTS
entityInstance: 5
path: /xyz/openbmc_project/sensors/fan_tach/FAN2_F
22:
<<: *FAN_DEFAULTS
entityInstance: 6
path: /xyz/openbmc_project/sensors/fan_tach/FAN2_R
23:
<<: *FAN_DEFAULTS
entityInstance: 7
path: /xyz/openbmc_project/sensors/fan_tach/FAN3_F
24:
<<: *FAN_DEFAULTS
entityInstance: 8
path: /xyz/openbmc_project/sensors/fan_tach/FAN3_R
25:
<<: *FAN_DEFAULTS
entityInstance: 9
path: /xyz/openbmc_project/sensors/fan_tach/FAN4_F
26:
<<: *FAN_DEFAULTS
entityInstance: 10
path: /xyz/openbmc_project/sensors/fan_tach/FAN4_R
27:
<<: *FAN_DEFAULTS
entityInstance: 11
path: /xyz/openbmc_project/sensors/fan_tach/FAN5_F
28:
<<: *FAN_DEFAULTS
entityInstance: 12
path: /xyz/openbmc_project/sensors/fan_tach/FAN5_R
57: &VOLTAGE_DEFAULTS
entityID: 0x13
entityInstance: 1
sensorType: 0x02
path: /xyz/openbmc_project/sensors/voltage/S0_0V8_D2D
sensorReadingType: 0x01
multiplierM: 5
offsetB: 0
bExp: 0
unit: xyz.openbmc_project.Sensor.Value.Unit.Volts
rExp: -3
serviceInterface: org.freedesktop.DBus.Properties
readingType: readingData
interfaces:
xyz.openbmc_project.Sensor.Value:
Value:
Offsets:
0xFF:
type: double
58:
<<: *VOLTAGE_DEFAULTS
entityInstance: 2
multiplierM: 5
path: /xyz/openbmc_project/sensors/voltage/S0_0V85_SOC
59:
<<: *VOLTAGE_DEFAULTS
entityInstance: 3
multiplierM: 5
path: /xyz/openbmc_project/sensors/voltage/S0_0V85_RC_DDR0
60:
<<: *VOLTAGE_DEFAULTS
entityInstance: 4
multiplierM: 5
path: /xyz/openbmc_project/sensors/voltage/S0_0V85_RC_DDR1
61:
<<: *VOLTAGE_DEFAULTS
entityInstance: 5
multiplierM: 5
path: /xyz/openbmc_project/sensors/voltage/S0_0V9_RC5A
62:
<<: *VOLTAGE_DEFAULTS
entityInstance: 6
multiplierM: 10
path: /xyz/openbmc_project/sensors/voltage/S0_1V8_RC5A
63:
<<: *VOLTAGE_DEFAULTS
entityInstance: 7
multiplierM: 7
path: /xyz/openbmc_project/sensors/voltage/S0_0V75_PCP
64:
<<: *VOLTAGE_DEFAULTS
entityInstance: 8
multiplierM: 6
path: /xyz/openbmc_project/sensors/voltage/S0_1V1_VDDQ0123
65:
<<: *VOLTAGE_DEFAULTS
entityInstance: 9
multiplierM: 6
path: /xyz/openbmc_project/sensors/voltage/S0_1V1_VDDQ4567
66:
<<: *VOLTAGE_DEFAULTS
entityInstance: 10
multiplierM: 10
path: /xyz/openbmc_project/sensors/voltage/S0_1V8_SOC
67:
<<: *VOLTAGE_DEFAULTS
entityInstance: 11
multiplierM: 8
path: /xyz/openbmc_project/sensors/voltage/S0_1V2_SOC
68:
<<: *VOLTAGE_DEFAULTS
entityInstance: 12
multiplierM: 5
path: /xyz/openbmc_project/sensors/voltage/S0_EXT_VREF
69:
<<: *VOLTAGE_DEFAULTS
entityInstance: 13
multiplierM: 5
path: /xyz/openbmc_project/sensors/voltage/S1_0V8_D2D
70:
<<: *VOLTAGE_DEFAULTS
entityInstance: 14
multiplierM: 5
path: /xyz/openbmc_project/sensors/voltage/S1_0V85_SOC
71:
<<: *VOLTAGE_DEFAULTS
entityInstance: 15
multiplierM: 5
path: /xyz/openbmc_project/sensors/voltage/S1_0V85_RC_DDR0
72:
<<: *VOLTAGE_DEFAULTS
entityInstance: 16
multiplierM: 5
path: /xyz/openbmc_project/sensors/voltage/S1_0V85_RC_DDR1
73:
<<: *VOLTAGE_DEFAULTS
entityInstance: 17
multiplierM: 5
path: /xyz/openbmc_project/sensors/voltage/S1_0V9_RC5A
74:
<<: *VOLTAGE_DEFAULTS
entityInstance: 18
multiplierM: 10
path: /xyz/openbmc_project/sensors/voltage/S1_1V8_RC5A
75:
<<: *VOLTAGE_DEFAULTS
entityInstance: 19
multiplierM: 7
path: /xyz/openbmc_project/sensors/voltage/S1_0V75_PCP
76:
<<: *VOLTAGE_DEFAULTS
entityInstance: 20
multiplierM: 6
path: /xyz/openbmc_project/sensors/voltage/S1_1V1_VDDQ0123
77:
<<: *VOLTAGE_DEFAULTS
entityInstance: 21
multiplierM: 6
path: /xyz/openbmc_project/sensors/voltage/S1_1V1_VDDQ4567
78:
<<: *VOLTAGE_DEFAULTS
entityInstance: 22
multiplierM: 10
path: /xyz/openbmc_project/sensors/voltage/S1_1V8_SOC
79:
<<: *VOLTAGE_DEFAULTS
entityInstance: 23
multiplierM: 8
path: /xyz/openbmc_project/sensors/voltage/S1_1V2_SOC
80:
<<: *VOLTAGE_DEFAULTS
entityInstance: 24
multiplierM: 5
path: /xyz/openbmc_project/sensors/voltage/S1_EXT_VREF
81:
<<: *VOLTAGE_DEFAULTS
entityInstance: 25
multiplierM: 80
path: /xyz/openbmc_project/sensors/voltage/12V_S0
82:
<<: *VOLTAGE_DEFAULTS
entityInstance: 26
multiplierM: 80
path: /xyz/openbmc_project/sensors/voltage/12V_S1
83:
<<: *VOLTAGE_DEFAULTS
entityInstance: 27
multiplierM: 80
path: /xyz/openbmc_project/sensors/voltage/12V_SB
84:
<<: *VOLTAGE_DEFAULTS
entityInstance: 28
multiplierM: 18
path: /xyz/openbmc_project/sensors/voltage/3V3
85:
<<: *VOLTAGE_DEFAULTS
entityInstance: 29
multiplierM: 18
path: /xyz/openbmc_project/sensors/voltage/3V3_SB
86:
<<: *VOLTAGE_DEFAULTS
entityInstance: 30
multiplierM: 27
path: /xyz/openbmc_project/sensors/voltage/5V
87:
<<: *VOLTAGE_DEFAULTS
entityInstance: 31
multiplierM: 27
path: /xyz/openbmc_project/sensors/voltage/5V_SB
88:
<<: *VOLTAGE_DEFAULTS
entityInstance: 32
multiplierM: 18
path: /xyz/openbmc_project/sensors/voltage/VBAT_RTC
89:
<<: *VOLTAGE_DEFAULTS
entityInstance: 33
multiplierM: 18
path: /xyz/openbmc_project/sensors/voltage/3V3_OCP0_SB
90:
<<: *VOLTAGE_DEFAULTS
entityInstance: 34
multiplierM: 18
path: /xyz/openbmc_project/sensors/voltage/3V3_OCP1_SB
91:
<<: *VOLTAGE_DEFAULTS
entityInstance: 35
multiplierM: 80
path: /xyz/openbmc_project/sensors/voltage/12V_OCP0_SB
92:
<<: *VOLTAGE_DEFAULTS
entityInstance: 36
multiplierM: 80
path: /xyz/openbmc_project/sensors/voltage/12V_OCP1_SB
93:
<<: *VOLTAGE_DEFAULTS
entityInstance: 37
multiplierM: 80
path: /xyz/openbmc_project/sensors/voltage/12V_HDD
94:
<<: *VOLTAGE_DEFAULTS
entityInstance: 38
multiplierM: 80
path: /xyz/openbmc_project/sensors/voltage/12V_FAN
95:
<<: *VOLTAGE_DEFAULTS
entityInstance: 39
multiplierM: 80
path: /xyz/openbmc_project/sensors/voltage/12V_PCIe
96:
<<: *VOLTAGE_DEFAULTS
entityInstance: 40
multiplierM: 80
path: /xyz/openbmc_project/sensors/voltage/12V_NIC_SB
97:
<<: *VOLTAGE_DEFAULTS
entityInstance: 41
multiplierM: 80
path: /xyz/openbmc_project/sensors/voltage/12V_GPU0
98:
<<: *VOLTAGE_DEFAULTS
entityInstance: 42
multiplierM: 80
path: /xyz/openbmc_project/sensors/voltage/12V_GPU1
99:
<<: *VOLTAGE_DEFAULTS
entityInstance: 43
multiplierM: 80
path: /xyz/openbmc_project/sensors/voltage/12V_GPU2
100:
<<: *VOLTAGE_DEFAULTS
entityInstance: 44
multiplierM: 10
path: /xyz/openbmc_project/sensors/voltage/1V8_SB
101:
<<: *VOLTAGE_DEFAULTS
entityInstance: 45
multiplierM: 6
path: /xyz/openbmc_project/sensors/voltage/1V05_SB
102:
<<: *VOLTAGE_DEFAULTS
entityInstance: 46
multiplierM: 8
path: /xyz/openbmc_project/sensors/voltage/1V25_SB
103:
<<: *VOLTAGE_DEFAULTS
entityInstance: 47
multiplierM: 18
path: /xyz/openbmc_project/sensors/voltage/3V3_M2
104:
<<: *VOLTAGE_DEFAULTS
entityInstance: 48
multiplierM: 10
path: /xyz/openbmc_project/sensors/voltage/12V_HDD_I
252:
<<: *VOLTAGE_DEFAULTS
entityInstance: 122
multiplierM: 80
path: /xyz/openbmc_project/sensors/voltage/12V_SB_BMC
253:
<<: *VOLTAGE_DEFAULTS
entityInstance: 123
multiplierM: 27
path: /xyz/openbmc_project/sensors/voltage/5V_SB_BMC
254:
<<: *VOLTAGE_DEFAULTS
entityInstance: 124
multiplierM: 18
path: /xyz/openbmc_project/sensors/voltage/3V3_SB_BMC
122:
<<: *TEMP_DEFAULTS
entityID: 19
entityInstance: 50
path: /xyz/openbmc_project/sensors/temperature/S0_PCP_VR_Temp
123: &power
sensorType: 0x08
path: /xyz/openbmc_project/sensors/power/S0_PCP_VR_Pwr
entityID: 0x13
entityInstance: 51
sensorReadingType: 0x01
multiplierM: 0x50
offsetB: 0
bExp: 0
unit: xyz.openbmc_project.Sensor.Value.Unit.Watts
rExp: -2
serviceInterface: org.freedesktop.DBus.Properties
readingType: readingData
interfaces:
xyz.openbmc_project.Sensor.Value:
Value:
Offsets:
0xFF:
type: double
129: &current
sensorType: 0x03
path: /xyz/openbmc_project/sensors/current/S0_SOC_VR_Cur
entityID: 0x13
entityInstance: 57
sensorReadingType: 0x01
multiplierM: 0x50
offsetB: 0
bExp: 0
unit: xyz.openbmc_project.Sensor.Value.Unit.Amperes
rExp: -3
serviceInterface: org.freedesktop.DBus.Properties
readingType: readingData
interfaces:
xyz.openbmc_project.Sensor.Value:
Value:
Offsets:
0xFF:
type: double
230:
<<: *VOLTAGE_DEFAULTS
entityInstance: 74
multiplierM: 20
rExp: -1
path: /xyz/openbmc_project/sensors/voltage/PSU0_VINPUT
231:
<<: *VOLTAGE_DEFAULTS
entityInstance: 75
multiplierM: 20
rExp: -1
path: /xyz/openbmc_project/sensors/voltage/PSU1_VINPUT
232:
<<: *VOLTAGE_DEFAULTS
entityInstance: 76
multiplierM: 20
rExp: -2
path: /xyz/openbmc_project/sensors/voltage/PSU0_VOUTPUT
233:
<<: *VOLTAGE_DEFAULTS
entityInstance: 77
multiplierM: 20
rExp: -2
path: /xyz/openbmc_project/sensors/voltage/PSU1_VOUTPUT
234:
<<: *current
entityInstance: 78
multiplierM: 80
path: /xyz/openbmc_project/sensors/current/PSU0_IINPUT
235:
<<: *current
entityInstance: 79
multiplierM: 80
path: /xyz/openbmc_project/sensors/current/PSU1_IINPUT
236:
<<: *current
entityInstance: 80
multiplierM: 160
path: /xyz/openbmc_project/sensors/current/PSU0_IOUTPUT
237:
<<: *current
entityInstance: 81
multiplierM: 160
path: /xyz/openbmc_project/sensors/current/PSU1_IOUTPUT
238:
<<: *power
entityInstance: 82
multiplierM: 80
rExp: -1
path: /xyz/openbmc_project/sensors/power/PSU0_PINPUT
239:
<<: *power
entityInstance: 83
multiplierM: 80
rExp: -1
path: /xyz/openbmc_project/sensors/power/PSU1_PINPUT
240:
<<: *power
entityInstance: 84
multiplierM: 80
rExp: -1
path: /xyz/openbmc_project/sensors/power/PSU0_POUTPUT
241:
<<: *power
entityInstance: 85
multiplierM: 80
rExp: -1
path: /xyz/openbmc_project/sensors/power/PSU1_POUTPUT
242:
<<: *power
entityInstance: 57
multiplierM: 80
rExp: -1
path: /xyz/openbmc_project/sensors/power/total_power
243:
<<: *TEMP_DEFAULTS
entityID: 0x1e
entityInstance: 58
path: /xyz/openbmc_project/sensors/temperature/PSU0_TEMP
244:
<<: *TEMP_DEFAULTS
entityID: 0x1e
entityInstance: 59
path: /xyz/openbmc_project/sensors/temperature/PSU1_TEMP
245:
<<: *FAN_DEFAULTS
entityInstance: 60
path: /xyz/openbmc_project/sensors/fan_tach/PSU0_fan1
246:
<<: *FAN_DEFAULTS
entityInstance: 61
path: /xyz/openbmc_project/sensors/fan_tach/PSU1_fan1
250:
<<: *TEMP_DEFAULTS
entityID: 3
entityInstance: 13
path: /xyz/openbmc_project/sensors/temperature/S0_THDIODE_Temp
251:
<<: *TEMP_DEFAULTS
entityID: 3
entityInstance: 14
path: /xyz/openbmc_project/sensors/temperature/S1_THDIODE_Temp
@@ -0,0 +1 @@
# console-id is default to obmc-console
@@ -0,0 +1 @@
console-id = ttyS1
@@ -0,0 +1 @@
console-id = ttyS2
@@ -0,0 +1 @@
console-id = ttyS3
@@ -0,0 +1 @@
console-id = ttyS7
@@ -0,0 +1 @@
console-id = ttyS8
@@ -0,0 +1,3 @@
# console-id is default to obmc-console
local-tty = ttyS0
local-tty-baud = 115200
@@ -0,0 +1,3 @@
local-tty = ttyS1
local-tty-baud = 115200
console-id = ttyS1
@@ -0,0 +1,3 @@
local-tty = ttyS2
local-tty-baud = 115200
console-id = ttyS2
@@ -0,0 +1,3 @@
local-tty = ttyS3
local-tty-baud = 115200
console-id = ttyS3
@@ -0,0 +1,3 @@
local-tty = ttyS7
local-tty-baud = 115200
console-id = ttyS7
@@ -0,0 +1,3 @@
local-tty = ttyS8
local-tty-baud = 115200
console-id = ttyS8
@@ -0,0 +1,29 @@
FILESEXTRAPATHS:append := "${THISDIR}/${PN}:"
RDEPENDS:${PN} += "bash"
# Declare port spcific config files
OBMC_CONSOLE_TTYS = "ttyS0 ttyS1 ttyS2 ttyS3 ttyS7 ttyS8"
CONSOLE_CLIENT = "2200 2201 2202 2203 2204 2205"
CONSOLE_SERVER_CONF_FMT = "file://server.{0}.conf"
CONSOLE_CLIENT_CONF_FMT = "file://client.{0}.conf"
CONSOLE_CLIENT_SERVICE_FMT = "obmc-console-ssh@{0}.service"
SRC_URI += " \
${@compose_list(d, 'CONSOLE_SERVER_CONF_FMT', 'OBMC_CONSOLE_TTYS')} \
${@compose_list(d, 'CONSOLE_CLIENT_CONF_FMT', 'CONSOLE_CLIENT')} \
"
SYSTEMD_SERVICE:${PN}:append = " \
${@compose_list(d, 'CONSOLE_CLIENT_SERVICE_FMT', 'CONSOLE_CLIENT')} \
"
SYSTEMD_SERVICE:${PN}:remove = "obmc-console-ssh.socket"
FILES:${PN}:remove = "${systemd_system_unitdir}/obmc-console-ssh@.service.d/use-socket.conf"
PACKAGECONFIG:append = " concurrent-servers"
do_install:append() {
# Install the console client configurations
install -m 0644 ${WORKDIR}/client.*.conf ${D}${sysconfdir}/${BPN}/
}
@@ -0,0 +1,8 @@
[Unit]
Description=Ampere Computing LLC host reboot
Conflicts=obmc-chassis-poweron@0.target
[Service]
Type=oneshot
ExecStart=/usr/sbin/ampere_power_util.sh mb host_reboot_wa
SyslogIdentifier=ampere_host_reboot
@@ -0,0 +1,50 @@
[
{
"Name": "REBOOT_ACK",
"LineName": "host0-reboot-ack-n",
"EventMon": "FALLING",
"Target": "ampere-host-reboot@0.service",
"Continue": true
},
{
"Name": "SHUTDOWN_ACK",
"LineName": "host0-shd-ack-n",
"EventMon": "FALLING",
"Target": "ampere-host-shutdown-ack@0.service",
"Continue": true
},
{
"Name": "S0_OVERTEMP",
"LineName": "s0-overtemp-n",
"EventMon": "FALLING",
"Target": "ampere_overtemp@0.service",
"Continue": true
},
{
"Name": "S1_OVERTEMP",
"LineName": "s1-overtemp-n",
"EventMon": "FALLING",
"Target": "ampere_overtemp@1.service",
"Continue": true
},
{
"Name": "S0_HIGHTEMP",
"LineName": "s0-hightemp-n",
"EventMon": "BOTH",
"Targets": {
"FALLING": ["ampere_hightemp_start@0.service"],
"RISING": ["ampere_hightemp_stop@0.service"]
},
"Continue": true
},
{
"Name": "S1_HIGHTEMP",
"LineName": "s1-hightemp-n",
"EventMon": "BOTH",
"Targets": {
"FALLING": ["ampere_hightemp_start@1.service"],
"RISING": ["ampere_hightemp_stop@1.service"]
},
"Continue": true
}
]
@@ -0,0 +1,21 @@
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
RDEPENDS:${PN}-monitor += "bash"
SRC_URI += " \
file://phosphor-multi-gpio-monitor.json \
"
SYSTEMD_SERVICE:${PN}-monitor += " \
ampere-host-shutdown-ack@.service \
ampere-host-reboot@.service \
"
FILES:${PN}-monitor += " \
${datadir}/${PN}/phosphor-multi-gpio-monitor.json \
"
do_install:append() {
install -d ${D}${bindir}
install -m 0644 ${WORKDIR}/phosphor-multi-gpio-monitor.json ${D}${datadir}/${PN}/
}
@@ -0,0 +1,3 @@
SOCKET_ID=default
MODE=stream
STREAM_DST=/run/rsyslog/console/cpu
@@ -0,0 +1,3 @@
SOCKET_ID=ttyS1
MODE=stream
STREAM_DST=/run/rsyslog/console/mpro0
@@ -0,0 +1,3 @@
SOCKET_ID=ttyS2
MODE=stream
STREAM_DST=/run/rsyslog/console/atf
@@ -0,0 +1,3 @@
SOCKET_ID=ttyS3
MODE=stream
STREAM_DST=/run/rsyslog/console/secpro0
@@ -0,0 +1,3 @@
SOCKET_ID=ttyS7
MODE=stream
STREAM_DST=/run/rsyslog/console/mpro1
@@ -0,0 +1,3 @@
SOCKET_ID=ttyS8
MODE=stream
STREAM_DST=/run/rsyslog/console/secpro1
@@ -0,0 +1,20 @@
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
SRC_URI:append = " \
file://ttyS0.conf \
file://ttyS1.conf \
file://ttyS2.conf \
file://ttyS3.conf \
file://ttyS7.conf \
file://ttyS8.conf \
"
do_install:append() {
# Install the configurations
install -m 0755 -d ${D}${sysconfdir}/${BPN}
install -m 0644 ${WORKDIR}/*.conf ${D}${sysconfdir}/${BPN}/
# Remove upstream-provided default configuration
rm -f ${D}${sysconfdir}/${BPN}/ttyVUART0.conf
}
@@ -0,0 +1,2 @@
PACKAGECONFIG:append = " mac-address-manual-fru-conf"
PACKAGECONFIG[mac-address-manual-fru-conf] = "-Dmac-address-fru-bus=14 -Dmac-address-fru-addr=80"
@@ -0,0 +1,2 @@
FILESEXTRAPATHS:append := "${THISDIR}/${PN}:"
@@ -0,0 +1,2 @@
{"id": 32, "revision": 1, "addn_dev_support": 141,
"manuf_id": 52538, "prod_id": 131, "aux": 0}
@@ -0,0 +1,9 @@
FILESEXTRAPATHS:append := "${THISDIR}/${PN}:"
PACKAGECONFIG:append = " dynamic-storages-only"
DEPENDS:append = " mtmitchell-yaml-config"
EXTRA_OEMESON = " \
-Dsensor-yaml-gen=${STAGING_DIR_HOST}${datadir}/mtmitchell-yaml-config/ipmi-sensors.yaml \
-Dfru-yaml-gen=${STAGING_DIR_HOST}${datadir}/mtmitchell-yaml-config/ipmi-fru-read.yaml \
"
@@ -0,0 +1,7 @@
DEFAULT_RMCPP_IFACE = "eth0"
ALT_RMCPP_IFACE = "eth1"
SYSTEMD_SERVICE:${PN} += " \
${PN}@${ALT_RMCPP_IFACE}.service \
${PN}@${ALT_RMCPP_IFACE}.socket \
"
@@ -0,0 +1,3 @@
[Service]
ExecStopPost=/bin/sh -c "gpioset $(gpiofind bmc-ok)=0"
ExecStartPost=/bin/sh -c "gpioset $(gpiofind bmc-ok)=1"
@@ -0,0 +1,11 @@
FILESEXTRAPATHS:append := "${THISDIR}/${PN}:"
SRC_URI += " file://ssifbridge-override.conf"
FILES:${PN} += "${systemd_system_unitdir}/ssifbridge.service.d"
do_install:append() {
install -d ${D}${systemd_system_unitdir}/ssifbridge.service.d
install -m 644 ${WORKDIR}/ssifbridge-override.conf \
${D}${systemd_system_unitdir}/ssifbridge.service.d
}
@@ -0,0 +1,17 @@
SUMMARY = "Phosphor LED Group Management for Mt. Mitchell"
PR = "r1"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
inherit native
PROVIDES += "virtual/phosphor-led-manager-config-native"
SRC_URI += "file://led.yaml"
# Overwrite the example led layout yaml file prior
# to building the phosphor-led-manager package
do_install() {
DEST=${D}${datadir}/phosphor-led-manager
install -D ${WORKDIR}/led.yaml ${DEST}/led.yaml
}
@@ -0,0 +1,32 @@
bmc_booted:
power:
Action: 'Blink'
DutyOn: 50
Period: 1000
Priority: 'On'
power_on:
power:
Action: 'On'
DutyOn: 50
Period: 0
Priority: 'On'
systemFault:
fault:
Action: 'On'
DutyOn: 50
Period: 0
Priority: 'Blink'
enclosure_identify:
identify:
Action: 'On'
DutyOn: 50
Period: 1000
enclosure_identify_blink:
identify:
Action: 'Blink'
DutyOn: 50
Period: 1000
@@ -0,0 +1,15 @@
RDEPENDS:${PN}-extras:append = " \
webui-vue \
phosphor-image-signing \
phosphor-virtual-sensor \
phosphor-misc-usb-ctrl \
"
RDEPENDS:${PN}-inventory:append = " \
dbus-sensors \
entity-manager \
"
RDEPENDS:${PN}-extras:remove = " phosphor-hwmon"
VIRTUAL-RUNTIME_obmc-sensors-hwmon ?= "dbus-sensors"
RDEPENDS:${PN}-extras:append = " phosphor-virtual-sensor"
@@ -0,0 +1,179 @@
[
{
"Desc":
{
"Name": "total_power",
"SensorType": "power"
},
"Threshold" :
{
},
"Associations":
[
[
"chassis",
"all_sensors",
"/xyz/openbmc_project/inventory/system/board/Mt_Mitchell_Motherboard"
],
[
"inventory",
"sensors",
"/xyz/openbmc_project/inventory/system/board/Mt_Mitchell_Motherboard"
]
],
"Params":
{
"DbusParam":
[
{
"ParamName": "P0",
"Desc":
{
"Name": "PSU0_POUTPUT",
"SensorType": "power"
}
},
{
"ParamName": "P1",
"Desc":
{
"Name": "PSU1_POUTPUT",
"SensorType": "power"
}
}
]
},
"Expression": "(P0 == P0) ? ((P1 == P1) ? P0+P1 : P0 ) : P1"
},
{
"Desc":
{
"Name": "OutletTemp",
"SensorType": "temperature"
},
"Threshold" :
{
"CriticalHigh": 70
},
"Associations":
[
[
"board",
"all_sensors",
"/xyz/openbmc_project/inventory/system/board/Mt_Mitchell_Motherboard"
],
[
"inventory",
"sensors",
"/xyz/openbmc_project/inventory/system/board/Mt_Mitchell_Motherboard"
]
],
"Params":
{
"DbusParam":
[
{
"ParamName": "P0",
"Desc":
{
"Name": "OutletTemp1",
"SensorType": "temperature"
}
},
{
"ParamName": "P1",
"Desc":
{
"Name": "OutletTemp2",
"SensorType": "temperature"
}
}
]
},
"Expression": "(P0 + P1) >= 0 ? (P0 + P1) / 2 : NULL"
},
{
"Desc":{
"Name":"NVMeM2_MaxTemp",
"SensorType":"temperature"
},
"Threshold" :
{
"CriticalHigh": 70
},
"Associations":
[
[
"chassis",
"all_sensors",
"/xyz/openbmc_project/inventory/system/board/Mt_Mitchell_Motherboard"
],
[
"inventory",
"sensors",
"/xyz/openbmc_project/inventory/system/board/Mt_Mitchell_Motherboard"
]
],
"Params":{
"DbusParam": [
{
"ParamName": "n0",
"Desc": {
"Name": "m2nvme0",
"SensorType": "temperature"
}
},
{
"ParamName": "n1",
"Desc": {
"Name": "m2nvme1",
"SensorType": "temperature"
}
}
]
},
"Expression": "max((n0 == n0) ? n0 : 0,(n1 == n1) ? n1 : 0)"
},
{
"Desc":{
"Name":"OCP_MaxTemp",
"SensorType":"temperature"
},
"Threshold" :
{
"CriticalHigh": 105
},
"Associations":
[
[
"chassis",
"all_sensors",
"/xyz/openbmc_project/inventory/system/board/Mt_Mitchell_Motherboard"
],
[
"inventory",
"sensors",
"/xyz/openbmc_project/inventory/system/board/Mt_Mitchell_Motherboard"
]
],
"Params":{
"DbusParam": [
{
"ParamName": "n1",
"Desc": {
"Name": "OCP1_Temp",
"SensorType": "temperature"
}
},
{
"ParamName": "n2",
"Desc": {
"Name": "OCP2_Temp",
"SensorType": "temperature"
}
}
]
},
"Expression": "max((n1 == n1) ? n1 : 0,(n2 == n2) ? n2 : 0)"
}
]
@@ -0,0 +1,11 @@
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
SRC_URI:append = " \
file://mtmitchell_virtual_sensor_config.json \
"
do_install:append() {
install -m 0644 ${WORKDIR}/mtmitchell_virtual_sensor_config.json \
${D}${datadir}/phosphor-virtual-sensor/virtual_sensor_config.json
}
@@ -0,0 +1,45 @@
{
"gpio_configs": {
"power_config": {
"power_good_in": "PGOOD",
"power_up_outs": [
{"name": "OCP_MAIN_PWREN", "polarity": true},
{"name": "BMC_SYS_PSON_L", "polarity": false}
]
}
},
"gpio_definitions": [
{
"name": "PGOOD",
"pin": "H3",
"direction": "in"
},
{
"name": "BMC_SYS_PSON_L",
"pin": "F2",
"direction": "out"
},
{
"name": "POWER_BUTTON",
"pin": "I6",
"direction": "both"
},
{
"name": "RESET_BUTTON",
"pin": "Z0",
"direction": "both"
},
{
"name": "OCP_MAIN_PWREN",
"pin": "W1",
"direction": "out"
},
{
"name": "ID_BTN",
"pin": "S2",
"direction": "both"
}
]
}
@@ -0,0 +1,10 @@
FILESEXTRAPATHS:append := "${THISDIR}/${PN}:"
SRC_URI += "\
file://mtmitchell_gpio_defs.json \
"
do_install:append() {
install -d ${D}${sysconfdir}/default/obmc/gpio/
install -m 0644 ${WORKDIR}/mtmitchell_gpio_defs.json ${D}/${sysconfdir}/default/obmc/gpio/gpio_defs.json
}
@@ -0,0 +1,5 @@
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
EXTRA_OEMESON:append = " \
-Dwarm-reboot=disabled \
"