批处理文件实例参考

@echo off
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::
:: xxxxxxxxx
:: xxxxxxx
::
:: mkspi.bat  <MAC> <Configuration> <Content> <product> <PrmFile>  <BinFileName> [Switch file name]
::
:: Example 00-C5-D9-00-00-22 Phone_4-20_0.0 OEM  CG3110M ./some_prm.inf
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Cleanup
del /Q tmp/OSEC.HEX >NUL 2>&1
del /Q tmp/MSEC.HEX >NUL 2>&1
del /Q tmp/prm.inf >NUL 2>&1
del /Q tmp/all.inf >NUL 2>&1


if "%1"=="-?" goto USAGE
if "%1"=="-h" goto USAGE
IF .%1==. goto USAGE
IF .%2==. goto ERROR
IF .%3==. goto ERROR
IF .%4==. goto ERROR
IF .%6==. goto ERROR

if "%~6"=="" goto DEFOUT
set binfilename=%6
goto RENOUT

:DEFOUT
set binfilename=spi.bin
:RENOUT

if "%7"=="" goto NOSWITCH
set switchfile=%7
echo using switch configuration file:  %switchfile%
goto SW
:NOSWITCH
echo setting
set switchfile="none"
:SW

IF "%4"=="CG3010"  call setenv.bat CG3010
IF "%4"=="CG3110M"  call setenv.bat CG3110
IF "%4"=="CG3110H"  call setenv.bat CG3110
IF "%4"=="CG3210H"  call setenv.bat CG3210
IF "%4"=="CG3210M"  call setenv.bat CG3210
:: Copy prm file to some temp directory
IF .%5==. (
    set prm=%PRMINF%
) else (
    set prm=%5
)
if not exist %prm% goto FILE_ERROR
echo using parameters file:            %prm%
copy %prm% ./tmp/prm.inf >NUL 2>&1

:: for OEM images we use INF without auto_activate enabled
IF %3==ALL (
    echo auto_activate=1 > tmp/all.inf
    more tmp/prm.inf >> tmp/all.inf
     set prm_path=tmp/all.inf
) else (
    set prm_path=tmp/prm.inf
)

:: build OEM section with new MAC address
IF "%4"=="CG3010" %mkprm% -M %1 -o -d 3010 -f %prm_path% > tmp/OSEC.HEX
IF "%4"=="CG3110M" %mkprm% -d CG3110M -M %1 -o -f %prm_path% > tmp/OSEC.HEX
IF "%4"=="CG3110H" %mkprm% -d CG3110H -M %1 -o -f %prm_path% > tmp/OSEC.HEX
IF "%4"=="CG3210H" %mkprm% -d CG3210H -M %1 -o -f %prm_path% > tmp/OSEC.HEX
IF "%4"=="CG3210M" %mkprm% -d CG3210M -M %1 -o -f %prm_path% > tmp/OSEC.HEX

if %ERRORLEVEL% lss 0 goto PRMFAIL

:: select harware initialization vector file
set hw_cfg=undef
:: 3110 or 3010
IF .%2==.Phone_4-20_0.0 set hw_cfg=%hwpath%/config1.txt
IF .%2==.Phone_4-20_1.0 set hw_cfg=%hwpath%/config3.txt
IF .%2==.Phone_12-28_1.0 set hw_cfg=%hwpath%/config21.txt
IF .%2==.Phone_12-28_1.1 set hw_cfg=%hwpath%/config23.txt
IF .%2==.Coax_4-20_1.0 set hw_cfg=%hwpath%/config12.txt
IF .%2==.Coax_12-28_1.0 set  hw_cfg=%hwpath%/config22.txt
IF .%2==.Coax_12-28_2.0 set  hw_cfg=%hwpath%/config28.txt
IF .%2==.Coax_12-28_2.1 set  hw_cfg=%hwpath%/config8.txt
IF .%2==.Coax_4-20_2.0 set hw_cfg=%hwpath%/config10.txt
IF .%2==.Phone_36-52_1.0 set hw_cfg=%hwpath%/config24.txt
IF .%2==.Coax_36-52_1.0 set hw_cfg=%hwpath%/config18.txt
IF .%2==.Coax_36-52_1.0_3012 set hw_cfg=%hwpath%/config20.txt
:: mxu 3210 config
IF .%2==.Config41ep set hw_cfg=%hwpath%/Config41EP.txt
IF .%2==.Config41m set hw_cfg=%hwpath%/Config41M.txt
IF .%2==.Config45EP set hw_cfg=%hwpath%/Config45EP.txt
IF .%2==.Config45m set hw_cfg=%hwpath%/Config45M.txt
:: HN 3210 configs
IF .%2==.Coax_4-36 set hw_cfg=%hwpath%/config30.txt
IF .%2==.Coax_12-44 set hw_cfg=%hwpath%/config34.txt
IF .%2==.Phone_36-68 set hw_cfg=%hwpath%/config39.txt
IF .%2==.Phone_12-28_1.1 set hw_cfg=%hwpath%/config23.txt


