blob: 024336d208238aa0130fdb4701527b906b67461f [file] [log] [blame]
ThuBaNguyen7b452822021-06-06 14:36:07 +07001#!/bin/bash
2
Thang Q. Nguyendde1fed2021-11-04 08:30:27 +00003# shellcheck source=/dev/null
ThuBaNguyen7b452822021-06-06 14:36:07 +07004source /usr/sbin/gpio-defs.sh
5source /usr/sbin/gpio-lib.sh
6
ThuBaNguyen7b452822021-06-06 14:36:07 +07007createFile=$1
ThuBaNguyen7b452822021-06-06 14:36:07 +07008
Thang Q. Nguyendde1fed2021-11-04 08:30:27 +00009# Check current Host status. Do nothing when the Host is currently ON
10st=$(busctl get-property xyz.openbmc_project.State.Host \
11 /xyz/openbmc_project/state/host0 xyz.openbmc_project.State.Host \
12 CurrentHostState | cut -d"." -f6)
13if [ "$st" == "Running\"" ]; then
14 exit 0
ThuBaNguyen7b452822021-06-06 14:36:07 +070015fi
16
17# Time out to check S0_FW_BOOT_OK is 60 seconds
18cnt=60
19val=0
Thang Q. Nguyendde1fed2021-11-04 08:30:27 +000020while [ "$cnt" -gt 0 ];
ThuBaNguyen7b452822021-06-06 14:36:07 +070021do
Thang Q. Nguyendde1fed2021-11-04 08:30:27 +000022 val=$(gpio_get_val "$S0_CPU_FW_BOOT_OK")
23 cnt=$((cnt - 1))
24 echo "$cnt S0_CPU_FW_BOOT_OK = $val"
25 if [ "$val" == 1 ]; then
26 # Sleep 5 second before the host is ready
27 sleep 5
28 if [ "$createFile" == 1 ]; then
29 mkdir -p /run/openbmc
30 echo "Creating /run/openbmc/host@0-on"
31 touch /run/openbmc/host@0-on
32 fi
33 exit 0
34 fi
35 sleep 1
ThuBaNguyen7b452822021-06-06 14:36:07 +070036done
37
38exit 1