#!/bin/sh
#   flashbios-s3
fwdir=$DeployPath/update
flashdir=$DeployPath/Linux/ofu
logfile=$DeploymentStore/flashbios.log
ADDLOG=addLogRecord
# ADDLOG=echo

date >$logfile
cd $flashdir
cp -f $DeployPath/Linux/drivers/amifldrv_mod.o .  2>>$logfile
# Sometimes there is a mismatch in the flashupdt afu version, so
# copy over the afu app from the afu directory.
# cp -f $DeployPath/Linux/drivers/afu/afulnx2_32 .  2>>$logfile

# Display the flash versions
./flashupdt -i  >>$logfile 2>&1
ret=$?
if [ $ret -eq 0 ]
then
 $ADDLOG FLASH INFO "Success: flashupdt info completed"
else
 $ADDLOG FLASH ERROR "Error $ret: flashupdt info failed"
fi

# Flash the BIOS, and firmware + FRU/SDR also if S5000
./flashupdt -u $fwdir >>$logfile 2>&1
ret=$?
if [ $ret -eq 0 ]
then
 $ADDLOG FLASH INFO "Success: flashupdt completed"
else
 $ADDLOG FLASH ERROR "Error $ret: flashupdt failed"
fi

echo "flashbios from $fwdir returned $ret"

exit $ret
