Skip to content

feat(stm32CubeProg): add offset option #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 5, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat(stm32CubeProg): add offset option
Fixes #57

Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
  • Loading branch information
fpistm committed Mar 31, 2023
commit c2b8d22eb56edf6ac1cad6aaa09a2c2d64befd1e
19 changes: 12 additions & 7 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
Expand All @@ -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"
Expand All @@ -22,6 +23,7 @@ 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>"
Expand Down Expand Up @@ -92,14 +94,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
Expand All @@ -114,19 +119,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!"
Expand Down