Skip to content

Commit da2ec11

Browse files
committed
[STM32CubeProg] Add support to request reset to bootloader mode
Signed-off-by: Frederic Pillon <[email protected]>
1 parent 775cb47 commit da2ec11

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

linux/stm32CubeProg.sh

+23-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ usage()
3232
echo "## Options:"
3333
echo "## For SWD: no mandatory options"
3434
echo "## For DFU: no mandatory options"
35+
echo "## Use '-serport=<com_port>' to request reset to bootloader mode"
3536
echo "## For Serial: 'serport=<com_port>'"
3637
echo "## com_port: serial identifier (mandatory). Ex: /dev/ttyS0"
3738
echo "##"
@@ -60,6 +61,26 @@ check_tool() {
6061
fi
6162
}
6263

64+
bootloaderMode() {
65+
if [ ! -z $SERPORT ]; then
66+
# Try to configure it at 1200 to restart
67+
# in Bootloader mode
68+
if [ -c $SERPORT ]; then
69+
count=0
70+
res=1
71+
while [ $res -ne 0 ] && ((count++ < 5)); do
72+
# echo "Try to set $SERPORT at 1200"
73+
stty -F $SERPORT 1200 > /dev/null 2>&1
74+
res=$?
75+
sleep 0.1
76+
done
77+
if [ $res -eq 0 ]; then
78+
sleep 0.5
79+
fi
80+
fi
81+
fi
82+
}
83+
6384
upload() {
6485
count=0
6586
STATUS=1
@@ -112,7 +133,8 @@ case $PROTOCOL in
112133
fi
113134
PORT=$SERPORT;;
114135
2)
115-
PORT='USB1';;
136+
PORT='USB1'
137+
bootloaderMode;;
116138
*)
117139
echo "Protocol unknown!"
118140
usage 4;;

0 commit comments

Comments
 (0)