|
1 | | -@echo off |
2 | | - |
3 | | -set ERROR=0 |
4 | | -set STM32CP_CLI=STM32_Programmer_CLI.exe |
5 | | -set ADDRESS=0x8000000 |
6 | | -set ERASE= |
7 | | -set MODE= |
8 | | -set PORT= |
9 | | -set OPTS= |
10 | | - |
11 | | -:: Check tool |
12 | | -where /Q %STM32CP_CLI% |
13 | | -if %errorlevel%==0 goto :param |
14 | | -::Check with default path |
15 | | -set STM32CP=%ProgramW6432%\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin |
16 | | -set STM32CP86=%ProgramFiles(X86)%\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin |
17 | | -set PATH=%PATH%;%STM32CP%;%STM32CP86% |
18 | | -where /Q %STM32CP_CLI% |
19 | | -if %errorlevel%==0 goto :param |
20 | | -echo %STM32CP_CLI% not found. |
21 | | -echo Please install it or add ^<STM32CubeProgrammer path^>\bin' to your PATH environment: |
22 | | -echo https://www.st.com/en/development-tools/stm32cubeprog.html |
23 | | -echo Aborting! |
24 | | -exit 1 |
25 | | - |
26 | | -:param |
27 | | -:: Parse options |
28 | | -if "%~1"=="" echo Not enough arguments! & set ERROR=2 & goto :usage |
29 | | -if "%~2"=="" echo Not enough arguments! & set ERROR=2 & goto :usage |
30 | | - |
31 | | -set PROTOCOL=%~1 |
32 | | -set FILEPATH=%~2 |
33 | | - |
34 | | -:: Protocol |
35 | | -:: 1x: Erase all sectors |
36 | | -if %~1 lss 10 goto :proto |
37 | | -set ERASE=-e all |
38 | | -set /a PROTOCOL-=10 |
39 | | - |
40 | | -:: 0: SWD |
41 | | -:: 1: Serial |
42 | | -:: 2: DFU |
43 | | -:proto |
44 | | -if %PROTOCOL%==0 goto :SWD |
45 | | -if %PROTOCOL%==1 goto :SERIAL |
46 | | -if %PROTOCOL%==2 goto :DFU |
47 | | -echo Protocol unknown! |
48 | | -set ERROR=4 |
49 | | -goto :usage |
50 | | - |
51 | | -:SWD |
52 | | -set PORT=SWD |
53 | | -set MODE=mode=UR |
54 | | -goto :opt |
55 | | - |
56 | | -:SERIAL |
57 | | -if "%~3"=="" set ERROR=3 & goto :usage |
58 | | -set PORT=%~3 |
59 | | -shift |
60 | | -goto :opt |
61 | | - |
62 | | -:DFU |
63 | | -set PORT=USB1 |
64 | | -goto :opt |
65 | | - |
66 | | -:opt |
67 | | -shift |
68 | | -shift |
69 | | -if "%~1"=="" goto :prog |
70 | | -set OPTS=%1 %2 %3 %4 %5 %6 %7 %8 %9 |
71 | | -goto :prog |
72 | | - |
73 | | -:prog |
74 | | -%STM32CP_CLI% -c port=%PORT% %MODE% %ERASE% -q -d %FILEPATH% %ADDRESS% %OPTS% |
75 | | -exit 0 |
76 | | - |
77 | | -:usage |
78 | | - echo %0 ^<protocol^> ^<file_path^> [OPTIONS] |
79 | | - echo. |
80 | | - echo protocol: |
81 | | - echo 0: SWD |
82 | | - echo 1: Serial |
83 | | - echo 2: DFU |
84 | | - echo Note: prefix it by 1 to erase all sectors |
85 | | - echo Ex: 10 erase all sectors using SWD interface |
86 | | - echo file_path: file path name to be downloaded: (bin, hex) |
87 | | - echo Options: |
88 | | - echo For SWD and DFU: no mandatory options |
89 | | - echo For Serial: ^<com_port^> |
90 | | - echo com_port: serial identifier (mandatory). Ex: COM15 |
91 | | - echo. |
92 | | - echo Note: all trailing arguments will be passed to the %STM32CP_CLI% |
93 | | - echo They have to be valid commands for STM32 MCU |
94 | | - echo Ex: -g: Run the code at the specified address |
95 | | - echo -rst: Reset system |
96 | | - echo -s: start automatically (optional) |
97 | | - exit %ERROR% |
| 1 | +@echo off |
| 2 | + |
| 3 | +set ERROR=0 |
| 4 | +set STM32CP_CLI=STM32_Programmer_CLI.exe |
| 5 | +set ADDRESS=0x8000000 |
| 6 | +set ERASE= |
| 7 | +set MODE= |
| 8 | +set PORT= |
| 9 | +set OPTS= |
| 10 | + |
| 11 | +:: Check tool |
| 12 | +where /Q %STM32CP_CLI% |
| 13 | +if %errorlevel%==0 goto :param |
| 14 | +::Check with default path |
| 15 | +set STM32CP=%ProgramW6432%\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin |
| 16 | +set STM32CP86=%ProgramFiles(X86)%\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin |
| 17 | +set PATH=%PATH%;%STM32CP%;%STM32CP86% |
| 18 | +where /Q %STM32CP_CLI% |
| 19 | +if %errorlevel%==0 goto :param |
| 20 | +echo %STM32CP_CLI% not found. |
| 21 | +echo Please install it or add ^<STM32CubeProgrammer path^>\bin' to your PATH environment: |
| 22 | +echo https://www.st.com/en/development-tools/stm32cubeprog.html |
| 23 | +echo Aborting! |
| 24 | +exit 1 |
| 25 | + |
| 26 | +:param |
| 27 | +:: Parse options |
| 28 | +if "%~1"=="" echo Not enough arguments! & set ERROR=2 & goto :usage |
| 29 | +if "%~2"=="" echo Not enough arguments! & set ERROR=2 & goto :usage |
| 30 | + |
| 31 | +set PROTOCOL=%~1 |
| 32 | +set FILEPATH=%~2 |
| 33 | + |
| 34 | +:: Protocol |
| 35 | +:: 1x: Erase all sectors |
| 36 | +if %~1 lss 10 goto :proto |
| 37 | +set ERASE=-e all |
| 38 | +set /a PROTOCOL-=10 |
| 39 | + |
| 40 | +:: 0: SWD |
| 41 | +:: 1: Serial |
| 42 | +:: 2: DFU |
| 43 | +:proto |
| 44 | +if %PROTOCOL%==0 goto :SWD |
| 45 | +if %PROTOCOL%==1 goto :SERIAL |
| 46 | +if %PROTOCOL%==2 goto :DFU |
| 47 | +echo Protocol unknown! |
| 48 | +set ERROR=4 |
| 49 | +goto :usage |
| 50 | + |
| 51 | +:SWD |
| 52 | +set PORT=SWD |
| 53 | +set MODE=mode=UR |
| 54 | +goto :opt |
| 55 | + |
| 56 | +:SERIAL |
| 57 | +if "%~3"=="" set ERROR=3 & goto :usage |
| 58 | +set PORT=%~3 |
| 59 | +shift |
| 60 | +goto :opt |
| 61 | + |
| 62 | +:DFU |
| 63 | +set PORT=USB1 |
| 64 | +goto :opt |
| 65 | + |
| 66 | +:opt |
| 67 | +shift |
| 68 | +shift |
| 69 | +if "%~1"=="" goto :prog |
| 70 | +set OPTS=%1 %2 %3 %4 %5 %6 %7 %8 %9 |
| 71 | +goto :prog |
| 72 | + |
| 73 | +:prog |
| 74 | +%STM32CP_CLI% -c port=%PORT% %MODE% %ERASE% -q -d %FILEPATH% %ADDRESS% %OPTS% |
| 75 | +exit 0 |
| 76 | + |
| 77 | +:usage |
| 78 | + echo %0 ^<protocol^> ^<file_path^> [OPTIONS] |
| 79 | + echo. |
| 80 | + echo protocol: |
| 81 | + echo 0: SWD |
| 82 | + echo 1: Serial |
| 83 | + echo 2: DFU |
| 84 | + echo Note: prefix it by 1 to erase all sectors |
| 85 | + echo Ex: 10 erase all sectors using SWD interface |
| 86 | + echo file_path: file path name to be downloaded: (bin, hex) |
| 87 | + echo Options: |
| 88 | + echo For SWD and DFU: no mandatory options |
| 89 | + echo For Serial: ^<com_port^> |
| 90 | + echo com_port: serial identifier (mandatory). Ex: COM15 |
| 91 | + echo. |
| 92 | + echo Note: all trailing arguments will be passed to the %STM32CP_CLI% |
| 93 | + echo They have to be valid commands for STM32 MCU |
| 94 | + echo Ex: -g: Run the code at the specified address |
| 95 | + echo -rst: Reset system |
| 96 | + echo -s: start automatically (optional) |
| 97 | + exit %ERROR% |
0 commit comments