Merge pull request #34 from fpistm/STM32CP

Introduce STM32CubeProgrammer
This commit is contained in:
Frederic Pillon 2019-05-03 15:22:26 +02:00 committed by GitHub
commit 0a5abb3fe5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
122 changed files with 266 additions and 517 deletions

View file

@ -1,11 +0,0 @@
# stm32 discovery boards, with onboard st/linkv1
# ie, STM32VL
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3744", \
MODE:="0666", \
SYMLINK+="stlinkv1_%n"
# If you share your linux system with other users, or just don't like the
# idea of write permission for everybody, you can replace MODE:="0666" with
# OWNER:="yourusername" to create the device owned by you, or with
# GROUP:="somegroupname" and mange access using standard unix groups.

View file

@ -1,12 +0,0 @@
# stm32 nucleo boards, with onboard st/linkv2-1
# ie, STM32F0, STM32F4.
# STM32VL has st/linkv1, which is quite different
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374b", \
MODE:="0666", \
SYMLINK+="stlinkv2-1_%n"
# If you share your linux system with other users, or just don't like the
# idea of write permission for everybody, you can replace MODE:="0666" with
# OWNER:="yourusername" to create the device owned by you, or with
# GROUP:="somegroupname" and mange access using standard unix groups.

View file

@ -1,12 +0,0 @@
# stm32 discovery boards, with onboard st/linkv2
# ie, STM32L, STM32F4.
# STM32VL has st/linkv1, which is quite different
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3748", \
MODE:="0666", \
SYMLINK+="stlinkv2_%n"
# If you share your linux system with other users, or just don't like the
# idea of write permission for everybody, you can replace MODE:="0666" with
# OWNER:="yourusername" to create the device owned by you, or with
# GROUP:="somegroupname" and mange access using standard unix groups.

View file

@ -5,15 +5,6 @@ if sudo [ -w /etc/udev/rules.d ]; then
sudo cp -v 45-maple.rules /etc/udev/rules.d/45-maple.rules
sudo chown root:root /etc/udev/rules.d/45-maple.rules
sudo chmod 644 /etc/udev/rules.d/45-maple.rules
sudo cp -v 49-stlinkv1.rules /etc/udev/rules.d/49-stlinkv1.rules
sudo chown root:root /etc/udev/rules.d/49-stlinkv1.rules
sudo chmod 644 /etc/udev/rules.d/49-stlinkv1.rules
sudo cp -v 49-stlinkv2.rules /etc/udev/rules.d/49-stlinkv2.rules
sudo chown root:root /etc/udev/rules.d/49-stlinkv2.rules
sudo chmod 644 /etc/udev/rules.d/49-stlinkv2.rules
sudo cp -v 49-stlinkv2-1.rules /etc/udev/rules.d/49-stlinkv2-1.rules
sudo chown root:root /etc/udev/rules.d/49-stlinkv2-1.rules
sudo chmod 644 /etc/udev/rules.d/49-stlinkv2-1.rules
echo "Reloading udev rules"
sudo udevadm control --reload-rules
echo "Adding current user to dialout group"

View file

@ -1 +0,0 @@
The maple upload script needs its rights to be set to 755

View file

@ -1,2 +0,0 @@
#!/bin/bash
$(dirname $0)/stm32flash/stm32flash -g 0x8000000 -b 115200 -w "$4" /dev/"$1"

Binary file not shown.

View file

@ -1 +0,0 @@
libstlink.so.1

View file

