Browse Source

install AVRDUDE 5.10, faster disk find for LPC1768 (#10849)

Bob Kuhn 6 years ago
parent
commit
235facd545

+ 13
- 34
Marlin/src/HAL/HAL_LPC1768/upload_extra_script.py View File

@@ -6,10 +6,10 @@
6 6
 
7 7
 target_filename = "FIRMWARE.CUR"
8 8
 target_drive = "REARM"
9
-upload_disk = ""
10 9
 
11 10
 import os
12
-import subprocess
11
+import platform
12
+current_OS = platform.system()
13 13
 
14 14
 #env_vars = subprocess.check_output('platformio run -t envdump')
15 15
 #env_vars = env_vars.split('\n')
@@ -21,10 +21,6 @@ build_type = os.environ.get("BUILD_TYPE", 'Not Set')
21 21
 if not(build_type == 'upload' or build_type == 'traceback' or build_type == 'Not Set') :
22 22
   exit(0)
23 23
 
24
-print '\nSearching for upload disk'
25
-
26
-import platform
27
-current_OS = platform.system()
28 24
 
29 25
 if current_OS == 'Windows':
30 26
 
@@ -43,38 +39,22 @@ if current_OS == 'Windows':
43 39
     driveStr = driveStr.strip().lstrip('Drives: ')  # typical result (string): 'C:\ D:\ E:\ F:\ G:\ H:\ I:\ J:\ K:\ L:\ M:\ Y:\ Z:\'
44 40
     drives = driveStr.split()  # typical result (array of stings): ['C:\\', 'D:\\', 'E:\\', 'F:\\', 'G:\\', 'H:\\', 'I:\\', 'J:\\', 'K:\\', 'L:\\', 'M:\\', 'Y:\\', 'Z:\\']
45 41
 
46
-    #
47
-    # scan top directory of each drive for FIRMWARE.CUR
48
-    #   return first drive found
49
-    #
50
-
51
-    import os
52 42
     upload_disk = 'Disk not found'
53 43
     target_file_found = False
54 44
     target_drive_found = False
55
-
56
-    volume_info = subprocess.check_output('powershell -Command volume ')
57
-    volume_info = volume_info.split('\n')
58
-    for entry in volume_info:
59
-      if target_drive in entry and target_drive_found == False:  # set upload if not found target file yet
60
-        target_drive_found = True
61
-        upload_disk = entry[ : entry.find(' ')] + ':'
62
-
63 45
     for drive in drives:
64 46
       final_drive_name = drive.strip().rstrip('\\')   # typical result (string): 'C:'
65
-      # modified version of walklevel()
66
-      level=0
67
-      some_dir = "/"
68
-      some_dir = some_dir.rstrip(os.path.sep)
69
-      assert os.path.isdir(some_dir)
70
-      num_sep = some_dir.count(os.path.sep)
71
-      for root, dirs, files in os.walk(final_drive_name):
72
-        num_sep_this = root.count(os.path.sep)
73
-        if num_sep + level <= num_sep_this:
74
-          del dirs[:]
75
-        if target_filename in files:
47
+      try:
48
+        volume_info = subprocess.check_output('cmd /C dir ' + final_drive_name, stderr=subprocess.STDOUT)
49
+      except Exception as e:
50
+        continue
51
+      else:
52
+        if target_drive in volume_info and target_file_found == False:  # set upload if not found target file yet
53
+          target_drive_found = True
54
+          upload_disk = final_drive_name
55
+        if target_filename in volume_info:
76 56
           if target_file_found == False:
77
-            upload_disk = root
57
+            upload_disk = final_drive_name
78 58
           target_file_found = True
79 59
 
80 60
     #
@@ -88,7 +68,7 @@ if current_OS == 'Windows':
88 68
       )
89 69
       print 'upload disk: ' , upload_disk
90 70
     else:
91
-       print '\nUnable to find destination disk.  File must be copied manually. \n'
71
+      print '\nUnable to find destination disk.  File must be copied manually. \n'
92 72
 