if %hw_cfg%==undef goto NOCFG
GOTO DEFCFG

:NOCFG
set hw_cfg=%hwpath%/%2
echo hw configuration is %hw_cfg%
  if not exist %hw_cfg% goto CONFIG_ERROR
:DEFCFG

IF "%3"=="ALL" goto ALL
IF "%3"=="OEM" goto OEM
goto ERROR

:OEM
:: Link the sections into an image
IF "%4"=="CG3010" %mkconf% -F -Y -o tmp/OSEC.HEX -f %binfilename%
IF "%4"=="CG3110H" %mkconf% -s -F -Y -o tmp/OSEC.HEX -f %binfilename%
IF "%4"=="CG3110M" %mkconf% -s -F -Y -o tmp/OSEC.HEX -f %binfilename%
IF "%4"=="CG3210H" %mkconf% -s -F -Y -o tmp/OSEC.HEX -f %binfilename%
IF "%4"=="CG3210M" %mkconf% -s -F -Y -o tmp/OSEC.HEX -f %binfilename%
if %ERRORLEVEL% lss 0 goto CONFFAIL
goto END

:ALL

IF "%4"=="CG3110M" GOTO CG3110M
IF "%4"=="CG3110H" GOTO CG3110H
IF "%4"=="CG3210H" GOTO CG3210H
IF "%4"=="CG3210M" GOTO CG3210M




:CG3010

:: extract the MAC QOS and ADDRESS sections
%mkprm% -m  -d 3010 -f %prm_path% > tmp/MSEC.HEX
if %ERRORLEVEL% lss 0 goto PRMFAIL
%mkprm% -0  -d 3010 -f %prm_path% > tmp/0.HEX
if %ERRORLEVEL% lss 0 goto PRMFAIL
%mkprm% -1  -d 3010 -f %prm_path% > tmp/1.HEX
if %ERRORLEVEL% lss 0 goto PRMFAIL
%mkprm% -2  -d 3010 -f %prm_path% > tmp/2.HEX
if %ERRORLEVEL% lss 0 goto PRMFAIL
:: Link the sections into an image
if  %switchfile%=="none" goto NO_SWITCH
%mkconf%  -F -Y -o tmp/OSEC.HEX -m tmp/MSEC.HEX -x %xpath%/x1.hex -x %xpath%/x2.hex -x %xpath%/x3.hex -x %xpath%/x4.hex -0 tmp/0.HEX -1 tmp/1.HEX -2 tmp/2.HEX -w %switchfile% -i %hw_cfg% -f %binfilename%

GOTO CONT
:NO SWITCH
%mkconf%  -F -Y -o tmp/OSEC.HEX -m tmp/MSEC.HEX -x %xpath%/x1.hex -x %xpath%/x2.hex -x %xpath%/x3.hex -x %xpath%/x4.hex -0 tmp/0.HEX -1 tmp/1.HEX -2 tmp/2.HEX -i %hw_cfg% -f %binfilename%

goto CONT