@ -1 +0,0 @@
libstlink.so.1.5.1

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,54 +0,0 @@
#!/bin/bash
LD_LIBRARY_PATH=$(dirname $0)/stlink/lib
if [ `uname -m` == "x86_64" ]; then
$(dirname $0)/../linux64/stlink_upload $*
else
$(dirname $0)/stlink/st-flash write "$4" 0x8000000
fi
exit 0
## Remove the lines 2 to 7 (above) if you want this script to wait until the Serial device has been enumerated and loaded before the script exits
# Check for leaf device.
function leaf_status()
{
this_leaf_status=$(lsusb |grep "1eaf" | awk '{ print $NF}')
# Find the mode of the leaf bootloader
case $this_leaf_status in
"1eaf:0003")
echo "dfu"
;;
"1eaf:0004")
echo "ttyACMx"
;;
*)
#echo "$this_leaf_status"
echo "unknown"
;;
esac
}
# You will need the usb-reset code, see https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki/Using-a-generic-stm32-board-on-linux-with-Maple-bootloader
#
USBRESET=$(which usb-reset) || USBRESET="./usb-reset"
# Check to see if a maple compatible board is attached
LEAF_STATUS=$(leaf_status)
echo "USB Status [$LEAF_STATUS]"
$(dirname $0)/stlink/st-flash write "$4" 0x8000000
sleep 4
# Reset the usb device to bring up the tty rather than DFU
"$USBRESET" "/dev/bus/usb/$(lsusb |grep "1eaf" |awk '{print $2,$4}'|sed 's/\://g'|sed 's/ /\//g')" >/dev/null 2>&1
# Check to see if a maple compatible board is attached
LEAF_STATUS=$(leaf_status)
echo "USB Status [$LEAF_STATUS]"
# Check to see if the tty came up
TTY_DEV=$(find /dev -cmin -2 |grep ttyAC)
echo -e "Waiting for tty device $TTY_DEV \n"
sleep 20
echo -e "$TTY_DEV should now be available.\n"
exit 0

94
linux/stm32CubeProg.sh Executable file
View 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

Binary file not shown.

View file

@ -1,11 +0,0 @@
# stm32 discovery boards, with onboard st/linkv1
# ie, STM32VL
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3744", \
MODE:="0666", \
SYMLINK+="stlinkv1_%n"
# If you share your linux system with other users, or just don't like the
# idea of write permission for everybody, you can replace MODE:="0666" with
# OWNER:="yourusername" to create the device owned by you, or with
# GROUP:="somegroupname" and mange access using standard unix groups.

View file

@ -1,12 +0,0 @@
# stm32 nucleo boards, with onboard st/linkv2-1
# ie, STM32F0, STM32F4.
# STM32VL has st/linkv1, which is quite different
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374b", \
MODE:="0666", \
SYMLINK+="stlinkv2-1_%n"
# If you share your linux system with other users, or just don't like the
# idea of write permission for everybody, you can replace MODE:="0666" with
# OWNER:="yourusername" to create the device owned by you, or with
# GROUP:="somegroupname" and mange access using standard unix groups.

View file

@ -1,12 +0,0 @@
# stm32 discovery boards, with onboard st/linkv2
# ie, STM32L, STM32F4.
# STM32VL has st/linkv1, which is quite different
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3748", \
MODE:="0666", \
SYMLINK+="stlinkv2_%n"
# If you share your linux system with other users, or just don't like the
# idea of write permission for everybody, you can replace MODE:="0666" with
# OWNER:="yourusername" to create the device owned by you, or with
# GROUP:="somegroupname" and mange access using standard unix groups.

View file

@ -5,15 +5,6 @@ if sudo [ -w /etc/udev/rules.d ]; then
sudo cp -v 45-maple.rules /etc/udev/rules.d/45-maple.rules
sudo chown root:root /etc/udev/rules.d/45-maple.rules
sudo chmod 644 /etc/udev/rules.d/45-maple.rules
sudo cp -v 49-stlinkv1.rules /etc/udev/rules.d/49-stlinkv1.rules
sudo chown root:root /etc/udev/rules.d/49-stlinkv1.rules
sudo chmod 644 /etc/udev/rules.d/49-stlinkv1.rules
sudo cp -v 49-stlinkv2.rules /etc/udev/rules.d/49-stlinkv2.rules
sudo chown root:root /etc/udev/rules.d/49-stlinkv2.rules
sudo chmod 644 /etc/udev/rules.d/49-stlinkv2.rules
sudo cp -v 49-stlinkv2-1.rules /etc/udev/rules.d/49-stlinkv2-1.rules
sudo chown root:root /etc/udev/rules.d/49-stlinkv2-1.rules
sudo chmod 644 /etc/udev/rules.d/49-stlinkv2-1.rules
echo "Reloading udev rules"
sudo udevadm control --reload-rules
echo "Adding current user to dialout group"

