@@ -32,6 +32,7 @@ usage()
3232echo " ## Options:"
3333echo " ## For SWD: no mandatory options"
3434echo " ## For DFU: no mandatory options"
35+ echo " ## Use '-serport=<com_port>' to request reset to bootloader mode"
3536echo " ## For Serial: 'serport=<com_port>'"
3637echo " ## com_port: serial identifier (mandatory). Ex: /dev/ttyS0"
3738echo " ##"
@@ -60,6 +61,26 @@ check_tool() {
6061fi
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/null2>&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+
6384upload () {
6485 count=0
6586 STATUS=1
@@ -112,7 +133,8 @@ case $PROTOCOL in
112133fi
113134 PORT=$SERPORT ;;
114135 2)
115- PORT=' USB1' ;;
136+ PORT=' USB1'
137+ bootloaderMode;;
116138* )
117139echo " Protocol unknown!"
118140 usage 4;;