:CG3110M
:: extract the MAC QOS and ADDRESS sections
%mkprm% -d CG3110M -m -f %prm_path% > tmp/MSEC.HEX
if %ERRORLEVEL% lss 0 goto PRMFAIL
%mkprm% -d CG3110M -0 -f %prm_path% > tmp/0.HEX
if %ERRORLEVEL% lss 0 goto PRMFAIL
%mkprm% -d CG3110M -1 -f %prm_path% > tmp/1.HEX
if %ERRORLEVEL% lss 0 goto PRMFAIL
%mkprm% -d CG3110M -2 -f %prm_path% > tmp/2.HEX
if %ERRORLEVEL% lss 0 goto PRMFAIL
:: Link the sections into an image
%mkconf% -F -s -o tmp/OSEC.HEX -m tmp/MSEC.HEX -x %xpath%/x1.hex -x %xpath%/x2.hex -x %xpath%/x3.hex -x %xpath%/x4.hex -0 tmp/0.HEX -1 tmp/1.HEX -2 tmp/2.HEX -i %hw_cfg% -Y -f %binfilename%

goto CONT

:CG3210M
echo using hw cofiguration file:       %hw_cfg%
:: extract the MAC QOS and ADDRESS sections
%mkprm% -d CG3210M -m -f %prm_path% > tmp/MSEC.HEX
if %ERRORLEVEL% lss 0 goto PRMFAIL
%mkprm% -d CG3210M -0 -f %prm_path% > tmp/0.HEX
if %ERRORLEVEL% lss 0 goto PRMFAIL
%mkprm% -d CG3210M -1 -f %prm_path% > tmp/1.HEX
if %ERRORLEVEL% lss 0 goto PRMFAIL
%mkprm% -d CG3210M -2 -f %prm_path% > tmp/2.HEX
if %ERRORLEVEL% lss 0 goto PRMFAIL
:: Link the sections into an image
if  %switchfile%=="none" goto NO_SWITCH3210M
echo   %mkconf% -F -s -o tmp/OSEC.HEX -m tmp/MSEC.HEX -x %xpath%/x1.hex -x %xpath%/x2.hex -x %xpath%/x3.hex -x %xpath%/x4.hex -0 tmp/0.HEX -1 tmp/1.HEX -2 tmp/2.HEX -w %switchfile% -i %hw_cfg% -Y -f %binfilename%

%mkconf% -F -s -o tmp/OSEC.HEX -m tmp/MSEC.HEX -x %xpath%/x1.hex -x %xpath%/x2.hex -x %xpath%/x3.hex -x %xpath%/x4.hex -0 tmp/0.HEX -1 tmp/1.HEX -2 tmp/2.HEX -w %switchfile% -i %hw_cfg% -Y -f %binfilename%
goto CONT
:NO_SWITCH3210M
%mkconf% -F -s -o tmp/OSEC.HEX -m tmp/MSEC.HEX -x %xpath%/x1.hex -x %xpath%/x2.hex -x %xpath%/x3.hex -x %xpath%/x4.hex -0 tmp/0.HEX -1 tmp/1.HEX -2 tmp/2.HEX -i %hw_cfg% -Y -f %binfilename%


goto CONT

:CG3110H
:: extract the MAC QOS and ADDRESS sections
%mkprm% -d CG3110H -m -f %prm_path% > tmp/MSEC.HEX
if %ERRORLEVEL% lss 0 goto PRMFAIL
%mkprm% -d CG3110H -0 -f %prm_path% > tmp/0.HEX
if %ERRORLEVEL% lss 0 goto PRMFAIL
%mkprm% -d CG3110H -1 -f %prm_path% > tmp/1.HEX
if %ERRORLEVEL% lss 0 goto PRMFAIL
%mkprm% -d CG3110H -2 -f %prm_path% > tmp/2.HEX
if %ERRORLEVEL% lss 0 goto PRMFAIL
:: Link the sections into an image
%mkconf% -F -s -o tmp/OSEC.HEX -m tmp/MSEC.HEX -x %xpath%/x1.hex -x %xpath%/x2.hex -x %xpath%/x3.hex -x %xpath%/x4.hex -0 tmp/0.HEX -1 tmp/1.HEX -2 tmp/2.HEX -i %hw_cfg% -Y -f %binfilename%
 goto CONT

