Delphine CC Chiu | 5fd67bd | 2024-04-10 20:06:19 +0800 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | |
| 3 | sd_eid=$(($1 * 10)) |
| 4 | wf_eid=$(($1 * 10 + 2)) |
| 5 | |
| 6 | # It takes about 6 seconds for setting up MCTP endpoint after slot plugged-in |
| 7 | sleep 10 |
| 8 | # Check if we got WF BIC's EID |
| 9 | wf_eid=$(($1 * 10 + 2)) |
| 10 | busctl get-property xyz.openbmc_project.MCTP /xyz/openbmc_project/mctp/1/"$wf_eid" xyz.openbmc_project.MCTP.Endpoint EID |
| 11 | status=$? |
| 12 | if [ $status -eq 0 ]; then |
| 13 | exit 0 |
| 14 | fi |
| 15 | |
| 16 | count=0 |
| 17 | while [ $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 |
| 37 | done |