Skip to content

Commit 5916e8c

Browse files
Updated linux stlink_upload
1 parent e7e552f commit 5916e8c

1 file changed

Lines changed: 45 additions & 1 deletion

File tree

tools/linux/stlink_upload

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,46 @@
1+
12
#!/bin/bash
2-
$(dirname $0)/stlink/st-flash write "$4" 0x8000000
3+
4+
# Check for leaf device.
5+
function leaf_status()
6+
{
7+
8+
this_leaf_status=$(lsusb |grep "1eaf" | awk '{ print $NF}')
9+
# Find the mode of the leaf bootloader
10+
case $this_leaf_status in
11+
"1eaf:0003")
12+
echo "dfu"
13+
;;
14+
"1eaf:0004")
15+
echo "ttyACMx"
16+
;;
17+
*)
18+
#echo "$this_leaf_status"
19+
echo "unknown"
20+
;;
21+
esac
22+
}
23+
24+
# 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
25+
#
26+
USBRESET=$(which usb-reset) || USBRESET="./usb-reset"
27+
28+
# Check to see if a maple compatible board is attached
29+
LEAF_STATUS=$(leaf_status)
30+
echo "USB Status [$LEAF_STATUS]"
31+
32+
$(dirname $0)/stlink/st-flash write "$4" 0x8000000
33+
34+
sleep 4
35+
# Reset the usb device to bring up the tty rather than DFU
36+
"$USBRESET" "/dev/bus/usb/$(lsusb |grep "1eaf" |awk '{print $2,$4}'|sed 's/\://g'|sed 's/ /\//g')" >/dev/null 2>&1
37+
# Check to see if a maple compatible board is attached
38+
LEAF_STATUS=$(leaf_status)
39+
echo "USB Status [$LEAF_STATUS]"
40+
# Check to see if the tty came up
41+
TTY_DEV=$(find /dev -cmin -2 |grep ttyAC)
42+
echo -e "Waiting for tty device $TTY_DEV \n"
43+
sleep 20
44+
echo -e "$TTY_DEV should now be available.\n"
45+
exit 0
46+

0 commit comments

Comments
 (0)