新增 ST-LINK CLI 复位脚本 reset.bat(复位/停机/运行/查探头/烧录)及测试说明文档
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
set STLINK=C:\Program Files (x86)\STMicroelectronics\STM32 ST-LINK Utility\ST-LINK Utility\ST-LINK_CLI.exe
|
||||
if not exist "%STLINK%" (
|
||||
echo RESET_FAIL: ST-LINK_CLI not found at "%STLINK%"
|
||||
exit /b 2
|
||||
)
|
||||
|
||||
if "%~1"=="" goto :reset_run
|
||||
if /i "%~1"=="hard" goto :hard
|
||||
if /i "%~1"=="halt" goto :halt
|
||||
if /i "%~1"=="run" goto :run
|
||||
if /i "%~1"=="list" goto :list
|
||||
if /i "%~1"=="flash" goto :flash
|
||||
goto :help
|
||||
|
||||
:reset_run
|
||||
echo RESET: system reset and run (SWD)
|
||||
"%STLINK%" -c SWD -Rst -Run -Q
|
||||
exit /b %ERRORLEVEL%
|
||||
|
||||
:hard
|
||||
echo RESET: nRST pulse 100ms (falls back to system reset if CLI lacks RM=)
|
||||
"%STLINK%" -c SWD RM=Hrst -HardRst PULSE=100 -Q
|
||||
if not errorlevel 1 exit /b 0
|
||||
echo RESET_NOTE: this ST-LINK_CLI rejects RM= (v3.5.0 known gap), falling back to system reset
|
||||
"%STLINK%" -c SWD -Rst -Run -Q
|
||||
exit /b %ERRORLEVEL%
|
||||
|
||||
:halt
|
||||
echo RESET: system reset and halt core (debug; resume with 'run')
|
||||
"%STLINK%" -c SWD -Rst -Halt
|
||||
exit /b %ERRORLEVEL%
|
||||
|
||||
:run
|
||||
echo RUN: resume halted core
|
||||
"%STLINK%" -c SWD -Run
|
||||
exit /b %ERRORLEVEL%
|
||||
|
||||
:list
|
||||
"%STLINK%" -List
|
||||
exit /b %ERRORLEVEL%
|
||||
|
||||
:flash
|
||||
if "%~2"=="" set "FW=%~dp0STM32F407-Demo\STM32F407-Demo.hex"
|
||||
if not "%~2"=="" set "FW=%~2"
|
||||
if not exist "%FW%" (
|
||||
echo FLASH_FAIL: firmware not found "%FW%"
|
||||
exit /b 2
|
||||
)
|
||||
echo FLASH: program "%FW%" then reset and run
|
||||
"%STLINK%" -c SWD -P "%FW%" -Rst -Run -Q
|
||||
exit /b %ERRORLEVEL%
|
||||
|
||||
:help
|
||||
echo Usage: reset.bat [command]
|
||||
echo.
|
||||
echo (none) System reset and run (restart board via SWD)
|
||||
echo hard nRST pulse 100ms; auto-falls back to system reset if CLI lacks RM=
|
||||
echo halt System reset and halt core (in-session read; auto-resumes after disconnect)
|
||||
echo run Resume a halted core
|
||||
echo list List connected ST-LINK probes
|
||||
echo flash [F] Program F (default: latest build hex) then reset and run
|
||||
echo.
|
||||
echo Exit codes: 0=OK 1=probe or target error 2=usage or tool missing
|
||||
|
||||
endlocal
|
||||
Reference in New Issue
Block a user