[STM32CubeProg] Add option to erase all sectors
For example adding a platform.local.txt with:
tools.stm32CubeProg.upload.pattern="{path}/{cmd}" 1{upload.protocol} "{build.path}/{build.project_name}.bin" {upload.options}
will allow to erase all sectors before download.
Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
This commit is contained in:
parent
e167f91814
commit
ce5b68d456
3 changed files with 48 additions and 17 deletions
|
|
@ -3,7 +3,7 @@ set -o nounset # Treat unset variables as an error
|
|||
#set -x
|
||||
STM32CP_CLI=STM32_Programmer.sh
|
||||
ADDRESS=0x8000000
|
||||
FILEPATH=
|
||||
ERASE=
|
||||
MODE=
|
||||
PORT=
|
||||
OPTS=
|
||||
|
|
@ -16,10 +16,12 @@ usage()
|
|||
echo "##"
|
||||
echo "## `basename $0` <protocol> <file_path> [OPTIONS]"
|
||||
echo "##"
|
||||
echo "## protocol: "
|
||||
echo "## protocol:"
|
||||
echo "## 0: SWD"
|
||||
echo "## 1: Serial "
|
||||
echo "## 1: Serial"
|
||||
echo "## 2: DFU"
|
||||
echo "## Note: prefix it by 1 to erase all sectors."
|
||||
echo "## Ex: 10 erase all sectors using SWD interface."
|
||||
echo "## file_path: file path name to be downloaded: (bin, hex)"
|
||||
echo "## Options:"
|
||||
echo "## For SWD and DFU: no mandatory options"
|
||||
|
|
@ -58,14 +60,20 @@ if [ $# -lt 2 ]; then
|
|||
usage 2
|
||||
fi
|
||||
|
||||
FILEPATH=$2
|
||||
|
||||
# Parse options
|
||||
PROTOCOL=$1
|
||||
FILEPATH=$2
|
||||
# Protocol $1
|
||||
# 1x: Erase all sectors
|
||||
if [ $1 -ge 10 ]; then
|
||||
ERASE='-e all'
|
||||
PROTOCOL=$(($1 - 10))
|
||||
fi
|
||||
# Protocol $1
|
||||
# 0: SWD
|
||||
# 1: Serial
|
||||
# 2: DFU
|
||||
case $1 in
|
||||
case $PROTOCOL in
|
||||
0)
|
||||
PORT='SWD'
|
||||
MODE='mode=UR'
|
||||
|
|
@ -89,7 +97,7 @@ if [ $# -gt 0 ]; then
|
|||
OPTS="$@"
|
||||
fi
|
||||
|
||||
${STM32CP_CLI} -c port=${PORT} ${MODE} -q -d ${FILEPATH} ${ADDRESS} ${OPTS}
|
||||
${STM32CP_CLI} -c port=${PORT} ${MODE} ${ERASE} -q -d ${FILEPATH} ${ADDRESS} ${OPTS}
|
||||
|
||||
exit 0
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
set -o nounset # Treat unset variables as an error
|
||||
STM32CP_CLI=STM32_Programmer_CLI
|
||||
ADDRESS=0x8000000
|
||||
FILEPATH=
|
||||
ERASE=
|
||||
MODE=
|
||||
PORT=
|
||||
OPTS=
|
||||
|
|
@ -17,8 +17,10 @@ usage()
|
|||
echo "##"
|
||||
echo "## protocol: "
|
||||
echo "## 0: SWD"
|
||||
echo "## 1: Serial "
|
||||
echo "## 1: Serial"
|
||||
echo "## 2: DFU"
|
||||
echo "## Note: prefix it by 1 to erase all sectors."
|
||||
echo "## Ex: 10 erase all sectors using SWD interface."
|
||||
echo "## file_path: file path name to be downloaded: (bin, hex)"
|
||||
echo "## Options:"
|
||||
echo "## For SWD and DFU: no mandatory options"
|
||||
|
|
@ -57,14 +59,21 @@ if [ $# -lt 2 ]; then
|
|||
usage 2
|
||||
fi
|
||||
|
||||
FILEPATH=$2
|
||||
|
||||
# Parse options
|
||||
PROTOCOL=$1
|
||||
FILEPATH=$2
|
||||
# Protocol $1
|
||||
# 1x: Erase all sectors
|
||||
if [ $1 -ge 10 ]; then
|
||||
ERASE='-e all'
|
||||
PROTOCOL=$(($1 - 10))
|
||||
fi
|
||||
# Protocol $1
|
||||
# 0: SWD
|
||||
# 1: Serial
|
||||
# 2: DFU
|
||||
case $1 in
|
||||
case $PROTOCOL in
|
||||
|
||||
0)
|
||||
PORT='SWD'
|
||||
MODE='mode=UR'
|
||||
|
|
@ -88,7 +97,7 @@ if [ $# -gt 0 ]; then
|
|||
OPTS="$@"
|
||||
fi
|
||||
|
||||
${STM32CP_CLI} -c port=${PORT} ${MODE} -q -d ${FILEPATH} ${ADDRESS} ${OPTS}
|
||||
${STM32CP_CLI} -c port=${PORT} ${MODE} ${ERASE} -q -d ${FILEPATH} ${ADDRESS} ${OPTS}
|
||||
|
||||
exit 0
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,10 @@
|
|||
set ERROR=0
|
||||
set STM32CP_CLI=STM32_Programmer_CLI.exe
|
||||
set ADDRESS=0x8000000
|
||||
set ERASE=
|
||||
set MODE=
|
||||
set PORT=
|
||||
set OPTS=
|
||||
|
||||
:: Check tool
|
||||
where /Q %STM32CP_CLI%
|
||||
|
|
@ -23,15 +27,23 @@ exit 1
|
|||
:: Parse options
|
||||
if "%~1"=="" echo Not enough arguments! & set ERROR=2 & goto :usage
|
||||
if "%~2"=="" echo Not enough arguments! & set ERROR=2 & goto :usage
|
||||
|
||||
set PROTOCOL=%~1
|
||||
set FILEPATH=%~2
|
||||
|
||||
:: Protocol
|
||||
:: 1x: Erase all sectors
|
||||
if %~1 lss 10 goto :proto
|
||||
set ERASE=-e all
|
||||
set /a PROTOCOL-=10
|
||||
|
||||
:: 0: SWD
|
||||
:: 1: Serial
|
||||
:: 2: DFU
|
||||
if %~1==0 goto :SWD
|
||||
if %~1==1 goto :SERIAL
|
||||
if %~1==2 goto :DFU
|
||||
:proto
|
||||
if %PROTOCOL%==0 goto :SWD
|
||||
if %PROTOCOL%==1 goto :SERIAL
|
||||
if %PROTOCOL%==2 goto :DFU
|
||||
echo Protocol unknown!
|
||||
set ERROR=4
|
||||
goto :usage
|
||||
|
|
@ -59,7 +71,7 @@ set OPTS=%1 %2 %3 %4 %5 %6 %7 %8 %9
|
|||
goto :prog
|
||||
|
||||
:prog
|
||||
%STM32CP_CLI% -c port=%PORT% %MODE% -q -d %FILEPATH% %ADDRESS% %OPTS%
|
||||
%STM32CP_CLI% -c port=%PORT% %MODE% %ERASE% -q -d %FILEPATH% %ADDRESS% %OPTS%
|
||||
exit 0
|
||||
|
||||
:usage
|
||||
|
|
@ -69,6 +81,8 @@ exit 0
|
|||
echo 0: SWD
|
||||
echo 1: Serial
|
||||
echo 2: DFU
|
||||
echo Note: prefix it by 1 to erase all sectors
|
||||
echo Ex: 10 erase all sectors using SWD interface
|
||||
echo file_path: file path name to be downloaded: (bin, hex)
|
||||
echo Options:
|
||||
echo For SWD and DFU: no mandatory options
|
||||
|
|
|
|||
Loading…
Reference in a new issue