meta-google: ipmi-fru-sh: Fix word width detection
Sometimes, the first value returned is not stable and not what is
expected from the FRU. If we perform multiple queries we can get a
stable reading and correctly detect word length.
Change-Id: I73a88870bef231566f0249d0629c751be6a5002c
Signed-off-by: William A. Kennington III <wak@google.com>
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 d02eeab..29b8e7f 100644
--- a/meta-google/recipes-google/ipmi/ipmi-fru-sh/lib.sh
+++ b/meta-google/recipes-google/ipmi/ipmi-fru-sh/lib.sh
@@ -80,8 +80,19 @@
IPMI_FRU_EEPROM_FILE["$idx"]=/etc/fru/baseboard.fru.bin
else
local offset_bw=offset_2bw
- local rsp
- rsp=$(i2ctransfer -f -y ${busaddr[0]} $(offset_1bw ${busaddr[1]} 0) r1) || return
+ local last=0
+ local rsp=0x100
+ local start=$SECONDS
+ # Query the FRU multiple times to ensure the return value is stabilized
+ while (( last != rsp )); do
+ # It shouldn't take > 0.1s to stabilize, limit instability
+ if (( SECONDS - start >= 10 )); then
+ echo "Timed out determining offset for ${busaddr[0]}@${busaddr[1]}" >&2
+ return 1
+ fi
+ last=$rsp
+ rsp=$(i2ctransfer -f -y ${busaddr[0]} $(offset_1bw ${busaddr[1]} 0) r1) || return
+ done
# FRUs never start with 0xff bytes, so we can figure out addressing mode
if (( rsp != 0xff )); then
offset_bw=offset_1bw