93 73
 
94 74
 if current_OS == 'Linux':
@@ -97,7 +77,6 @@ if current_OS == 'Linux':
97 77
     # platformio.ini will accept this for a Linux upload port designation: 'upload_port = /media/media_name/drive'
98 78
     #
99 79
 
100
-    import os
101 80
     upload_disk = 'Disk not found'
102 81
     target_file_found = False
103 82
     target_drive_found = False

+ 34
- 0
buildroot/share/atom/auto_build.py View File

@@ -23,6 +23,8 @@
23 23
 
24 24
 #######################################
25 25
 #
26
+# Revision: 2.0.1
27
+#
26 28
 # Description: script to automate PlatformIO builds
27 29
 # CLI:  python auto_build.py build_option
28 30
 #    build_option (required)
@@ -103,6 +105,7 @@ current_OS = platform.system()
103 105
 target_env = ''
104 106
 board_name = ''
105 107
 
108
+
106 109
 #########
107 110
 #  Python 2 error messages:
108 111
 #    Can't find a usable init.tcl in the following directories ...
@@ -208,6 +211,13 @@ def resolve_path(path):
208 211
         import os
209 212
 
210 213
     # turn the selection into a partial path
214
+
215
+        if 0 <= path.find('"'):
216
+          path = path[ path.find('"') : ]
217
+          if 0 <= path.find(', line '):
218
+            path = path.replace(', line ', ':')
219
+          path = path.replace('"', '')
220
+
211 221
        #get line and column numbers
212 222
         line_num = 1
213 223
         column_num = 1
@@ -969,6 +979,7 @@ class output_window(Text):
969 979
         Text.__init__(self, self.frame, borderwidth=3, relief="sunken")
970 980
         self.config(tabs=(400,))  # configure Text widget tab stops
971 981
         self.config(background = 'black', foreground = 'white', font= ("consolas", 12), wrap = 'word', undo = 'True')
982
+#        self.config(background = 'black', foreground = 'white', font= ("consolas", 12), wrap = 'none', undo = 'True')
972 983
         self.config(height  = 24, width = 100)
973 984
         self.config(insertbackground = 'pale green')  # keyboard insertion point
974 985
         self.pack(side='left', fill='both', expand=True)
@@ -991,6 +1002,25 @@ class output_window(Text):
991 1002
         self.config(yscrollcommand=scrb.set)
992 1003
         scrb.pack(side='right', fill='y')
993 1004
 
1005
+#        self.scrb_Y = tk.Scrollbar(self.frame, orient='vertical', command=self.yview)
1006
+#        self.scrb_Y.config(yscrollcommand=self.scrb_Y.set)
1007
+#        self.scrb_Y.pack(side='right', fill='y')
1008
+#
1009
+#        self.scrb_X = tk.Scrollbar(self.frame, orient='horizontal', command=self.xview)
1010
+#        self.scrb_X.config(xscrollcommand=self.scrb_X.set)
1011
+#        self.scrb_X.pack(side='bottom', fill='x')
1012
+
1013
+#        scrb_X = tk.Scrollbar(self, orient=tk.HORIZONTAL, command=self.xview)  # tk.HORIZONTAL now have a horizsontal scroll bar BUT... shrinks it to a postage stamp and hides far right behind the vertical scroll bar
1014
+#        self.config(xscrollcommand=scrb_X.set)
1015
+#        scrb_X.pack(side='bottom', fill='x')
1016
+#
1017
+#        scrb= tk.Scrollbar(self, orient='vertical', command=self.yview)
1018
+#        self.config(yscrollcommand=scrb.set)
1019
+#        scrb.pack(side='right', fill='y')
1020
+
1021
+#        self.config(height  = 240, width = 1000)            # didn't get the size baCK TO NORMAL
1022
+#        self.pack(side='left', fill='both', expand=True)    # didn't get the size baCK TO NORMAL
1023
+
994 1024
 
995 1025
         # pop-up menu
996 1026
         self.popup = tk.Menu(self, tearoff=0)
