-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathavrdudeWrapper
More file actions
109 lines (99 loc) · 2.27 KB
/
Copy pathavrdudeWrapper
File metadata and controls
109 lines (99 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/bash
#
# Name: avrdudeWrapper
#
# Version Date Comment
# ------- ---- -------
# 0.0.3 191027 Used call name of script for path to avrdude.
# Made for MacOS and Linux
# 0.0.2 191022 Cleaned up and added the debug option.
# 0.0.1 191022 Initial version
#
# Created on: 191021
# Author: Jacob
#
# Purpose:
# Reset avr109 based arduino to upload mode by pushing the Serial port
# to 1200 Baud on linux machines
# Based on windows bat file by p1ne and Javanaut.
# https://github.com/p1ne/arduino-leonardo-uploader
# https://github.com/javanaut2018/avrdude_autoreset_wrapper
#
# The required information is extracted out of the command line send by
# arduinocdt
#
#
# Usage:
# 1: Place this script in:
# /Users/[YOURUSERNAME]/.arduinocdt/packages/arduino/tools/avrdude/[VERSION]/bin
# 2: Edit:
# /Users/[YOURUSERNAME]/.arduinocdt/packages/arduino/hardware/avr/[VERSION]/platform.txt
# Replace:
# tools.avrdude.cmd.path={path}/bin/avrdude
# With:
# tools.avrdude.cmd.path={path}/bin/avrdude_wrapper.bat
# 3: (re)start eclipse.
#
#
# Set DEBUG to non zero for additional output
DEBUG=0
ME=`basename "$0"`
echo "$ME: starting script"
# print all parameters when in debug mode
if [ $DEBUG -ne 0 ]
then
for arg in "$@"
do
echo $arg
done
fi
OS=`uname`
# Make the program path that is: $0 - scriptname + arduino101load
PROGPATH=${0%$ME}"avrdude"
# Get the options for the excution of the avrdude command
OPTIONS=$*
# Look for the option -c and -P
for arg in "$@"
do
# get the first to characters of the argument
OPT="${arg:0:2}"
case $OPT in
"-c")
# get the programmer mode
PROG=${arg#-c}
;;
"-P")
# get the port
PORT=${arg#-P}
;;
*)
esac
done
# Create the commandline
COMMAND=$PROGPATH" "$OPTIONS
# print all parameters when in debug mode
if [ $DEBUG -ne 0 ]
then
echo "OS = $OS"
echo "Programmer = $PROG"
echo "Program path = $PROGPATH"
echo "Port = $PORT"
echo "Options = $OPTIONS"
echo "Command = $COMMAND"
fi
# Create the delay for avr109 type of boards
if [ $PROG = "avr109" ]
then
if [ $OS = "Darwin" ]
then
echo "$ME: Reset Arduino $OS"
stty -f "$PORT" 1200 cs8 -cstopb -parenb
else
echo "$ME: Reset Arduino $OS"
stty -F "$PORT" 1200 cs8 -cstopb -parenb
fi
echo "$ME: Wait to give the board time to reboot"
sleep 2
fi
$COMMAND
# eof