-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e7e552f
commit 5916e8c
Showing
1 changed file
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,46 @@ | ||
|
||
#!/bin/bash | ||
$(dirname $0)/stlink/st-flash write "$4" 0x8000000 | ||
|
||
# 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 | ||
|
5916e8c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This script fails now as it has an extra line at the beginning now. This causes an error:
/mnt/vbox/shared/Arduino_STM32_Sketch/hardware/Arduino_STM32/tools/linux/stlink_upload: 5: /mnt/vbox/shared/Arduino_STM32_Sketch/hardware/Arduino_STM32/tools/linux/stlink_upload: Syntax error: "(" unexpected
http://stackoverflow.com/questions/12910744/why-should-the-shebang-line-always-be-the-first-line