@echo off

SET BIOS_NAME=NEW70112.FD
SET EC_NAME=KBCA112A
SET ME_VERSION=6.0.31.1208

: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 -i -n -p6 %EC_NAME%.rom
cls
flashit %BIOS_NAME% /all
goto exit

:FlashBIOS
spi /flash -v20000 -ac -i -n -p6 %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