@@ -1230,6 +1260,10 @@ def main():
1230 1260
 
1231 1261
         target_env = get_env(board_name, Marlin_ver)
1232 1262
 
1263
+        os.environ["BUILD_TYPE"] = build_type   # let sub processes know what is happening
1264
+        os.environ["TARGET_ENV"] = target_env
1265
+        os.environ["BOARD_NAME"] = board_name
1266
+
1233 1267
         auto_build = output_window()
1234 1268
         if 0 <= target_env.find('USB1286'):
1235 1269
             copy_boards_dir()          # copy custom boards over to PlatformIO if using custom board

+ 15478
- 0
buildroot/share/atom/avrdude.conf
File diff suppressed because it is too large
View File


BIN
buildroot/share/atom/avrdude_5.10_linux View File


BIN
buildroot/share/atom/avrdude_5.10_macOS View File


+ 15478
- 0
buildroot/share/atom/avrdude_linux.conf
File diff suppressed because it is too large
View File


+ 15272
- 0
buildroot/share/atom/avrdude_macOS.conf
File diff suppressed because it is too large
View File


+ 96
- 70
buildroot/share/atom/create_custom_upload_command_CDC.py View File

@@ -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
+  )

+ 18
- 13
buildroot/share/atom/create_custom_upload_command_DFU.py View File

@@ -9,29 +9,34 @@
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 os
12 13
 import sys
13 14
 from SCons.Script import DefaultEnvironment
14
-
15 15
 import platform
16 16
 current_OS = platform.system()
17 17
 
18 18
 env = DefaultEnvironment()
19 19
 
20
-if current_OS == 'Windows':
21
-    avrdude_conf_path =  env.get("PIOHOME_DIR") + '\\packages\\toolchain-atmelavr\\etc\\avrdude.conf'
20
+build_type = os.environ.get("BUILD_TYPE", 'Not Set')
21
+if not(build_type == 'upload' or build_type == 'traceback' or build_type == 'Not Set') :
22
+  env.Replace(UPLOAD_PROTOCOL = 'teensy-gui')  # run normal Teensy2 scripts
23
+else:
24
+
25
+  if current_OS == 'Windows':
26
+      avrdude_conf_path =  env.get("PIOHOME_DIR") + '\\packages\\toolchain-atmelavr\\etc\\avrdude.conf'
22 27
 
23
-    source_path = env.get("PROJECTBUILD_DIR") + '\\' + env.get("PIOENV") + '\\firmware.hex'
28
+      source_path = env.get("PROJECTBUILD_DIR") + '\\' + env.get("PIOENV") + '\\firmware.hex'
24 29
 
25
-    upload_string = 'avrdude -p usb1286 -c flip1 -C ' + avrdude_conf_path + ' -U flash:w:' + source_path + ':i'
30
+      upload_string = 'avrdude -p usb1286 -c flip1 -C ' + avrdude_conf_path + ' -U flash:w:' + source_path + ':i'
26 31
 
27
-else:
28
-    source_path = env.get("PROJECTBUILD_DIR") + '/' + env.get("PIOENV") + '/firmware.hex'
32
+  else:
33
+      source_path = env.get("PROJECTBUILD_DIR") + '/' + env.get("PIOENV") + '/firmware.hex'
29 34
 
30
-    upload_string = 'avrdude -p usb1286 -c flip1 -U flash:w:' + source_path + ':i'
35
+      upload_string = 'avrdude -p usb1286 -c flip1 -U flash:w:' + source_path + ':i'
31 36
 
32 37
 
33
-env.Replace(
34
-     UPLOADCMD = upload_string,
35
-     MAXIMUM_RAM_SIZE = 8192,
36
-     MAXIMUM_SIZE = 130048
37
-)
38
+  env.Replace(
39
+       UPLOADCMD = upload_string,
40
+       MAXIMUM_RAM_SIZE = 8192,
41
+       MAXIMUM_SIZE = 130048
42
+  )

Loading…
Cancel
Save