Add STM32CubeProgrammer support
Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
This commit is contained in:
parent
be6cae0057
commit
0e0ac6837d
3 changed files with 266 additions and 0 deletions
94
linux/stm32CubeProg.sh
Executable file
94
linux/stm32CubeProg.sh
Executable file
|
|
@ -0,0 +1,94 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -o nounset # Treat unset variables as an error
|
||||||
|
#set -x
|
||||||
|
STM32CP_CLI=STM32_Programmer.sh
|
||||||
|
ADDRESS=0x8000000
|
||||||
|
FILEPATH=
|
||||||
|
MODE=
|
||||||
|
PORT=
|
||||||
|
OPTS=
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
## Help function
|
||||||
|
usage()
|
||||||
|
{
|
||||||
|
echo "############################################################"
|
||||||
|
echo "##"
|
||||||
|
echo "## `basename $0` <protocol> <file_path> [OPTIONS]"
|
||||||
|
echo "##"
|
||||||
|
echo "## protocol: "
|
||||||
|
echo "## 0: SWD"
|
||||||
|
echo "## 1: Serial "
|
||||||
|
echo "## 2: DFU"
|
||||||
|
echo "## file_path: file path name to be downloaded: (bin, hex)"
|
||||||
|
echo "## Options:"
|
||||||
|
echo "## For SWD: -rst"
|
||||||
|
echo "## -rst: Reset system (default)"
|
||||||
|
echo "## For Serial: <com_port> -s"
|
||||||
|
echo "## com_port: serial identifier. Ex: /dev/ttyS0"
|
||||||
|
echo "## -s: start automatically"
|
||||||
|
echo "## For DFU: none"
|
||||||
|
echo "############################################################"
|
||||||
|
exit $1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
check_tool() {
|
||||||
|
command -v $STM32CP_CLI >/dev/null 2>&1
|
||||||
|
if [ $? != 0 ]; then
|
||||||
|
export PATH="$HOME/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin":$PATH
|
||||||
|
fi
|
||||||
|
command -v $STM32CP_CLI >/dev/null 2>&1
|
||||||
|
if [ $? != 0 ]; then
|
||||||
|
echo "$STM32CP_CLI not found."
|
||||||
|
echo "Please install it or add '<STM32CubeProgrammer path>/bin' to your PATH environment:"
|
||||||
|
echo "https://www.st.com/en/development-tools/stm32cubeprog.html"
|
||||||
|
echo "Aborting!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
check_tool
|
||||||
|
|
||||||
|
if [ $# -lt 2 ]; then
|
||||||
|
echo "Not enough arguments!"
|
||||||
|
usage 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
FILEPATH=$2
|
||||||
|
|
||||||
|
# Parse options
|
||||||
|
# Protocol $1
|
||||||
|
# 0: SWD
|
||||||
|
# 1: Serial
|
||||||
|
# 2: DFU
|
||||||
|
case $1 in
|
||||||
|
0)
|
||||||
|
PORT='SWD'
|
||||||
|
MODE='mode=UR'
|
||||||
|
if [ $# -lt 3 ]; then
|
||||||
|
OPTS=-rst
|
||||||
|
else
|
||||||
|
OPTS=$3
|
||||||
|
fi;;
|
||||||
|
1)
|
||||||
|
if [ $# -lt 3 ]; then
|
||||||
|
usage 3
|
||||||
|
else
|
||||||
|
PORT=$3
|
||||||
|
if [ $# -gt 3 ]; then
|
||||||
|
shift 3
|
||||||
|
OPTS="$@"
|
||||||
|
fi
|
||||||
|
fi;;
|
||||||
|
2)
|
||||||
|
PORT='USB1';;
|
||||||
|
*)
|
||||||
|
echo "Protocol unknown!"
|
||||||
|
usage 4;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
${STM32CP_CLI} -c port=${PORT} ${MODE} -q -d ${FILEPATH} ${ADDRESS} ${OPTS}
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
||||||
93
macosx/stm32CubeProg
Executable file
93
macosx/stm32CubeProg
Executable file
|
|
@ -0,0 +1,93 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -o nounset # Treat unset variables as an error
|
||||||
|
STM32CP_CLI=STM32_Programmer_CLI
|
||||||
|
ADDRESS=0x8000000
|
||||||
|
FILEPATH=
|
||||||
|
MODE=
|
||||||
|
PORT=
|
||||||
|
OPTS=
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
## Help function
|
||||||
|
usage()
|
||||||
|
{
|
||||||
|
echo "############################################################"
|
||||||
|
echo "##"
|
||||||
|
echo "## `basename $0` <protocol> <file_path> [OPTIONS]"
|
||||||
|
echo "##"
|
||||||
|
echo "## protocol: "
|
||||||
|
echo "## 0: SWD"
|
||||||
|
echo "## 1: Serial "
|
||||||
|
echo "## 2: DFU"
|
||||||
|
echo "## file_path: file path name to be downloaded: (bin, hex)"
|
||||||
|
echo "## Options:"
|
||||||
|
echo "## For SWD: -rst"
|
||||||
|
echo "## -rst: Reset system (default)"
|
||||||
|
echo "## For Serial: <com_port> -s"
|
||||||
|
echo "## com_port: serial identifier. Ex: /dev/ttyS0"
|
||||||
|
echo "## -s: start automatically"
|
||||||
|
echo "## For DFU: none"
|
||||||
|
echo "############################################################"
|
||||||
|
exit $1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
check_tool() {
|
||||||
|
command -v $STM32CP_CLI >/dev/null 2>&1
|
||||||
|
if [ $? != 0 ]; then
|
||||||
|
export PATH="/Applications/STMicroelectronics/STM32Cube/STM32CubeProgrammer/STM32CubeProgrammer.app/Contents/MacOs/bin":$PATH
|
||||||
|
fi
|
||||||
|
command -v $STM32CP_CLI >/dev/null 2>&1
|
||||||
|
if [ $? != 0 ]; then
|
||||||
|
echo "$STM32CP_CLI not found."
|
||||||
|
echo "Please install it or add '<STM32CubeProgrammer path>/bin' to your PATH environment:"
|
||||||
|
echo "https://www.st.com/en/development-tools/stm32cubeprog.html"
|
||||||
|
echo "Aborting!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
check_tool
|
||||||
|
|
||||||
|
if [ $# -lt 2 ]; then
|
||||||
|
echo "Not enough arguments!"
|
||||||
|
usage 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
FILEPATH=$2
|
||||||
|
|
||||||
|
# Parse options
|
||||||
|
# Protocol $1
|
||||||
|
# 0: SWD
|
||||||
|
# 1: Serial
|
||||||
|
# 2: DFU
|
||||||
|
case $1 in
|
||||||
|
0)
|
||||||
|
PORT='SWD'
|
||||||
|
MODE='mode=UR'
|
||||||
|
if [ $# -lt 3 ]; then
|
||||||
|
OPTS=-rst
|
||||||
|
else
|
||||||
|
OPTS=$3
|
||||||
|
fi;;
|
||||||
|
1)
|
||||||
|
if [ $# -lt 3 ]; then
|
||||||
|
usage 3
|
||||||
|
else
|
||||||
|
PORT=$3
|
||||||
|
if [ $# -gt 3 ]; then
|
||||||
|
shift 3
|
||||||
|
OPTS="$@"
|
||||||
|
fi
|
||||||
|
fi;;
|
||||||
|
2)
|
||||||
|
PORT='USB1';;
|
||||||
|
*)
|
||||||
|
echo "Protocol unknown!"
|
||||||
|
usage 4;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
${STM32CP_CLI} -c port=${PORT} ${MODE} -q -d ${FILEPATH} ${ADDRESS} ${OPTS}
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
||||||
79
win/stm32CubeProg.bat
Normal file
79
win/stm32CubeProg.bat
Normal file
|
|
@ -0,0 +1,79 @@
|
||||||
|
@echo off
|
||||||
|
|
||||||
|
set ERROR=0
|
||||||
|
set STM32CP_CLI=STM32_Programmer_CLI.exe
|
||||||
|
set ADDRESS=0x8000000
|
||||||
|
|
||||||
|
:: Check tool
|
||||||
|
where /Q %STM32CP_CLI%
|
||||||
|
if %errorlevel%==0 goto :param
|
||||||
|
::Check with default path
|
||||||
|
set STM32CP=%ProgramW6432%\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin
|
||||||
|
set STM32CP86=%ProgramFiles(X86)%\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin
|
||||||
|
set PATH=%PATH%;%STM32CP%;%STM32CP86%
|
||||||
|
where /Q %STM32CP_CLI%
|
||||||
|
if %errorlevel%==0 goto :param
|
||||||
|
echo %STM32CP_CLI% not found.
|
||||||
|
echo Please install it or add ^<STM32CubeProgrammer path^>\bin' to your PATH environment:
|
||||||
|
echo https://www.st.com/en/development-tools/stm32cubeprog.html
|
||||||
|
echo Aborting!
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
:param
|
||||||
|
:: 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 FILEPATH=%~2
|
||||||
|
|
||||||
|
:: Protocol
|
||||||
|
:: 0: SWD
|
||||||
|
:: 1: Serial
|
||||||
|
:: 2: DFU
|
||||||
|
if %~1==0 goto :SWD
|
||||||
|
if %~1==1 goto :SERIAL
|
||||||
|
if %~1==2 goto :DFU
|
||||||
|
echo Protocol unknown!
|
||||||
|
set ERROR=4
|
||||||
|
goto :usage
|
||||||
|
|
||||||
|
:SWD
|
||||||
|
set PORT=SWD
|
||||||
|
set MODE=mode=UR
|
||||||
|
if "%~3"=="" (set OPTS=-rst) else (set OPTS=%3)
|
||||||
|
goto :prog
|
||||||
|
|
||||||
|
:SERIAL
|
||||||
|
if "%~3"=="" set ERROR=3 & goto :usage
|
||||||
|
set PORT=%~3
|
||||||
|
|
||||||
|
if "%~4"=="" goto :prog
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
set OPTS=%*
|
||||||
|
goto :prog
|
||||||
|
|
||||||
|
:DFU
|
||||||
|
set PORT=USB1
|
||||||
|
goto :prog
|
||||||
|
|
||||||
|
:prog
|
||||||
|
%STM32CP_CLI% -c port=%PORT% %MODE% -q -d %FILEPATH% %ADDRESS% %OPTS%
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
:usage
|
||||||
|
echo %0 ^<protocol^> ^<file_path^> [OPTIONS]
|
||||||
|
echo.
|
||||||
|
echo protocol:
|
||||||
|
echo 0: SWD
|
||||||
|
echo 1: Serial
|
||||||
|
echo 2: DFU
|
||||||
|
echo file_path: file path name to be downloaded: (bin, hex)
|
||||||
|
echo Options:
|
||||||
|
echo For SWD: -rst
|
||||||
|
echo -rst: Reset system (default)
|
||||||
|
echo For Serial: ^<com_port^> -s
|
||||||
|
echo com_port: serial identifier. Ex: /dev/ttyS0
|
||||||
|
echo -s: start automatically
|
||||||
|
echo For DFU: none
|
||||||
|
exit %ERROR%
|
||||||
Loading…
Reference in a new issue