#!/bin/bash
echo "================= Update Both 1st + 2nd BIOS Region ================"
#for non-boot image
if [ -f "./afulnx_64" ] && [ -f "../../../flash_G.rom" ]; then
	./afulnx_64 ../../../flash_G.rom /p /b /n /k /l /RLC:EJ /SSB:{NONBOOT16M}
fi

#for boot image
./afulnx_64 ../../../flash_T.rom /p /b /n /k /l /RLC:EJ 
declare -i EXIT_STATUS="$?"
if [ $EXIT_STATUS -ne 0 ]; then
	if [ "$EXIT_STATUS" -ne 100 ]; then
		echo "============ Update 1st BIOS FAIL ============="
	else
		./afulnx_64 /OEMCMD:2B
		echo "============ Update Both 1st + 2nd BIOS Region Complete ========="
	fi
else
	./afulnx_64 /OEMCMD:2B
	echo "============ Update Both 1st + 2nd BIOS Region Complete ========="
fi
