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,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