meta-ampere: mtjade: support FRU inventory
Support to parse the Mt.Jade FRU device, map FRU data with inventory
information and report FRU content via IPMI.
Tested:
1. Run IPMI fru print command:
root@mtjade:~# ipmitool fru print
FRU Device Description : Builtin FRU Device (ID 0)
Chassis Type : Rack Mount Chassis
Chassis Serial : A1A1-A000-0000000000123
Board Mfg Date : Fri Feb 5 00:00:00 2021 UTC
Board Mfg : WIWYNN
Board Product : Mt.Jade Motherboard
Board Serial : B8103010002500900019J0LB
Board Part Number : B81.03010.0026
Product Manufacturer : WIWYNN
Product Name : Mt.Jade Server System
Product Part Number : B81.03001.0009
Product Version : EVT2
Product Serial : B810300100050130002DN0SD
2. Check FRU inventory reoirt from REST
/xyz/openbmc_project/inventory/system/chassis/motherboard
Signed-off-by: Thang Q. Nguyen <thang@os.amperecomputing.com>
Change-Id: I231d5766b2f89a535d850eb437d63a9db84fb846
diff --git a/meta-ampere/meta-jade/recipes-phosphor/configuration/mtjade-yaml-config.bb b/meta-ampere/meta-jade/recipes-phosphor/configuration/mtjade-yaml-config.bb
new file mode 100644
index 0000000..66238dc
--- /dev/null
+++ b/meta-ampere/meta-jade/recipes-phosphor/configuration/mtjade-yaml-config.bb
@@ -0,0 +1,27 @@
+SUMMARY = "YAML configuration for Mt.Jade"
+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://mtjade-ipmi-fru.yaml \
+ file://mtjade-ipmi-fru-properties.yaml \
+ "
+
+S = "${WORKDIR}"
+
+do_install() {
+ cat mtjade-ipmi-fru.yaml > fru-read.yaml
+ install -m 0644 -D mtjade-ipmi-fru-properties.yaml \
+ ${D}${datadir}/${BPN}/ipmi-extra-properties.yaml
+ install -m 0644 -D fru-read.yaml \
+ ${D}${datadir}/${BPN}/ipmi-fru-read.yaml
+}
+
+FILES_${PN}-dev = " \
+ ${datadir}/${BPN}/ipmi-extra-properties.yaml \
+ ${datadir}/${BPN}/ipmi-fru-read.yaml \
+ "
+
+ALLOW_EMPTY_${PN} = "1"
diff --git a/meta-ampere/meta-jade/recipes-phosphor/configuration/mtjade-yaml-config/mtjade-ipmi-fru-properties.yaml b/meta-ampere/meta-jade/recipes-phosphor/configuration/mtjade-yaml-config/mtjade-ipmi-fru-properties.yaml
new file mode 100644
index 0000000..db8de9f
--- /dev/null
+++ b/meta-ampere/meta-jade/recipes-phosphor/configuration/mtjade-yaml-config/mtjade-ipmi-fru-properties.yaml
@@ -0,0 +1,23 @@
+/system/chassis/motherboard:
+ xyz.openbmc_project.Inventory.Decorator.Replaceable:
+ FieldReplaceable: 'true'
+ xyz.openbmc_project.Inventory.Decorator.Cacheable:
+ Cached: 'true'
+ xyz.openbmc_project.Inventory.Item:
+ Present: 'true'
+
+/system/chassis:
+ xyz.openbmc_project.Inventory.Decorator.Replaceable:
+ FieldReplaceable: 'true'
+ xyz.openbmc_project.Inventory.Decorator.Cacheable:
+ Cached: 'true'
+ xyz.openbmc_project.Inventory.Item:
+ Present: 'true'
+
+/system:
+ xyz.openbmc_project.Inventory.Decorator.Replaceable:
+ FieldReplaceable: 'true'
+ xyz.openbmc_project.Inventory.Decorator.Cacheable:
+ Cached: 'true'
+ xyz.openbmc_project.Inventory.Item:
+ Present: 'true'
diff --git a/meta-ampere/meta-jade/recipes-phosphor/configuration/mtjade-yaml-config/mtjade-ipmi-fru.yaml b/meta-ampere/meta-jade/recipes-phosphor/configuration/mtjade-yaml-config/mtjade-ipmi-fru.yaml
new file mode 100644
index 0000000..80bcce4
--- /dev/null
+++ b/meta-ampere/meta-jade/recipes-phosphor/configuration/mtjade-yaml-config/mtjade-ipmi-fru.yaml
@@ -0,0 +1,85 @@
+0x00:
+ /system/chassis/motherboard:
+ entityID: 7
+ entityInstance: 1
+ interfaces:
+ xyz.openbmc_project.Inventory.Decorator.Asset:
+ BuildDate:
+ IPMIFruProperty: Mfg Date
+ IPMIFruSection: Board
+ PartNumber:
+ IPMIFruProperty: Part Number
+ IPMIFruSection: Board
+ Manufacturer:
+ IPMIFruProperty: Manufacturer
+ IPMIFruSection: Board
+ SerialNumber:
+ IPMIFruProperty: Serial Number
+ IPMIFruSection: Board
+ xyz.openbmc_project.Inventory.Item:
+ PrettyName:
+ IPMIFruProperty: Name
+ IPMIFruSection: Board
+ xyz.openbmc_project.Inventory.Item.NetworkInterface:
+ MACAddress:
+ IPMIFruProperty: Custom Field 1
+ IPMIFruSection: Board
+ xyz.openbmc_project.Inventory.Decorator.VendorInformation:
+ CustomField1:
+ IPMIFruProperty: FRU File ID
+ IPMIFruSection: Board
+ xyz.openbmc_project.Common.UUID:
+ UUID:
+ IPMIFruProperty: UUID
+ IPMIFruSection: MultiRecord
+ /system/chassis:
+ entityID: 23
+ entityInstance: 1
+ interfaces:
+ xyz.openbmc_project.Inventory.Decorator.Asset:
+ SerialNumber:
+ IPMIFruProperty: Serial Number
+ IPMIFruSection: Chassis
+ PartNumber:
+ IPMIFruProperty: Part Number
+ IPMIFruSection: Chassis
+ Model:
+ IPMIFruProperty: Type
+ IPMIFruSection: Chassis
+ xyz.openbmc_project.Inventory.Decorator.VendorInformation:
+ CustomField2:
+ IPMIFruProperty: Custom Field 1
+ IPMIFruSection: Chassis
+ /system:
+ entityID: 7
+ entityInstance: 2
+ interfaces:
+ xyz.openbmc_project.Inventory.Item:
+ PrettyName:
+ IPMIFruProperty: Name
+ IPMIFruSection: Product
+ xyz.openbmc_project.Inventory.Decorator.Asset:
+ PartNumber:
+ IPMIFruProperty: Model Number
+ IPMIFruSection: Product
+ Manufacturer:
+ IPMIFruProperty: Manufacturer
+ IPMIFruSection: Product
+ SerialNumber:
+ IPMIFruProperty: Serial Number
+ IPMIFruSection: Product
+ xyz.openbmc_project.Inventory.Decorator.Revision:
+ Version:
+ IPMIFruProperty: Version
+ IPMIFruSection: Product
+ xyz.openbmc_project.Inventory.Decorator.AssetTag:
+ AssetTag:
+ IPMIFruProperty: Asset Tag
+ IPMIFruSection: Product
+ xyz.openbmc_project.Inventory.Decorator.VendorInformation:
+ CustomField1:
+ IPMIFruProperty: FRU File ID
+ IPMIFruSection: Product
+ CustomField2:
+ IPMIFruProperty: Custom Field 1
+ IPMIFruSection: Product
diff --git a/meta-ampere/meta-jade/recipes-phosphor/ipmi/phosphor-ipmi-fru/obmc/eeproms/system/chassis/motherboard b/meta-ampere/meta-jade/recipes-phosphor/ipmi/phosphor-ipmi-fru/obmc/eeproms/system/chassis/motherboard
new file mode 100644
index 0000000..f049834
--- /dev/null
+++ b/meta-ampere/meta-jade/recipes-phosphor/ipmi/phosphor-ipmi-fru/obmc/eeproms/system/chassis/motherboard
@@ -0,0 +1,2 @@
+SYSFS_PATH=/sys/bus/i2c/devices/3-0050/eeprom
+FRUID=0
diff --git a/meta-ampere/meta-jade/recipes-phosphor/ipmi/phosphor-ipmi-fru_%.bbappend b/meta-ampere/meta-jade/recipes-phosphor/ipmi/phosphor-ipmi-fru_%.bbappend
new file mode 100644
index 0000000..be3e7fe
--- /dev/null
+++ b/meta-ampere/meta-jade/recipes-phosphor/ipmi/phosphor-ipmi-fru_%.bbappend
@@ -0,0 +1,26 @@
+inherit obmc-phosphor-systemd
+
+DEPENDS_append_mtjade = " mtjade-yaml-config"
+
+EXTRA_OECONF_mtjade = " \
+ YAML_GEN=${STAGING_DIR_HOST}${datadir}/mtjade-yaml-config/ipmi-fru-read.yaml \
+ PROP_YAML=${STAGING_DIR_HOST}${datadir}/mtjade-yaml-config/ipmi-extra-properties.yaml \
+ "
+FILESEXTRAPATHS_prepend_mtjade := "${THISDIR}/${PN}:"
+
+EEPROM_NAMES = "motherboard"
+
+EEPROMFMT = "system/chassis/{0}"
+EEPROM_ESCAPEDFMT = "system-chassis-{0}"
+EEPROMS = "${@compose_list(d, 'EEPROMFMT', 'EEPROM_NAMES')}"
+EEPROMS_ESCAPED = "${@compose_list(d, 'EEPROM_ESCAPEDFMT', 'EEPROM_NAMES')}"
+
+ENVFMT = "obmc/eeproms/{0}"
+SYSTEMD_ENVIRONMENT_FILE_${PN}_append_mtjade := "${@compose_list(d, 'ENVFMT', 'EEPROMS')}"
+
+TMPL = "obmc-read-eeprom@.service"
+TGT = "multi-user.target"
+INSTFMT = "obmc-read-eeprom@{0}.service"
+FMT = "../${TMPL}:${TGT}.wants/${INSTFMT}"
+
+SYSTEMD_LINK_${PN}_append_mtjade := "${@compose_list(d, 'FMT', 'EEPROMS_ESCAPED')}"
diff --git a/meta-ampere/meta-jade/recipes-phosphor/ipmi/phosphor-ipmi-host_%.bbappend b/meta-ampere/meta-jade/recipes-phosphor/ipmi/phosphor-ipmi-host_%.bbappend
new file mode 100644
index 0000000..980746e
--- /dev/null
+++ b/meta-ampere/meta-jade/recipes-phosphor/ipmi/phosphor-ipmi-host_%.bbappend
@@ -0,0 +1,14 @@
+FILESEXTRAPATHS_append_mtjade := "${THISDIR}/${PN}:"
+
+DEPENDS_append_mtjade = " mtjade-yaml-config"
+
+RRECOMMENDS_${PN} += "ipmitool"
+
+EXTRA_OECONF_mtjade = " \
+ FRU_YAML_GEN=${STAGING_DIR_HOST}${datadir}/mtjade-yaml-config/ipmi-fru-read.yaml \
+ "
+
+do_install_append_mtjade(){
+ install -d ${D}${includedir}/phosphor-ipmi-host
+ install -m 0644 -D ${S}/selutility.hpp ${D}${includedir}/phosphor-ipmi-host
+}