:: Seco srl - Arezzo -
@echo off
echo.
echo KabyLake and SkyLake BIOS updater - Windows 64bit Version
echo.

:: Sanitiy check and init parameters
if "%1"=="" goto ErrorUsage
if "%2"=="" set NVSfile=%1
if not "%2"=="" set NVSfile=%2

:: Saving LAN setting
echo.
echo Dumping old BIOS image...
H2OFFT-Wx64 OldBios.bin -g -n -DAM
IF ERRORLEVEL 1 GOTO ErrorSave

:: Programming new image
echo.
echo Programming new BIOS image...
echo.
H2OFFT-Wx64 %1 -ALL -N %3 %4 %5 %6 %7 %8 %9
IF ERRORLEVEL 1 GOTO ErrorBIOS

:: Restoring NVS
echo.
echo Restoring NVS...
echo.
H2OFFT-Wx64 %NVSfile% -SPN -N -Q
IF ERRORLEVEL 1 GOTO ErrorBIOS

:: Restoring LAN setting
echo Restoring MAC address and LED setting...
echo.
H2OFFT-Wx64 OldBios.bin -GBE -N -Q
IF ERRORLEVEL 1 GOTO ErrorBIOS
del OldBios.bin

:: Done
echo Done: you can now safely turn the power off.
GOTO End

:ErrorUsage
echo Usage: %0 BIOSfile [DUMPfile] [Options]
echo Where:
echo BIOSfile is the MANDATORY BIOS binary image
echo DUMPfile is the optional dumped BIOS file
echo Options are additional command line options
echo.
echo See documentation for more information
GOTO End

:ErrorSave
echo BIOS dump error!!
GOTO End

:ErrorBIOS
echo BIOS programming error!!

:End