View file

@ -1 +0,0 @@
The maple upload script needs its rights to be set to 755

View file

@ -1,2 +0,0 @@
#!/bin/bash
$(dirname $0)/stm32flash/stm32flash -g 0x8000000 -b 115200 -w "$4" /dev/"$1"

Binary file not shown.

View file

@ -1 +0,0 @@
libstlink.so.1

View file

@ -1 +0,0 @@
libstlink.so.1.5.1

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,48 +0,0 @@
#!/bin/bash
LD_LIBRARY_PATH=$(dirname $0)/stlink/lib
$(dirname $0)/stlink/st-flash write "$4" 0x8000000
exit 0
# Check for leaf device.
function leaf_status()
{
this_leaf_status=$(lsusb |grep "1eaf" | awk '{ print $NF}')
# Find the mode of the leaf bootloader
case $this_leaf_status in
"1eaf:0003")
echo "dfu"
;;
"1eaf:0004")
echo "ttyACMx"
;;
*)
#echo "$this_leaf_status"
echo "unknown"
;;
esac
}
# You will need the usb-reset code, see https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki/Using-a-generic-stm32-board-on-linux-with-Maple-bootloader
#
USBRESET=$(which usb-reset) || USBRESET="./usb-reset"
# Check to see if a maple compatible board is attached
LEAF_STATUS=$(leaf_status)
echo "USB Status [$LEAF_STATUS]"
$(dirname $0)/stlink/st-flash write "$4" 0x8000000
sleep 4
# Reset the usb device to bring up the tty rather than DFU
"$USBRESET" "/dev/bus/usb/$(lsusb |grep "1eaf" |awk '{print $2,$4}'|sed 's/\://g'|sed 's/ /\//g')" >/dev/null 2>&1
# Check to see if a maple compatible board is attached
LEAF_STATUS=$(leaf_status)
echo "USB Status [$LEAF_STATUS]"
# Check to see if the tty came up
TTY_DEV=$(find /dev -cmin -2 |grep ttyAC)
echo -e "Waiting for tty device $TTY_DEV \n"
sleep 20
echo -e "$TTY_DEV should now be available.\n"
exit 0

Binary file not shown.

View file

@ -1,2 +0,0 @@
#!/bin/bash
$(dirname $0)/stm32flash/stm32flash -g 0x8000000 -b 115200 -w "$4" /dev/"$1"

View file

@ -1 +0,0 @@
libstlink.1.5.1.dylib

Binary file not shown.

View file

@ -1 +0,0 @@
libstlink.1.dylib

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,3 +0,0 @@
#!/bin/bash
DYLD_LIBRARY_PATH=$(dirname $0)/stlink/lib
$(dirname $0)/stlink/st-flash write "$4" 0x8000000

93
macosx/stm32CubeProg Executable file
View 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

Binary file not shown.

View file

@ -1,11 +0,0 @@
@echo off
rem: Note %~dp0 get path of this batch file
rem: Need to change drive if My Documents is on a drive other than C:
set driverLetter=%~dp0
set driverLetter=%driverLetter:~0,2%
%driverLetter%
cd %~dp0
rem: the two line below are needed to fix path issues with incorrect slashes before the bin file name
set str=%4
set str=%str:/=\%
stm32flash\stm32flash.exe -g 0x8000000 -b 115200 -w %str% %1

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show more