summaryrefslogtreecommitdiff
path: root/meta-google
diff options
context:
space:
mode:
authorWilliam A. Kennington III <wak@google.com>2021-10-13 09:25:05 +0300
committerWilliam A. Kennington III <wak@google.com>2021-10-14 21:38:20 +0300
commita810614ad3f15e006f40f5214f9e85f93ccee37b (patch)
tree7a2d75411c7f985fd7df77cb209788f3acf58f3c /meta-google
parentbe156a84b677699a557a27f77bf8db29d68e6d19 (diff)
downloadopenbmc-a810614ad3f15e006f40f5214f9e85f93ccee37b.tar.xz
meta-google: ipmi-fru-sh: Add lookup for FruDevice names
This makes it possible to specify a FRU lookup by a dynamically discovered FRUs from entity manager. Change-Id: Icf83aa3eff1cbc08a8fa3f99754e5c10e3e583fc Signed-off-by: William A. Kennington III <wak@google.com>
Diffstat (limited to 'meta-google')
-rw-r--r--meta-google/recipes-google/ipmi/ipmi-fru-sh/lib.sh40
1 files changed, 40 insertions, 0 deletions
diff --git a/meta-google/recipes-google/ipmi/ipmi-fru-sh/lib.sh b/meta-google/recipes-google/ipmi/ipmi-fru-sh/lib.sh
index 3ae0f0864..940be7fb0 100644
--- a/meta-google/recipes-google/ipmi/ipmi-fru-sh/lib.sh
+++ b/meta-google/recipes-google/ipmi/ipmi-fru-sh/lib.sh
@@ -44,6 +44,33 @@ of_name_to_eeprom() {
declare -A IPMI_FRU_EEPROM_FILE=()
+ipmi_fru_device_to_file() {
+ local fdn="$1"
+
+ local json
+ json="$(busctl -j call xyz.openbmc_project.FruDevice \
+ /xyz/openbmc_project/FruDevice/"$fdn" org.freedesktop.DBus.Properties \
+ GetAll s xyz.openbmc_project.FruDevice)" || return 80
+
+ local jqq='.data[0] | (.BUS.data | tostring) + " " + (.ADDRESS.data | tostring)'
+ local busaddr
+ busaddr="$(echo "$json" | jq -r "$jqq")" || return
+
+ # FRU 0 is hardcoded and FruDevice does not report the correct bus for it
+ # Hardcode a workaround for this specifically known bus
+ if [ "$busaddr" = '0 0' ]; then
+ echo "/etc/fru/baseboard.fru.bin"
+ else
+ local dev="$(printf '%d-%04x' $busaddr)"
+ local efile="/sys/bus/i2c/devices/$dev/eeprom"
+ # The at24 eeprom driver is not guaranteed to be bound
+ if [ ! -e "$efile" ]; then
+ echo "$dev" >/sys/bus/i2c/drivers/at24/bind || return
+ fi
+ echo "$efile"
+ fi
+}
+
ipmi_fru_alloc() {
local name="$1"
local -n ret="$2"
@@ -58,6 +85,19 @@ ipmi_fru_alloc() {
local file
file="$(of_name_to_eeprom "$ofn")" || return
IPMI_FRU_EEPROM_FILE["$ret"]="$file"
+ elif [[ "$name" =~ ^frudev-name:(.*)$ ]]; then
+ local fdn="${BASH_REMATCH[1]}"
+ local start=$SECONDS
+ local file
+ while (( SECONDS - start < 60 )); do
+ local rc=0
+ file="$(ipmi_fru_device_to_file "$fdn")" || rc=$?
+ (( rc == 0 )) && break
+ # Immediately return any errors, 80 is special to signify retry
+ (( rc != 80 )) && return $rc
+ sleep 1
+ done
+ IPMI_FRU_EEPROM_FILE["$ret"]="$file"
else
echo "Invalid IPMI FRU eeprom specification: $name" >&2
return 1