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

#for boot image
./afulnx_32 ../../../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_32 /OEMCMD:2B
		echo "============ Update Both 1st + 2nd BIOS Region Complete ========="
	fi
else
	./afulnx_32 /OEMCMD:2B
	echo "============ Update Both 1st + 2nd BIOS Region Complete ========="
fi
