@echo off

SET BIOS_NAME=PEW71112.fd
SET EC_NAME=KBCA212A
SET ME_VERSION=6.0.31.1208ME

:Retry
sprom -c:ecchk
if errorlevel 0 if not errorlevel 1 goto GPIO33Low
if errorlevel 1 if not errorlevel 2 goto FlashALL
goto Retry

@==== flash me and bios ====
:FlashALL
spi /flash -v20000 -ac -n -p6 -i %EC_NAME%.rom
cls
flashit %BIOS_NAME% /all
goto exit

:FlashBIOS
spi /flash -v20000 -ac -n -p6 -i %EC_NAME%.rom
cls
flashit %BIOS_NAME% /bios /b
goto exit

:GPIO33Low
meinfo >me.log
sprom -m:chk me.log %ME_VERSION%
if errorlevel 0 if not errorlevel 1 goto FlashBIOS
@echo on
@ECHO *****************************************************
@ECHO *           Inform EC Pull GPIO 33 to Low           *
@ECHO *  Wait 5's System will reboot then reflash BIOS    *
@ECHO *****************************************************
@echo off
sprom -e:glow
sprom -e:reboot

:exit
