Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: stm32duino/Arduino_Tools
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: b1c2d2c
Choose a base ref
...
head repository: stm32duino/Arduino_Tools
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: fdae1cc
Choose a head ref
  • 5 commits
  • 2 files changed
  • 1 contributor

Commits on Mar 31, 2023

  1. feat(stm32CubeProg): add offset option

    Fixes #57
    
    Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
    fpistm committed Mar 31, 2023
    Copy the full SHA
    c2b8d22 View commit details
  2. chore(stm32CubeProg): appply shell check and format

    Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
    fpistm committed Mar 31, 2023
    Copy the full SHA
    4f388d2 View commit details

Commits on Apr 4, 2023

  1. feat(stm32CubeProg): add start at specified address

    Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
    fpistm committed Apr 4, 2023
    Copy the full SHA
    c9b5343 View commit details

Commits on Apr 5, 2023

  1. Merge pull request #90 from fpistm/upload_offset

    feat(stm32CubeProg): add offset option
    fpistm authored Apr 5, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    1e68c09 View commit details

Commits on Jul 5, 2023

  1. doc: update badge version

    Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
    fpistm committed Jul 5, 2023
    Copy the full SHA
    fdae1cc View commit details
Showing with 23 additions and 20 deletions.
  1. +1 −1 README.md
  2. +22 −19 stm32CubeProg.sh
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Arduino_Tools
[![GitHub release](https://img.shields.io/github/release/stm32duino/Arduino_Tools.svg)](https://github.com/stm32duino/Arduino_Tools/releases/latest)
[![GitHub commits](https://img.shields.io/github/commits-since/stm32duino/Arduino_Tools/2.2.0.svg)](https://github.com/stm32duino/Arduino_Tools/compare/2.2.0...master)
[![GitHub commits](https://img.shields.io/github/commits-since/stm32duino/Arduino_Tools/2.2.1.svg)](https://github.com/stm32duino/Arduino_Tools/compare/2.2.1...master)

Contains upload tools for STM32 based boards and some other usefull scripts.
41 changes: 22 additions & 19 deletions stm32CubeProg.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/sh -
set -o nounset # Treat unset variables as an error
# set -o xtrace # Print command traces before executing command.

STM32CP_CLI=
ADDRESS=0x8000000
@@ -13,7 +14,7 @@ OPTS=""
usage() {
echo "############################################################"
echo "##"
echo "## $(basename "$0") <protocol> <file_path> [OPTIONS]"
echo "## $(basename "$0") <protocol> <file_path> <offset> [OPTIONS]"
echo "##"
echo "## protocol:"
echo "## 0: SWD"
@@ -22,16 +23,15 @@ usage() {
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 "## offset: offset to add to $ADDRESS"
echo "## Options:"
echo "## For SWD and DFU: no mandatory options"
echo "## For Serial: <com_port>"
echo "## com_port: serial identifier (mandatory). Ex: /dev/ttyS0 or COM1"
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 "## They have to be valid commands for STM32CubeProgrammer cli"
echo "## Ex: -rst: Reset system"
echo "############################################################"
exit "$1"
}
@@ -40,13 +40,13 @@ UNAME_OS="$(uname -s)"
case "${UNAME_OS}" in
Linux*)
STM32CP_CLI=STM32_Programmer.sh
if ! command -v $STM32CP_CLI >/dev/null 2>&1; then
if ! command -v $STM32CP_CLI > /dev/null 2>&1; then
export PATH="$HOME/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin":"$PATH"
fi
if ! command -v $STM32CP_CLI >/dev/null 2>&1; then
if ! command -v $STM32CP_CLI > /dev/null 2>&1; then
export PATH="/opt/stm32cubeprog/bin":"$PATH"
fi
if ! command -v $STM32CP_CLI >/dev/null 2>&1; then
if ! command -v $STM32CP_CLI > /dev/null 2>&1; then
echo "STM32CubeProgrammer not found ($STM32CP_CLI)."
echo "Please install it or add '<STM32CubeProgrammer path>/bin' to your PATH environment:"
echo "https://www.st.com/en/development-tools/stm32cubeprog.html"
@@ -56,10 +56,10 @@ case "${UNAME_OS}" in
;;
Darwin*)
STM32CP_CLI=STM32_Programmer_CLI
if ! command -v $STM32CP_CLI >/dev/null 2>&1; then
if ! command -v $STM32CP_CLI > /dev/null 2>&1; then
export PATH="/Applications/STMicroelectronics/STM32Cube/STM32CubeProgrammer/STM32CubeProgrammer.app/Contents/MacOs/bin":"$PATH"
fi
if ! command -v $STM32CP_CLI >/dev/null 2>&1; then
if ! command -v $STM32CP_CLI > /dev/null 2>&1; then
echo "STM32CubeProgrammer not found ($STM32CP_CLI)."
echo "Please install it or add '<STM32CubeProgrammer path>/bin' to your PATH environment:"
echo "https://www.st.com/en/development-tools/stm32cubeprog.html"
@@ -69,7 +69,7 @@ case "${UNAME_OS}" in
;;
Windows*)
STM32CP_CLI=STM32_Programmer_CLI.exe
if ! command -v $STM32CP_CLI >/dev/null 2>&1; then
if ! command -v $STM32CP_CLI > /dev/null 2>&1; then
if [ -n "${PROGRAMFILES+x}" ]; then
STM32CP86=${PROGRAMFILES}/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin
export PATH="${STM32CP86}":"$PATH"
@@ -78,7 +78,7 @@ case "${UNAME_OS}" in
STM32CP=${PROGRAMW6432}/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin
export PATH="${STM32CP}":"$PATH"
fi
if ! command -v $STM32CP_CLI >/dev/null 2>&1; then
if ! command -v $STM32CP_CLI > /dev/null 2>&1; then
echo "STM32CubeProgrammer not found ($STM32CP_CLI)."
echo "Please install it or add '<STM32CubeProgrammer path>\bin' to your PATH environment:"
echo "https://www.st.com/en/development-tools/stm32cubeprog.html"
@@ -92,14 +92,17 @@ case "${UNAME_OS}" in
;;
esac

if [ $# -lt 2 ]; then
if [ $# -lt 3 ]; then
echo "Not enough arguments!"
usage 2
fi

# Parse options
PROTOCOL=$1
FILEPATH=$2
OFFSET=$3
ADDRESS=$(printf "0x%x" $((ADDRESS + OFFSET)))

# Protocol $1
# 1x: Erase all sectors
if [ "$1" -ge 10 ]; then
@@ -114,19 +117,19 @@ case $PROTOCOL in
0)
PORT="SWD"
MODE="mode=UR"
shift 2
shift 3
;;
1)
if [ $# -lt 3 ]; then
if [ $# -lt 4 ]; then
usage 3
else
PORT=$3
shift 3
PORT=$4
shift 4
fi
;;
2)
PORT="USB1"
shift 2
shift 3
;;
*)
echo "Protocol unknown!"
@@ -138,6 +141,6 @@ if [ $# -gt 0 ]; then
OPTS="$*"
fi

${STM32CP_CLI} -c port=${PORT} ${MODE} ${ERASE:+"-e all"} -q -d "${FILEPATH}" ${ADDRESS} "${OPTS}"
${STM32CP_CLI} -c port=${PORT} ${MODE} ${ERASE:+"-e all"} -q -d "${FILEPATH}" "${ADDRESS}" -s "${ADDRESS}" "${OPTS}"

exit $?