meta-fii/meta-kudo: Add kudo-cmd a collection of kudo system utils

1. Add Kudo.sh, a script for display and controlling kudo system
2. Add kudo-ras.sh for debug Ampere system errors on kudo system

Signed-off-by: XP Chen <xiao-peng.chen@fii-na.com>
Change-Id: I5763e0de4be942b9b851b910448d15135ca9db16
Signed-off-by: Mohaimen Alsamarai <mohaimen.alsamarai@fii-na.com>
diff --git a/meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-cmd.bb b/meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-cmd.bb
new file mode 100644
index 0000000..777fa6f
--- /dev/null
+++ b/meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-cmd.bb
@@ -0,0 +1,22 @@
+SUMMARY = "Phosphor OpenBMC Kudo System Command"
+DESCRIPTION = "Phosphor OpenBMC Kudo System Command Daemon"
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:
+
+PR = "r1"
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
+
+RDEPENDS_${PN} += "bash"
+
+SRC_URI = " \
+    file://kudo.sh \
+    file://kudo-ras.sh \
+    "
+
+SYSTEMD_PACKAGES = "${PN}"
+
+do_install () {
+    install -d ${D}/${sbindir}
+    install -m 0755 ${WORKDIR}/kudo.sh ${D}/${sbindir}/kudo.sh
+    install -m 0755 ${WORKDIR}/kudo-ras.sh ${D}/${sbindir}/kudo-ras.sh
+}
diff --git a/meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-cmd/kudo-ras.sh b/meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-cmd/kudo-ras.sh
new file mode 100644
index 0000000..af1b0a4
--- /dev/null
+++ b/meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-cmd/kudo-ras.sh
@@ -0,0 +1,575 @@
+#!/bin/bash
+
+powerState=$(i2cget -f -y 0x2 0x4f 0xe0 b)
+
+getGPISourceRegisters(){
+    REG60=$(i2cget -f -y 0x2 0x4f 0x60 w)       # GPI Data Set
+    REG61=$(i2cget -f -y 0x2 0x4f 0x61 w)       # GPI DATA Set #0
+    REG62=$(i2cget -f -y 0x2 0x4f 0x62 w)       # GPI DATA Set #1
+    REG63=$(i2cget -f -y 0x2 0x4f 0x63 w)       # GPI DATA Set #2
+    REG64=$(i2cget -f -y 0x2 0x4f 0x64 w)       # GPI DATA Set #3
+    DS0Pres=$((REG60 & 0x0100))
+    DS1Pres=$((REG60 & 0x0200))
+    DS2Pres=$((REG60 & 0x0400))
+    DS3Pres=$((REG60 & 0x0800))
+}
+
+getErrorCount() {
+    MemCE=$(i2cget -f -y 0x2 0x4f 0x90 w)
+    MemUE=$(i2cget -f -y 0x2 0x4f 0x93 w)
+    CoreCE=$(i2cget -f -y 0x2 0x4f 0x80 w)
+    CoreUE=$(i2cget -f -y 0x2 0x4f 0x83 w)
+    PCIeCE=$(i2cget -f -y 0x2 0x4f 0xc0 w)
+    PCIeUE=$(i2cget -f -y 0x2 0x4f 0xc2 w)
+    OtherCE=$(i2cget -f -y 0x2 0x4f 0xd0 w)
+    OtherUE=$(i2cget -f -y 0x2 0x4f 0xd8 w)
+}
+
+getReg61Vals() {
+    REG61_0800=$((REG61 & 0x0800))
+    REG61_0800_VAL=$((REG61_0800 >> 8))
+    REG61_1000=$((REG61 & 0x1000))
+    REG61_1000_VAL=$((REG61_1000 >> 12))
+}
+
+getReg62Vals() {
+    REG62_0100=$((REG62 & 0x0100))
+    REG62_0100_VAL=$((REG62_0100 >> 8))
+    REG62_0200=$((REG62 & 0x0200))
+    REG62_0200_VAL=$((REG62_0200 >> 9))
+    REG62_0400=$((REG62 & 0x0400))
+    REG62_0400_VAL=$((REG62_0400 >> 10))
+}
+
+getReg63Vals() {
+    REG63_0100=$((REG63 & 0x0100))
+    REG63_0100_VAL=$((REG63_0100 >> 8))
+}
+
+getReg64Vals() {
+    REG64_0100=$((REG64 & 0x0100))
+    REG64_0100_VAL=$((REG64_0100 >> 8))
+    REG64_0200=$((REG64 & 0x0200))
+    REG64_0200_VAL=$((REG64_0200 >> 9))
+    REG64_0800=$((REG64 & 0x0800))
+    REG64_0800_VAL=$((REG64_0800 >> 11))
+    REG64_2000=$((REG64 & 0x2000))
+    REG64_2000_VAL=$((REG64_2000 >> 13))
+    REG64_4000=$((REG64 & 0x4000))
+    REG64_4000_VAL=$((REG64_4000 >> 14))
+    REG64_8000=$((REG64 & 0x8000))
+    REG64_8000_VAL=$((REG64_8000 >> 15))
+    REG64_0001=$((REG64 & 0x0001))
+    REG64_0001_VAL=$((REG64_0001))
+}
+
+getGPIStatusRegisters(){
+    REG70=$(i2cget -f -y 0x2 0x4f 0x70 w)       # Core, DIMM, SLC, PCIe, and Other errors
+    REG78=$(i2cget -f -y 0x2 0x4f 0x78 w)       # VRD Fault/Warning Error
+    REG79=$(i2cget -f -y 0x2 0x4f 0x79 w)       # VRD Hot
+    REG7A=$(i2cget -f -y 0x2 0x4f 0x7A w)       # DIMM Hot Error
+    REG7B=$(i2cget -f -y 0x2 0x4f 0x7B w)       # Boot #1 Error
+    REG7C=$(i2cget -f -y 0x2 0x4f 0x7C w)       # Boot #2 Error
+    REG7D=$(i2cget -f -y 0x2 0x4f 0x7D w)       # Watchdog/Other Status
+    REG7E=$(i2cget -f -y 0x2 0x4f 0x7E w)       # RAS internal error
+}
+
+getReg70Vals() {
+    REG70_0100=$((REG70 & 0x0100))
+    REG70_0100_VAL=$((REG70_0100 >> 8))
+    REG70_0200=$((REG70 & 0x0200))
+    REG70_0200_VAL=$((REG70_0200 >> 9))
+    REG70_0400=$((REG70 & 0x0400))
+    REG70_0400_VAL=$((REG70_0400 >> 10))
+    REG70_0800=$((REG70 & 0x0800))
+    REG70_0800_VAL=$((REG70_0800 >> 11))
+    REG70_4000=$((REG70 & 0x4000))
+    REG70_4000_VAL=$((REG70_4000 >> 14))
+    REG70_8000=$((REG70 & 0x8000))
+    REG70_8000_VAL=$((REG70_8000 >> 15))
+    REG70_0001=$((REG70 & 0x0001))
+    REG70_0001_VAL=$((REG70_0001))
+    REG70_0002=$((REG70 & 0x0002))
+    REG70_0002_VAL=$((REG70_0002 >> 1))
+}
+
+getReg78Vals() {
+    REG78_0100=$((REG78 & 0x0100))
+    REG78_0100_VAL=$((REG78_0100 >> 8))
+    REG78_0200=$((REG78 & 0x0200))
+    REG78_0200_VAL=$((REG78_0200 >> 9))
+    REG78_0400=$((REG78 & 0x0400))
+    REG78_0400_VAL=$((REG78_0400 >> 10))
+    REG78_0800=$((REG78 & 0x0800))
+    REG78_0800_VAL=$((REG78_0800 >> 11))
+    REG78_1000=$((REG78 & 0x1000))
+    REG78_1000_VAL=$((REG78_1000 >> 12))
+    REG78_2000=$((REG78 & 0x2000))
+    REG78_2000_VAL=$((REG78_2000 >> 13))
+    REG78_4000=$((REG78 & 0x4000))
+    REG78_4000_VAL=$((REG78_4000 >> 14))
+    REG78_8000=$((REG78 & 0x8000))
+    REG78_8000_VAL=$((REG78_8000 >> 15))
+    REG78_0001=$((REG78 & 0x0001))
+    REG78_0001_VAL=$((REG78_0001))
+    REG78_0002=$((REG78 & 0x0002))
+    REG78_0002_VAL=$((REG78_0002 >> 1))
+    REG78_0004=$((REG78 & 0x0004))
+    REG78_0004_VAL=$((REG78_0004 >> 2))
+    REG78_0008=$((REG78 & 0x0008))
+    REG78_0008_VAL=$((REG78_0008 >> 3))
+}
+
+getReg79Vals() {
+    REG79_0100=$((REG79 & 0x0100))
+    REG79_0100_VAL=$((REG79_0100 >> 8))
+    REG79_1000=$((REG79 & 0x1000))
+    REG79_1000_VAL=$((REG79_1000 >> 12))
+    REG79_2000=$((REG79 & 0x2000))
+    REG79_2000_VAL=$((REG79_2000 >> 13))
+    REG79_4000=$((REG79 & 0x4000))
+    REG79_4000_VAL=$((REG79_4000 >> 14))
+    REG79_0001=$((REG79 & 0x0001))
+    REG79_0001_VAL=$((REG79_0001))
+    REG79_0002=$((REG79 & 0x0002))
+    REG79_0002_VAL=$((REG79_0002 >> 1))
+    REG79_0004=$((REG79 & 0x0004))
+    REG79_0004_VAL=$((REG79_0004 >> 2))
+    REG79_0008=$((REG79 & 0x0008))
+    REG79_0008_VAL=$((REG79_0008 >> 3))
+}
+
+getReg7AVals() {
+    REG7A_0100=$((REG7A & 0x0100))
+    REG7A_0100_VAL=$((REG7A_0100 >> 8))
+    REG7A_0200=$((REG7A & 0x0200))
+    REG7A_0200_VAL=$((REG7A_0200 >> 9))
+    REG7A_0400=$((REG7A & 0x0400))
+    REG7A_0400_VAL=$((REG7A_0400 >> 10))
+    REG7A_0800=$((REG7A & 0x0800))
+    REG7A_0800_VAL=$((REG7A_0800 >> 11))
+    REG7A_1000=$((REG7A & 0x1000))
+    REG7A_1000_VAL=$((REG7A_1000 >> 12))
+    REG7A_2000=$((REG7A & 0x2000))
+    REG7A_2000_VAL=$((REG7A_2000 >> 13))
+    REG7A_4000=$((REG7A & 0x4000))
+    REG7A_4000_VAL=$((REG7A_4000 >> 14))
+    REG7A_8000=$((REG7A & 0x8000))
+    REG7A_8000_VAL=$((REG7A_8000 >> 15))
+}
+
+getReg7DVals() {
+    REG7D_0100=$((REG7D & 0x0100))
+    REG7D_0100_VAL=$((REG7D_0100 >> 8))
+    REG7D_0200=$((REG7D & 0x0200))
+    REG7D_0200_VAL=$((REG7D_0200 >> 9))
+    REG7D_0400=$((REG7D & 0x0400))
+    REG7D_0400_VAL=$((REG7D_0400 >> 10))
+}
+
+getReg7EVals() {
+    REG7E_0100=$((REG7E & 0x0100))
+    REG7E_0100_VAL=$((REG7E_0100 >> 8))
+    REG7E_0200=$((REG7E & 0x0200))
+    REG7E_0200_VAL=$((REG7E_0200 >> 9))
+}
+
+getGPIMaskRegisters(){
+    REG50=$(i2cget -f -y 0x2 0x4f 0x50 w)       # GPI Control #0
+    REG51=$(i2cget -f -y 0x2 0x4f 0x51 w)       # GPI Control #1
+    REG52=$(i2cget -f -y 0x2 0x4f 0x52 w)       # GPI Control #2
+    REG53=$(i2cget -f -y 0x2 0x4f 0x53 w)       # GPI Control #3
+    REG54=$(i2cget -f -y 0x2 0x4f 0x54 w)       # GPI CE/UE Mask
+}
+
+getReg50Vals() {
+    REG50_0400=$((REG50 & 0x0400))
+    REG50_0400_VAL=$((REG50_0400 >> 10))
+    REG50_0800=$((REG50 & 0x0800))
+    REG50_0800_VAL=$((REG50_0800 >> 11))
+}
+
+getReg51Vals() {
+    REG51_0100=$((REG51 & 0x0100))
+    REG51_0100_VAL=$((REG51_0100 >> 8))
+    REG51_0200=$((REG51 & 0x0200))
+    REG51_0200_VAL=$((REG51_0200 >> 9))
+    REG51_0400=$((REG51 & 0x0400))
+    REG51_0400_VAL=$((REG51_0400 >> 10))
+}
+
+getReg52Vals() {
+    REG52_0100=$((REG52 & 0x0100))
+    REG52_0100_VAL=$((REG52_0100 >> 8))
+}
+
+getReg53Vals() {
+    REG53_0100=$((REG53 & 0x0100))
+    REG53_0100_VAL=$((REG53_0100 >> 8))
+    REG53_0200=$((REG53 & 0x0200))
+    REG53_0200_VAL=$((REG53_0200 >> 9))
+    REG53_0800=$((REG53 & 0x0800))
+    REG53_0800_VAL=$((REG53_0800 >> 11))
+    REG53_2000=$((REG53 & 0x2000))
+    REG53_2000_VAL=$((REG53_2000 >> 13))
+    REG53_4000=$((REG53 & 0x4000))
+    REG53_4000_VAL=$((REG53_4000 >> 14))
+    REG53_8000=$((REG53 & 0x8000))
+    REG53_8000_VAL=$((REG53_8000 >> 15))
+    REG53_0001=$((REG53 & 0x0001))
+    REG53_0001_VAL=$((REG53_0001))
+}
+
+getReg54Vals() {
+    REG54_0100=$((REG54 & 0x0100))
+    REG54_0100_VAL=$((REG54_0100 >> 8))
+    REG54_0200=$((REG54 & 0x0200))
+    REG54_0200_VAL=$((REG54_0200 >> 9))
+    REG54_0001=$((REG54 & 0x0001))
+    REG54_0001_VAL=$((REG54_0001))
+    REG54_0002=$((REG54 & 0x0002))
+    REG54_0002_VAL=$((REG54_0002 >> 1))
+    REG54_0004=$((REG54 & 0x0004))
+    REG54_0004_VAL=$((REG54_0004 >> 2))
+    REG54_0008=$((REG54 & 0x0008))
+    REG54_0008_VAL=$((REG54_0008 >> 3))
+    REG54_0010=$((REG54 & 0x0010))
+    REG54_0010_VAL=$((REG54_0010 >> 4))
+    REG54_0020=$((REG54 & 0x0020))
+    REG54_0020_VAL=$((REG54_0020 >> 5))
+}
+
+
+
+if [ -z $powerState ]
+ then
+        echo "System is currently Powered off S6"
+else
+        echo "System is currently in ${powerState} "
+
+        # Get Error Count
+        getErrorCount
+        echo "  "
+        echo " Error Count: "
+        echo " Memory   Errors: Correctable $((MemCE >> 8)) Uncorrectable $((MemUE >> 8)) "
+        echo " Core     Errors: Correctable $((CoreCE >> 8)) Uncorrectable $((CoreUE >> 8))"
+        echo " PCIe     Errors: Correctable $((PCIeCE >> 8)) Uncorrectable $((PCIeUE >> 8)) "
+        echo " Other    Errors: Correctable $((OtherCE >> 8)) Uncorrectable $((OtherUE >> 8)) "
+
+        # GPI Source Registers
+        getGPISourceRegisters
+        echo "  "
+        echo " GPI Source Registers: "
+        echo " GPI Data Set #0 Present: $((DS0Pres >> 8)) "
+        echo " GPI Data Set #1 Present: $((DS1Pres >> 9)) "
+        echo " GPI Data Set #2 Present: $((DS2Pres >> 10)) "
+        echo " GPI Data Set #3 Present: $((DS3Pres >> 11)) "
+
+        # REG61 Data Set#0
+        getReg61Vals
+        echo "  "
+        echo " GPI Data Set#0: "
+        if [[ "$REG61_0800_VAL" != 0 ]]; then
+                echo " Platform Booting "
+        fi
+        if [[ "$REG61_1000_VAL" != 0 ]]; then
+                echo " Critical Stop "
+        fi
+
+        # REG62 Data Set#1
+        getReg62Vals
+        echo "  "
+        echo " GPI Data Set#1: "
+        if [[ "$REG62_0100_VAL" != 0 ]]; then
+                echo " SoC VR HOT/Warn/Fault "
+        fi
+        if [[ "$REG62_0200_VAL" != 0 ]]; then
+                echo " Core VR HOT/Warn/Fault "
+        fi
+        if [[ "$REG62_0400_VAL" != 0 ]]; then
+                echo " DIMM HOT/Warn/Fault "
+        fi
+
+        # REG63 Data Set#2
+        getReg63Vals
+        echo "  "
+        echo " GPI Data Set#2: "
+        if [[ "$REG63_0100_VAL" != 0 ]]; then
+                echo " DIMM HOT "
+        fi
+
+        # REG64 Data Set#3
+        getReg64Vals
+        echo "  "
+        echo " GPI Data Set#3: "
+        if [[ "$REG64_0100_VAL" != 0 ]]; then
+                echo " Core Errors "
+        fi
+        if [[ "$REG64_0200_VAL" != 0 ]]; then
+                echo " Memory Errors "
+        fi
+        if [[ "$REG64_0800_VAL" != 0 ]]; then
+                echo " PCIe Errors "
+        fi
+        if [[ "$REG64_2000_VAL" != 0 ]]; then
+                echo " Other Errors "
+        fi
+        if [[ "$REG64_4000_VAL" != 0 ]]; then
+                echo " ACPI State Change "
+        fi
+        if [[ "$REG64_8000_VAL" != 0 ]]; then
+                echo " Boot Errors "
+        fi
+        if [[ "$REG64_0001_VAL" != 0 ]]; then
+                echo " RAS Internal Error "
+    fi
+
+        # GPI Status Regs
+        getGPIStatusRegisters
+        echo "  "
+        echo " GPI Status Regs "
+
+        getReg70Vals
+        echo "  "
+        echo " Core, DIMM, SLC, PCIe, and Other errors: "
+        if [[ "$REG70_0100_VAL" != 0 ]]; then
+                echo " Core CE Error "
+        fi
+        if [[ "$REG70_0200_VAL" != 0 ]]; then
+                echo " Core UE Error "
+        fi
+        if [[ "$REG70_0400_VAL" != 0 ]]; then
+                echo " DIMM CE Error "
+        fi
+        if [[ "$REG70_0800_VAL" != 0 ]]; then
+                echo " DIMM UE Error "
+        fi
+        if [[ "$REG70_4000_VAL" != 0 ]]; then
+                echo " PCIe CE Error "
+        fi
+        if [[ "$REG70_8000_VAL" != 0 ]]; then
+                echo " PCIe UE Error "
+        fi
+        if [[ "$REG70_0001_VAL" != 0 ]]; then
+                echo " Other CE Error "
+        fi
+        if [[ "$REG70_0002_VAL" != 0 ]]; then
+                echo " Other UE Error "
+        fi
+
+        getReg78Vals
+        echo "  "
+        echo " VRD Fault/Warning Error: "
+        if [[ "$REG78_0100_VAL" != 0 ]]; then
+                echo " SoC VRD fault/warning "
+        fi
+        if [[ "$REG78_0200_VAL" != 0 ]]; then
+                echo " Core VRD1 fault/warning "
+        fi
+        if [[ "$REG78_0400_VAL" != 0 ]]; then
+                echo " Core VRD2 fault/warning "
+        fi
+        if [[ "$REG78_0800_VAL" != 0 ]]; then
+                echo " Core VRD3 fault/warning "
+        fi
+        if [[ "$REG78_1000_VAL" != 0 ]]; then
+                echo " DIMM VRD1 fault/warning "
+        fi
+        if [[ "$REG78_2000_VAL" != 0 ]]; then
+                echo " DIMM VRD2 fault/warning "
+        fi
+        if [[ "$REG78_4000_VAL" != 0 ]]; then
+                echo " DIMM VRD3 fault/warning "
+        fi
+        if [[ "$REG78_8000_VAL" != 0 ]]; then
+                echo " DIMM VRD3 fault/warning "
+        fi
+        if [[ "$REG78_0001_VAL" != 0 ]]; then
+                echo " DIMM fault/warning "
+        fi
+        if [[ "$REG78_0002_VAL" != 0 ]]; then
+                echo " DIMM fault/warning "
+        fi
+        if [[ "$REG78_0004_VAL" != 0 ]]; then
+                echo " DIMM fault/warning "
+        fi
+        if [[ "$REG78_0008_VAL" != 0 ]]; then
+                echo " DIMM fault/warning "
+        fi
+
+        getReg79Vals
+        echo "  "
+        echo " VRD Hot: "
+        if [[ "$REG79_0100_VAL" != 0 ]]; then
+                echo " SoC VRD is HOT "
+        fi
+        if [[ "$REG79_1000_VAL" != 0 ]]; then
+                echo " Core VRD1 is HOT "
+        fi
+        if [[ "$REG79_2000_VAL" != 0 ]]; then
+                echo " Core VRD2 is HOT "
+        fi
+        if [[ "$REG79_4000_VAL" != 0 ]]; then
+                echo " Core VRD3 is HOT "
+        fi
+        if [[ "$REG79_0001_VAL" != 0 ]]; then
+                echo " DIMM VRD1 is HOT "
+        fi
+        if [[ "$REG79_0002_VAL" != 0 ]]; then
+                echo " DIMM VRD2 is HOT "
+        fi
+        if [[ "$REG79_0004_VAL" != 0 ]]; then
+                echo " DIMM VRD3 is HOT "
+        fi
+        if [[ "$REG79_0008_VAL" != 0 ]]; then
+                echo " DIMM VRD4 is HOT "
+        fi
+
+        getReg7AVals
+        echo "  "
+        echo " DIMM Hot Error: "
+        if [[ "$REG7A_0100_VAL" != 0 ]]; then
+                echo " DIMM channel 0 is HOT "
+        fi
+        if [[ "$REG7A_0200_VAL" != 0 ]]; then
+                echo " DIMM channel 1 is HOT "
+        fi
+        if [[ "$REG7A_0400_VAL" != 0 ]]; then
+                echo " DIMM channel 2 is HOT "
+        fi
+        if [[ "$REG7A_0800_VAL" != 0 ]]; then
+                echo " DIMM channel 3 is HOT "
+        fi
+        if [[ "$REG7A_1000_VAL" != 0 ]]; then
+                echo " DIMM channel 4 is HOT "
+        fi
+        if [[ "$REG7A_2000_VAL" != 0 ]]; then
+                echo " DIMM channel 5 is HOT "
+        fi
+        if [[ "$REG7A_4000_VAL" != 0 ]]; then
+                echo " DIMM channel 6 is HOT "
+        fi
+        if [[ "$REG7A_8000_VAL" != 0 ]]; then
+                echo " DIMM channel 7 is HOT "
+        fi
+
+        echo "  "
+        echo " Boot #1 Error: $((REG7B >> 8)) "
+        echo " Boot #2 Error: $((REG7C >> 8)) "
+
+
+        getReg7DVals
+        echo "  "
+        echo " Watchdog/Other Status: "
+        if [[ "$REG7D_0100_VAL" != 0 ]]; then
+                echo " Non-secure WDT expired "
+        fi
+        if [[ "$REG7D_0200_VAL" != 0 ]]; then
+                echo " Secure WDT expired "
+        fi
+        if [[ "$REG7D_0400_VAL" != 0 ]]; then
+                echo " Firmware WDT expired "
+        fi
+
+        getReg7EVals
+        echo "  "
+        echo " RAS internal error: "
+        if [[ "$REG7E_0100_VAL" != 0 ]]; then
+                echo " Error from SMpro "
+        fi
+        if [[ "$REG7E_0200_VAL" != 0 ]]; then
+                echo " Error from PMpro "
+        fi
+
+        # GPI Mask Regs
+        getGPIMaskRegisters
+        echo "  "
+        echo " GPI Mask Regs "
+
+        getReg50Vals
+        echo "  "
+        echo " GPI Control #0: "
+
+        if [[ "$REG50_0400_VAL" != 0 ]]; then
+                echo " Platform Booting "
+        fi
+        if [[ "$REG50_0800_VAL" != 0 ]]; then
+                echo " Critical Stop "
+        fi
+
+        getReg51Vals
+        echo "  "
+        echo " GPI Control #1: "
+
+        if [[ "$REG51_0100_VAL" != 0 ]]; then
+                echo " SoC VR HOT/Warn/Fault "
+        fi
+        if [[ "$REG51_0200_VAL" != 0 ]]; then
+                echo " Core VR HOT/Warn/Fault "
+        fi
+        if [[ "$REG51_0400_VAL" != 0 ]]; then
+                echo " DIMM VRD HOT/Warn/Fault "
+        fi
+
+        getReg52Vals
+        echo "  "
+        echo " GPI Control #2: "
+
+        if [[ "$REG52_0100_VAL" != 0 ]]; then
+                echo " DIMM HOT "
+        fi
+
+        getReg53Vals
+        echo "  "
+        echo " GPI Control #3: "
+        if [[ "$REG53_0100_VAL" != 0 ]]; then
+                echo " Core Errors "
+        fi
+        if [[ "$REG53_0200_VAL" != 0 ]]; then
+                echo " Memory Errors "
+        fi
+        if [[ "$REG53_0800_VAL" != 0 ]]; then
+                echo " PCIe Errors "
+        fi
+        if [[ "$REG53_2000_VAL" != 0 ]]; then
+                echo " Other SoC Errors "
+        fi
+        if [[ "$REG53_4000_VAL" != 0 ]]; then
+                echo " ACPI State Change "
+        fi
+        if [[ "$REG53_8000_VAL" != 0 ]]; then
+                echo " Boot Errors "
+        fi
+        if [[ "$REG53_0001_VAL" != 0 ]]; then
+                echo " RAS Internal Error "
+        fi
+
+        getReg54Vals
+        echo "  "
+        echo " GPI CE/UE Mask: "
+        if [[ "$REG54_0100_VAL" != 0 ]]; then
+                echo " Core CE "
+        fi
+        if [[ "$REG54_0200_VAL" != 0 ]]; then
+                echo " Core UE "
+        fi
+        if [[ "$REG54_0001_VAL" != 0 ]]; then
+                echo " DIMM CE "
+        fi
+        if [[ "$REG54_0002_VAL" != 0 ]]; then
+                echo " DIMM UE "
+        fi
+        if [[ "$REG54_0004_VAL" != 0 ]]; then
+                echo " PCIe CE "
+        fi
+        if [[ "$REG54_0008_VAL" != 0 ]]; then
+                echo " PCIe UE "
+        fi
+        if [[ "$REG54_0010_VAL" != 0 ]]; then
+                echo " Other CE "
+        fi
+        if [[ "$REG54_0020_VAL" != 0 ]]; then
+                echo " Other UE "
+        fi
+
+fi
diff --git a/meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-cmd/kudo.sh b/meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-cmd/kudo.sh
new file mode 100644
index 0000000..0c12fca
--- /dev/null
+++ b/meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-cmd/kudo.sh
@@ -0,0 +1,276 @@
+#!/bin/bash
+# help information
+
+source /usr/sbin/kudo-lib.sh
+
+function usage_rst() {
+  echo " kudo rst [parameter]"
+  echo "        hotswap  --> reset the whole kudo node"
+  echo "        system   --> reset the host"
+  echo "        btn      --> trigger a power button event"
+  echo "        shutdown --> send out shutdown signal to CPU"
+  echo "        display  --> "
+}
+
+function usage_led() {
+
+  echo " kudo led 'att'/'boot' [parameter]"
+  echo "        on --> change to CPU console"
+  echo "        off --> change to CPU 0 SCP console"
+  echo "        status --> change to CPU 1 SCP console"
+}
+
+function usage_uart() {
+  echo " kudo uart [parameter]"
+  echo "        host --> change to CPU console"
+  echo "        scp1 --> change to CPU 0 SCP console"
+  echo "        scp2 --> change to CPU 1 SCP console"
+  echo "        hosthr --> change CPU console to header"
+  echo "        scphr --> change SCP console to header"
+  echo "        display  --> "
+}
+
+function usage() {
+  echo " kudo BMC console system utilities"
+  echo " kudo [optional] [parameter]"
+  echo "   rst   --> reset traget device"
+  echo "   fw    --> get version"
+  echo "   uart  --> control the uart mux"
+  echo "   led   --> control the leds"
+}
+
+function reset() {
+  case $1 in
+    hotswap)
+      # Virtual reset #94
+      set_gpio_ctrl 94 out 1
+      ;;
+    system)
+      # S0 system reset #65
+      set_gpio_ctrl 65 out 0
+      sleep 1
+      set_gpio_ctrl 65 out 1
+      ;;
+    btn)
+      # power button #203
+      set_gpio_ctrl 203 out 1
+      sleep 1
+      set_gpio_ctrl 203 out 0
+      ;;
+    shutdown)
+      # BMC_CPU_SHD_REQ #70
+      set_gpio_ctrl 70 out 0
+      sleep 3
+      set_gpio_ctrl 70 out 1
+      ;;
+    forceOff)
+      # power button #203
+      set_gpio_ctrl 203 out 1
+      sleep 6
+      set_gpio_ctrl 203 out 0
+      ;;
+    display)
+      echo "Virtual reset   #94" $(get set_gpio_ctrl 94)
+      echo "S0 System reset #65" $(get set_gpio_ctrl 65)
+      echo "Power Button   #203" $(get set_gpio_ctrl 203)
+      echo "BMC_CPU SHD Req #70" $(get set_gpio_ctrl 70)
+      ;;
+    *)
+      usage_rst
+    ;;
+  esac
+}
+
+function fw_rev() {
+  BMC_CPLD_VER_FILE="/run/cpld0.version"
+  MB_CPLD_VER_FILE="/run/cpld1.version"
+
+  cmd=$(cat $BMC_CPLD_VER_FILE)
+  echo " BMC_CPLD: " $cmd
+  cmd=$(cat $MB_CPLD_VER_FILE)
+  echo " MB_CPLD: " $cmd
+
+  cmd=$(cat /etc/os-release | grep VERSION -w | cut -d '=' -f 2)
+  echo " BMC        : " ${cmd}
+
+  #BMC PWR Sequencer
+  i2cset -y -f -a 14 0x59 0xfe 0x0000 w
+  cmd=$(i2cget -y -f -a 14 0x59 0xfe i 2 | awk '{print substr($0,3)}')
+  echo " BMC PowerSequencer : ${cmd}"
+  #only display with smbios exists
+  if [[ -e /var/lib/smbios/smbios2 ]]; then
+    cmd=$(busctl introspect xyz.openbmc_project.Smbios.MDR_V2 \
+            /xyz/openbmc_project/inventory/system/chassis/motherboard/bios | grep Version | awk '{print $4}')
+    echo " Bios: $cmd"
+  fi
+
+  cmd=$(i2cget -f -y 2 0x4f 0x1 w);
+  echo " SCP Firmware: ${cmd}"
+
+  adm1266_ver  | grep REVISION
+
+}
+
+function uartmux() {
+  case $1 in
+    host)
+      set_gpio_ctrl 167 out 1
+      ;;
+    scp1)
+      set_gpio_ctrl 161 out 1
+      set_gpio_ctrl 177 out 1
+      set_gpio_ctrl 198 out 0
+      ;;
+    scp2)
+      set_gpio_ctrl 161 out 1
+      set_gpio_ctrl 177 out 1
+      set_gpio_ctrl 198 out 1
+      ;;
+    hosthr)
+      set_gpio_ctrl 167 out 0
+      ;;
+    scphr)
+      set_gpio_ctrl 161 out 0
+      set_gpio_ctrl 177 out 0
+      ;;
+    display)
+      if [ $(get_gpio_ctrl 167) -eq 1 ]; then
+        echo " CPU host to BMC console"
+      else
+        echo " CPU host to header"
+      fi
+      if [ $(get_gpio_ctrl 161) -eq 1 ] && [ $(get_gpio_ctrl 177) -eq 1 ]; then
+        if [ $(get_gpio_ctrl 198) -eq 1 ]; then
+          echo " SCP2 host to BMC console"
+        else
+          echo " SCP1 host to BMC console"
+        fi
+      elif [ $(get_gpio_ctrl 161) -eq 0 ] && [ $(get_gpio_ctrl 177) -eq 0 ]; then
+        if [ $(get_gpio_ctrl 198) -eq 1 ]; then
+          echo " SCP2 host to Header"
+        else
+          echo " SCP1 host to Header"
+        fi
+      else
+        echo "It's unknown status"
+        echo "167" $(get_gpio_ctrl 167)
+        echo "161" $(get_gpio_ctrl 161)
+        echo "177" $(get_gpio_ctrl 177)
+        echo "198" $(get_gpio_ctrl 198)
+      fi
+      ;;
+    *)
+      usage_uart
+      ;;
+  esac
+}
+
+function ledtoggle() {
+
+    CurrentLED=$( i2cget -y -f -a 34 0x76 0x05 i 1 | cut -d ' ' -f 2)
+  case $1 in
+    boot)
+        cmd=$((($CurrentLED & 0x40) != 0))
+        case $2 in
+         on)
+            #turn on LED
+            if [[ $cmd -eq 0 ]]; then
+                setValue=$(( 0x40 + $CurrentLED ))
+                i2cset -y -f -a 34 0x76 0x10 $setValue
+            fi
+            ;;
+         off)
+            #turn off led
+            if [[ $cmd -eq 1 ]]; then
+                setValue=$(( 0x80 & $CurrentLED ))
+                i2cset -y -f -a 34 0x76 0x10 $setValue
+            fi
+            ;;
+        toggle)
+            #turn on LED
+                setValue=$(( 0x40 ^ $CurrentLED ))
+                i2cset -y -f -a 34 0x76 0x10 $setValue
+            ;;
+         status)
+            #displayLED status
+            if [[ $cmd -eq 1 ]]; then
+                echo "on"
+            else
+                echo "off"
+            fi
+            ;;
+         *)
+            usage_led
+            ;;
+        esac
+      ;;
+    att)
+        cmd=$((($CurrentLED & 0x80) != 0))
+        case $2 in
+         on)
+            #turn on LED
+            if [[ $cmd -eq 0 ]]; then
+                setValue=$(( 0x80 + $CurrentLED ))
+                i2cset -y -f -a 34 0x76 0x10 $setValue
+            fi
+            ;;
+         off)
+            #turn off led
+            if [[ $cmd -eq 1 ]]; then
+                 setValue=$(( 0x40 & $CurrentLED ))
+                i2cset -y -f -a 34 0x76 0x10 $setValue
+            fi
+            ;;
+        toggle)
+            #turn on LED
+            setValue=$(( 0x80 ^ $CurrentLED ))
+            i2cset -y -f -a 34 0x76 0x10 $setValue
+            ;;
+         status)
+            #displayLED status
+            if [[ $cmd -eq 1 ]]; then
+                echo "on"
+            else
+                echo "off"
+            fi
+            ;;
+         *)
+            usage_led
+            ;;
+        esac
+      ;;
+    *)
+        usage_led
+        ;;
+    esac
+}
+
+function usblist() {
+  for i in {0..8}
+  do
+    cmd="devmem 0xf083"$i"154"
+    printf "udc%d : 0xF803%d154-" "$i" "$i"
+    $cmd
+   done
+}
+
+case $1 in
+  rst)
+    reset $2
+    ;;
+  fw)
+    fw_rev
+    ;;
+  uart)
+    uartmux $2
+    ;;
+  usb)
+    usblist
+    ;;
+  led)
+    ledtoggle $2 $3
+    ;;
+  *)
+    usage
+    ;;
+esac
diff --git a/meta-fii/meta-kudo/recipes-kudo/packagegroups/packagegroup-kudo-apps.bb b/meta-fii/meta-kudo/recipes-kudo/packagegroups/packagegroup-kudo-apps.bb
index 06161e1..f1ca264 100644
--- a/meta-fii/meta-kudo/recipes-kudo/packagegroups/packagegroup-kudo-apps.bb
+++ b/meta-fii/meta-kudo/recipes-kudo/packagegroups/packagegroup-kudo-apps.bb
@@ -28,6 +28,7 @@
     ncsid \
     gbmc-mac-config \
     kudo-boot \
+    kudo-cmd \
     "
 
 SUMMARY_${PN}-kudo-fw = "KUDO Firmware"