Adding stm32 auto-upload scripts for Windows, Mac, and Linux (#184)

This commit is contained in:
Ben Lye
2018-08-16 09:29:47 +01:00
committed by GitHub
parent 1dc52773f4
commit 685de52538
11 changed files with 234 additions and 8 deletions

View File

@@ -0,0 +1,45 @@
#!/bin/bash
#set -e
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
}
# Get the directory where the script is running.
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
# Check to see if a maple compatible board is attached
LEAF_STATUS=$(leaf_status)
# Board not found, or no boot loader on board.
if [[ $(leaf_status) = "unknown" ]]
then
# No maple board detected
echo "Maple device not found. Attempting serial upload."
SERIAL_UPLOAD=${DIR}/serial_upload_inc_bootloader
echo "${SERIAL_UPLOAD}" $1 0x8000000 $2 $3
"${SERIAL_UPLOAD}" $1 0x8000000 $2 $3
else
# Maple board detected
echo "Maple device found. Attempting USB upload."
MAPLE_UPLOAD=${DIR}/maple_upload
echo "${MAPLE_UPLOAD}" $1 2 1eaf:0003 $2
"${MAPLE_UPLOAD}" $1 2 1eaf:0003 $2
fi