:CG3210H
echo using hw cofiguration file:       %hw_cfg%
:: extract the MAC QOS and ADDRESS sections
%mkprm% -d CG3210H -m -f %prm_path% > tmp/MSEC.HEX
if %ERRORLEVEL% lss 0 goto PRMFAIL
%mkprm% -d CG3210H -0 -f %prm_path% > tmp/0.HEX
if %ERRORLEVEL% lss 0 goto PRMFAIL
%mkprm% -d CG3210H -1 -f %prm_path% > tmp/1.HEX
if %ERRORLEVEL% lss 0 goto PRMFAIL
%mkprm% -d CG3210H -2 -f %prm_path% > tmp/2.HEX
if %ERRORLEVEL% lss 0 goto PRMFAIL
:: Link the sections into an image
if  %switchfile%=="none" goto NO_SWITCH3210H
%mkconf% -F -s -o tmp/OSEC.HEX -m tmp/MSEC.HEX -x %xpath%/x1.hex -x %xpath%/x2.hex -x %xpath%/x3.hex -x %xpath%/x4.hex -0 tmp/0.HEX -1 tmp/1.HEX -2 tmp/2.HEX -w %switchfile% -i %hw_cfg% -Y -f %binfilename%
goto CONT
:NO_SWITCH3210H
%mkconf% -F -s -o tmp/OSEC.HEX -m tmp/MSEC.HEX -x %xpath%/x1.hex -x %xpath%/x2.hex -x %xpath%/x3.hex -x %xpath%/x4.hex -0 tmp/0.HEX -1 tmp/1.HEX -2 tmp/2.HEX  -i %hw_cfg% -Y -f %binfilename%


:CONT
if %ERRORLEVEL% lss 0 goto CONFFAIL



goto END

:ERROR
echo ERROR - Invalid input!
goto USAGE

:PRMFAIL
@echo Failed to process parameters (%ERRORLEVEL%)
goto END

:CONFFAIL
@echo Failed to generate image file (%ERRORLEVEL%)
goto END

:FILE_ERROR
@echo Failed to find parameter file %5
goto END

:CONFIG_ERROR
@echo Failed to find hw config file %hw_cfg%
goto END

:USAGE
@echo.
@echo Usage: "mkspi.bat <MAC> <Configuration> <Content> <Chipset> <PrmFile> <BinFileName> [switchFileName]"
@echo.
@echo   MAC            - Mac address to set into image e.g: 00-C5-D9-00-00-22
@echo   Configuration  - Hardware configuration
@echo             Available Cfg:
@echo                Phone_4-20_0.0  (formerly known as phone1)
@echo                Phone_4-20_1.0
@echo                Phone_12-28_1.0
@echo                Phone_12-28_1.1
@echo                Coax_4-20_1.0   (formerly known as coax2)
@echo                Coax_12-28_1.0  (formerly known as coax3)
@echo                Coax_12-28_2.0
@echo                Coax_12-28_2.1
@echo                Coax_4-20_2.0
@echo                Phone_36-52_1.0
@echo                Coax_36-52_1.0
@echo                Coax_36-52_1.0_3012
@echo             for CG3210H:
@echo                           Coax_4-36
@echo                           Coax_12-44
@echo                           Phone_36-68
@echo                           Phone_12-28_1.1
@echo             for CG3210M:
@echo                Config41ep
@echo                Config41m
@echo                Config45ep
@echo                Config45m
@echo or enter configuration filename e.g.   config30.txt

@echo   Content - ALL or OEM  (use ALL for regular BIN or OEM for OEM section only)
@echo   PrmFile - Full/Relative path to prm file (default: ../fwtool/prm.inf)
@echo   BinFileName - name of output bin
@echo   switchFileName - name of switch configuration file (default is no switch configuration)
@echo.
@echo   for example:
@echo   mkspi.bat 00:c5:d9:11:11:22  Config41m ALL CG3210M ../FwTool/prm/3210/prm_mxu_ep.inf CG3210M_281EP.bin  ../FwTool/switch/ICPlus_175d_Default.txt
@echo.
goto END

:END
:: Cleanup

del /Q tmp/OSEC.HEX >NUL 2>&1
del /Q tmp/MSEC.HEX >NUL 2>&1
del /Q tmp/prm.inf >NUL 2>&1
del /Q tmp/all.inf >NUL 2>&1

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值