|
@@ -9,107 +9,133 @@
|
9
|
9
|
# Will continue on if a COM port isn't found so that the compilation can be done.
|
10
|
10
|
#
|
11
|
11
|
|
|
12
|
+import subprocess
|
|
13
|
+import os
|
12
|
14
|
import sys
|
|
15
|
+from SCons.Script import DefaultEnvironment
|
|
16
|
+import platform
|
|
17
|
+current_OS = platform.system()
|
13
|
18
|
|
14
|
|
-import subprocess
|
|
19
|
+env = DefaultEnvironment()
|
15
|
20
|
|
|
21
|
+build_type = os.environ.get("BUILD_TYPE", 'Not Set')
|
16
|
22
|
|
17
|
|
-import platform
|
18
|
|
-current_OS = platform.system()
|
19
|
23
|
|
20
|
|
-from SCons.Script import DefaultEnvironment
|
|
24
|
+if not(build_type == 'upload' or build_type == 'traceback' or build_type == 'Not Set') :
|
|
25
|
+ env.Replace(UPLOAD_PROTOCOL = 'teensy-gui') # run normal Teensy2 scripts
|
|
26
|
+else:
|
|
27
|
+ com_first = ''
|
|
28
|
+ com_last = ''
|
|
29
|
+ com_CDC = ''
|
|
30
|
+ description_first = ''
|
|
31
|
+ description_last = ''
|
|
32
|
+ description_CDC = ''
|
21
|
33
|
|
22
|
|
-env = DefaultEnvironment()
|
|
34
|
+ #
|
|
35
|
+ # grab the first com port that pops up unless we find one we know for sure
|
|
36
|
+ # is a CDC device
|
|
37
|
+ #
|
|
38
|
+ def get_com_port(com_search_text, descr_search_text, start):
|
23
|
39
|
|
24
|
|
-com_first = ''
|
25
|
|
-com_last = ''
|
26
|
|
-com_CDC = ''
|
27
|
|
-description_first = ''
|
28
|
|
-description_last = ''
|
29
|
|
-description_CDC = ''
|
|
40
|
+ global com_first
|
|
41
|
+ global com_last
|
|
42
|
+ global com_CDC
|
|
43
|
+ global description_first
|
|
44
|
+ global description_last
|
|
45
|
+ global description_CDC
|
30
|
46
|
|
31
|
|
-#
|
32
|
|
-# grab the first com port that pops up unless we find one we know for sure
|
33
|
|
-# is a CDC device
|
34
|
|
-#
|
35
|
|
-def get_com_port(com_search_text, descr_search_text, start):
|
36
|
47
|
|
37
|
|
- global com_first
|
38
|
|
- global com_last
|
39
|
|
- global com_CDC
|
40
|
|
- global description_first
|
41
|
|
- global description_last
|
42
|
|
- global description_CDC
|
|
48
|
+ print '\nLooking for Serial Port\n'
|
|
49
|
+
|
|
50
|
+ # stream output from subprocess and split it into lines
|
|
51
|
+ pio_subprocess = subprocess.Popen(['platformio', 'device', 'list'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
|
52
|
+
|
|
53
|
+ looking_for_description = False
|
|
54
|
+ for line in iter(pio_subprocess.stdout.readline, ''):
|
|
55
|
+ if 0 <= line.find(com_search_text):
|
|
56
|
+ looking_for_description = True
|
|
57
|
+ com_last = line.replace('\n', '')
|
|
58
|
+ if com_first == '':
|
|
59
|
+ com_first = com_last
|
|
60
|
+ if 0 <= line.find(descr_search_text) and looking_for_description:
|
|
61
|
+ looking_for_description = False
|
|
62
|
+ description_last = line[ start : ]
|
|
63
|
+ if description_first == '':
|
|
64
|
+ description_first = description_last
|
|
65
|
+ if 0 <= description_last.find('CDC'):
|
|
66
|
+ com_CDC = com_last
|
|
67
|
+ description_CDC = description_last
|
|
68
|
+
|
|
69
|
+ if com_CDC == '' and not(com_first == ''):
|
|
70
|
+ com_CDC = com_first
|
|
71
|
+ description_CDC = description_first
|
|
72
|
+ elif com_CDC == '':
|
|
73
|
+ com_CDC = 'COM_PORT_NOT_FOUND'
|
|
74
|
+
|
|
75
|
+ while 0 <= com_CDC.find('\n'):
|
|
76
|
+ com_CDC = com_CDC.replace('\n', '')
|
|
77
|
+ while 0 <= com_CDC.find('\r'):
|
|
78
|
+ com_CDC = com_CDC.replace('\r', '')
|
|
79
|
+
|
|
80
|
+ if com_CDC == 'COM_PORT_NOT_FOUND':
|
|
81
|
+ print com_CDC, '\n'
|
|
82
|
+ else:
|
|
83
|
+ print 'FOUND: ' ,com_CDC
|
|
84
|
+ print 'DESCRIPTION: ', description_CDC , '\n'
|
43
|
85
|
|
|
86
|
+ if current_OS == 'Windows':
|
44
|
87
|
|
45
|
|
- print '\nLooking for Serial Port\n'
|
|
88
|
+ get_com_port('COM', 'Hardware ID:', 13)
|
46
|
89
|
|
47
|
|
- # stream output from subprocess and split it into lines
|
48
|
|
- pio_subprocess = subprocess.Popen(['platformio', 'device', 'list'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
|
90
|
+ # avrdude_conf_path = env.get("PIOHOME_DIR") + '\\packages\\toolchain-atmelavr\\etc\\avrdude.conf'
|
|
91
|
+ avrdude_conf_path = 'buildroot\\share\\atom\\avrdude.conf'
|
49
|
92
|
|
50
|
|
- looking_for_description = False
|
51
|
|
- for line in iter(pio_subprocess.stdout.readline, ''):
|
52
|
|
- if 0 <= line.find(com_search_text):
|
53
|
|
- looking_for_description = True
|
54
|
|
- com_last = line.replace('\n', '')
|
55
|
|
- if com_first == '':
|
56
|
|
- com_first = com_last
|
57
|
|
- if 0 <= line.find(descr_search_text) and looking_for_description:
|
58
|
|
- looking_for_description = False
|
59
|
|
- description_last = line[ start : ]
|
60
|
|
- if description_first == '':
|
61
|
|
- description_first = description_last
|
62
|
|
- if 0 <= description_last.find('CDC'):
|
63
|
|
- com_CDC = com_last
|
64
|
|
- description_CDC = description_last
|
|
93
|
+ avrdude_exe_path = 'buildroot\\share\\atom\\avrdude_5.10.exe'
|
65
|
94
|
|
66
|
|
- if com_CDC == '' and not(com_first == ''):
|
67
|
|
- com_CDC = com_first
|
68
|
|
- description_CDC = description_first
|
69
|
|
- elif com_CDC == '':
|
70
|
|
- com_CDC = 'COM_PORT_NOT_FOUND'
|
|
95
|
+ # source_path = env.get("PROJECTBUILD_DIR") + '\\' + env.get("PIOENV") + '\\firmware.hex'
|
|
96
|
+ source_path = '.pioenvs\\' + env.get("PIOENV") + '\\firmware.hex'
|
71
|
97
|
|
72
|
|
- if com_CDC == 'COM_PORT_NOT_FOUND':
|
73
|
|
- print com_CDC, '\n'
|
74
|
|
- else:
|
75
|
|
- print 'FOUND: ' ,com_CDC
|
76
|
|
- print 'DESCRIPTION: ', description_CDC , '\n'
|
|
98
|
+ upload_string = avrdude_exe_path + ' -p usb1286 -c avr109 -P ' + com_CDC + ' -U flash:w:' + source_path + ':i'
|
77
|
99
|
|
78
|
|
-if current_OS == 'Windows':
|
79
|
100
|
|
80
|
|
- get_com_port('COM', 'Hardware ID:', 13)
|
|
101
|
+ if current_OS == 'Darwin': # MAC
|
81
|
102
|
|
82
|
|
- avrdude_conf_path = env.get("PIOHOME_DIR") + '\\packages\\toolchain-atmelavr\\etc\\avrdude.conf'
|
|
103
|
+ get_com_port('usbmodem', 'Description:', 13)
|
83
|
104
|
|
84
|
|
- source_path = env.get("PROJECTBUILD_DIR") + '\\' + env.get("PIOENV") + '\\firmware.hex'
|
|
105
|
+# avrdude_conf_path = env.get("PIOHOME_DIR") + '/packages/toolchain-atmelavr/etc/avrdude.conf'
|
|
106
|
+ avrdude_conf_path = 'buildroot/share/atom/avrdude_macOS.conf'
|
85
|
107
|
|
86
|
|
- upload_string = 'avrdude -p usb1286 -c avr109 -P ' + com_CDC + ' -C ' + avrdude_conf_path + ' -U flash:w:' + source_path + ':i'
|
87
|
108
|
|
|
109
|
+ avrdude_exe_path = 'buildroot/share/atom/avrdude_5.10_macOS'
|
88
|
110
|
|
89
|
|
-if current_OS == 'Darwin': # MAC
|
|
111
|
+# source_path = env.get("PROJECTBUILD_DIR") + '/' + env.get("PIOENV") + '/firmware.hex'
|
|
112
|
+ source_path = '.pioenvs/' + env.get("PIOENV") + '/firmware.hex'
|
90
|
113
|
|
91
|
|
- get_com_port('usbmodem', 'Description:', 13)
|
92
|
114
|
|
93
|
|
- avrdude_conf_path = env.get("PIOHOME_DIR") + '/packages/toolchain-atmelavr/etc/avrdude.conf'
|
|
115
|
+# upload_string = 'avrdude -p usb1286 -c avr109 -P ' + com_CDC + ' -U flash:w:' + source_path + ':i'
|
|
116
|
+ upload_string = avrdude_exe_path + ' -p usb1286 -c avr109 -P ' + com_CDC + ' -C ' + avrdude_conf_path + ' -U flash:w:' + source_path + ':i'
|
|
117
|
+ print 'upload_string: ', upload_string
|
94
|
118
|
|
95
|
|
- source_path = env.get("PROJECTBUILD_DIR") + '/' + env.get("PIOENV") + '/firmware.hex'
|
96
|
119
|
|
97
|
|
- upload_string = 'avrdude -p usb1286 -c avr109 -P ' + com_CDC + ' -U flash:w:' + source_path + ':i'
|
98
|
120
|
|
|
121
|
+ if current_OS == 'Linux':
|
99
|
122
|
|
100
|
|
-if current_OS == 'Linux':
|
|
123
|
+ get_com_port('/dev/tty', 'Description:', 13)
|
101
|
124
|
|
102
|
|
- get_com_port('/dev/tty', 'Description:', 13)
|
|
125
|
+# avrdude_conf_path = env.get("PIOHOME_DIR") + '/packages/toolchain-atmelavr/etc/avrdude.conf'
|
|
126
|
+ avrdude_conf_path = 'buildroot/share/atom/avrdude_linux.conf'
|
103
|
127
|
|
104
|
|
- avrdude_conf_path = env.get("PIOHOME_DIR") + '/packages/toolchain-atmelavr/etc/avrdude.conf'
|
105
|
128
|
|
106
|
|
- source_path = env.get("PROJECTBUILD_DIR") + '/' + env.get("PIOENV") + '/firmware.hex'
|
|
129
|
+ avrdude_exe_path = 'buildroot/share/atom/avrdude_5.10_linux'
|
|
130
|
+# source_path = env.get("PROJECTBUILD_DIR") + '/' + env.get("PIOENV") + '/firmware.hex'
|
|
131
|
+ source_path = '.pioenvs/' + env.get("PIOENV") + '/firmware.hex'
|
107
|
132
|
|
108
|
|
- upload_string = 'avrdude -p usb1286 -c avr109 -P ' + com_CDC + ' -U flash:w:' + source_path + ':i'
|
|
133
|
+# upload_string = 'avrdude -p usb1286 -c avr109 -P ' + com_CDC + ' -U flash:w:' + source_path + ':i'
|
|
134
|
+ upload_string = avrdude_exe_path + ' -p usb1286 -c avr109 -P ' + com_CDC + ' -C ' + avrdude_conf_path + ' -U flash:w:' + source_path + ':i'
|
109
|
135
|
|
110
|
136
|
|
111
|
|
-env.Replace(
|
112
|
|
- UPLOADCMD = upload_string,
|
113
|
|
- MAXIMUM_RAM_SIZE = 8192,
|
114
|
|
- MAXIMUM_SIZE = 130048
|
115
|
|
-)
|
|
137
|
+ env.Replace(
|
|
138
|
+ UPLOADCMD = upload_string,
|
|
139
|
+ MAXIMUM_RAM_SIZE = 8192,
|
|
140
|
+ MAXIMUM_SIZE = 130048
|
|
141
|
+ )
|