diff --git a/linux/stm32CubeProg.sh b/linux/stm32CubeProg.sh index ff9a7b80..885776c1 100755 --- a/linux/stm32CubeProg.sh +++ b/linux/stm32CubeProg.sh @@ -22,12 +22,15 @@ usage() 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: -s" - echo "## com_port: serial identifier. Ex: /dev/ttyS0" - echo "## -s: start automatically" - echo "## For DFU: none" + echo "## For SWD and DFU: no mandatory options" + echo "## For Serial: " + echo "## com_port: serial identifier (mandatory). Ex: /dev/ttyS0" + echo "##" + echo "## Note: all trailing arguments will be passed to the $STM32CP_CLI" + echo "## They have to be valid commands for STM32 MCU" + echo "## Ex: -g: Run the code at the specified address" + echo "## -rst: Reset system" + echo "## -s: start automatically (optional)" echo "############################################################" exit $1 } @@ -66,28 +69,26 @@ case $1 in 0) PORT='SWD' MODE='mode=UR' - if [ $# -lt 3 ]; then - OPTS=-rst - else - OPTS=$3 - fi;; + shift 2;; 1) if [ $# -lt 3 ]; then usage 3 else PORT=$3 - if [ $# -gt 3 ]; then - shift 3 - OPTS="$@" - fi + shift 3 fi;; 2) - PORT='USB1';; + PORT='USB1' + shift 2;; *) echo "Protocol unknown!" usage 4;; esac +if [ $# -gt 0 ]; then + OPTS="$@" +fi + ${STM32CP_CLI} -c port=${PORT} ${MODE} -q -d ${FILEPATH} ${ADDRESS} ${OPTS} exit 0 diff --git a/macosx/stm32CubeProg b/macosx/stm32CubeProg index cfa71bf6..af486f1d 100755 --- a/macosx/stm32CubeProg +++ b/macosx/stm32CubeProg @@ -21,12 +21,15 @@ usage() 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: -s" - echo "## com_port: serial identifier. Ex: /dev/ttyS0" - echo "## -s: start automatically" - echo "## For DFU: none" + echo "## For SWD and DFU: no mandatory options" + echo "## For Serial: " + echo "## com_port: serial identifier (mandatory). Ex: /dev/ttyS0" + echo "##" + echo "## Note: all trailing arguments will be passed to the $STM32CP_CLI" + echo "## They have to be valid commands for STM32 MCU" + echo "## Ex: -g: Run the code at the specified address" + echo "## -rst: Reset system" + echo "## -s: start automatically (optional)" echo "############################################################" exit $1 } @@ -65,28 +68,26 @@ case $1 in 0) PORT='SWD' MODE='mode=UR' - if [ $# -lt 3 ]; then - OPTS=-rst - else - OPTS=$3 - fi;; + shift 2;; 1) if [ $# -lt 3 ]; then usage 3 else PORT=$3 - if [ $# -gt 3 ]; then - shift 3 - OPTS="$@" - fi + shift 3 fi;; 2) - PORT='USB1';; + PORT='USB1' + shift 2;; *) echo "Protocol unknown!" usage 4;; esac +if [ $# -gt 0 ]; then + OPTS="$@" +fi + ${STM32CP_CLI} -c port=${PORT} ${MODE} -q -d ${FILEPATH} ${ADDRESS} ${OPTS} exit 0 diff --git a/win/stm32CubeProg.bat b/win/stm32CubeProg.bat index f1d259b1..d6fa20d2 100644 --- a/win/stm32CubeProg.bat +++ b/win/stm32CubeProg.bat @@ -39,22 +39,23 @@ goto :usage :SWD set PORT=SWD set MODE=mode=UR -if "%~3"=="" (set OPTS=-rst) else (set OPTS=%3) -goto :prog +goto :opt :SERIAL if "%~3"=="" set ERROR=3 & goto :usage set PORT=%~3 - -if "%~4"=="" goto :prog shift -shift -shift -set OPTS=%* -goto :prog +goto :opt :DFU set PORT=USB1 +goto :opt + +:opt +shift +shift +if "%~1"=="" goto :prog +set OPTS=%* goto :prog :prog @@ -70,10 +71,13 @@ exit 0 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: ^ -s - echo com_port: serial identifier. Ex: /dev/ttyS0 - echo -s: start automatically - echo For DFU: none + echo For SWD and DFU: no mandatory options + echo For Serial: ^ + echo com_port: serial identifier (mandatory). Ex: COM15 + echo. + echo Note: all trailing arguments will be passed to the %STM32CP_CLI% + echo They have to be valid commands for STM32 MCU + echo Ex: -g: Run the code at the specified address + echo -rst: Reset system + echo -s: start automatically (optional) exit %ERROR%