@ECHO OFF
SETLOCAL

ECHO Toradex NVFlash Update Script
ECHO ***********************************
IF not "%1"=="" (
set VERSION=%1
IF not "%2"=="" (
set RAM=%2
goto BEGIN3
)
goto BEGIN2
)

ECHO Do you like to program: 
:BEGIN1
ECHO 1) Moduletype V1.1
ECHO 2) Moduletype V1.2
ECHO 3) use SD Card (for V1.1 or V1.2)
ECHO Please choose a number:
SET UPDATE_CHOICE=1
SET /P UPDATE_CHOICE=
IF %UPDATE_CHOICE%==1 set VERSION=V1_1
IF %UPDATE_CHOICE%==2 set VERSION=V1_2
IF %UPDATE_CHOICE%==3 set VERSION=hsmmc
IF not defined VERSION (
ECHO Input not valid, try again 
GOTO BEGIN1
)

ECHO Modules RAM size is: 
:BEGIN2
ECHO 1) 256MB
ECHO 2) 512MB
ECHO Please choose a number:
SET UPDATE_CHOICE=1
SET /P UPDATE_CHOICE=
IF %UPDATE_CHOICE%==1 set RAM=256
IF %UPDATE_CHOICE%==2 set RAM=512
IF not defined RAM (
ECHO Input not valid, try again 
GOTO BEGIN1
)

:BEGIN3
set CFG_FILE=lnx_hsmmc.cfg
IF not "%VERSION%"=="hsmmc" (
copy USR.yaffs2_%RAM%_%VERSION% USR.yaffs2 
set VERSION=%VERSION%_nand
set CFG_FILE=lnx_nand.cfg
)

..\nvflash.exe --bct ColibriT20_333_%RAM%_%VERSION%.bct --setbct --configfile  %CFG_FILE%  --create --bl loader.nb0 --go
del USR.yaffs2

echo .
if "%1"=="" pause