blob: fb4b9700aa46b072743fce5478d63ba2d1173e65 [file] [log] [blame]
Delphine CC Chiu5fd67bd2024-04-10 20:06:19 +08001#!/bin/bash
2
3sd_eid=$(($1 * 10))
4wf_eid=$(($1 * 10 + 2))
5
6# It takes about 6 seconds for setting up MCTP endpoint after slot plugged-in
7sleep 10
8# Check if we got WF BIC's EID
9wf_eid=$(($1 * 10 + 2))
10busctl get-property xyz.openbmc_project.MCTP /xyz/openbmc_project/mctp/1/"$wf_eid" xyz.openbmc_project.MCTP.Endpoint EID
11status=$?
12if [ $status -eq 0 ]; then
13 exit 0
14fi
15
16count=0
17while [ $count -lt 3 ]; do
18 # Check WF BIC status
19 output=$(pldmtool raw -m "$sd_eid" -d 0x80 0x02 0x3A 0x4c 0xff)
20 status=$?
21 if [ $status -ne 0 ]; then
22 echo "Error executing pldmtool command"
23 exit 1
24 fi
25 # Get data at Rx line
26 rx_data=$(echo "$output" | grep "Rx:" | awk '{for (i=3; i<=NF; i++) print $i}')
27 # Get last byte
28 wf_ready=$(echo "$rx_data" | tail -n 1)
29 # 02 means WF BIC ready, otherwise 01.
30 if [ "$wf_ready" == "02" ]; then
31 busctl call xyz.openbmc_project.MCTP /xyz/openbmc_project/mctp au.com.CodeConstruct.MCTP SetupEndpointByConfigPath s /xyz/openbmc_project/inventory/system/board/Yosemite_4_Wailua_Falls_Slot_"$1"/BIC
32 break
33 else
34 count=$((count + 1))
35 sleep 2
36 fi
37done