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

2.0.x
Bob Kuhn 7 years ago committed by Scott Lahteine
parent 645df23eb0
commit 235facd545

@ -6,10 +6,10 @@
target_filename = "FIRMWARE.CUR" target_filename = "FIRMWARE.CUR"
target_drive = "REARM" target_drive = "REARM"
upload_disk = ""
import os import os
import subprocess import platform
current_OS = platform.system()
#env_vars = subprocess.check_output('platformio run -t envdump') #env_vars = subprocess.check_output('platformio run -t envdump')
#env_vars = env_vars.split('\n') #env_vars = env_vars.split('\n')
@ -21,10 +21,6 @@ build_type = os.environ.get("BUILD_TYPE", 'Not Set')
if not(build_type == 'upload' or build_type == 'traceback' or build_type == 'Not Set') : if not(build_type == 'upload' or build_type == 'traceback' or build_type == 'Not Set') :
exit(0) exit(0)
print '\nSearching for upload disk'
import platform
current_OS = platform.system()
if current_OS == 'Windows': if current_OS == 'Windows':
@ -43,38 +39,22 @@ if current_OS == 'Windows':
driveStr = driveStr.strip().lstrip('Drives: ') # typical result (string): 'C:\ D:\ E:\ F:\ G:\ H:\ I:\ J:\ K:\ L:\ M:\ Y:\ Z:\' driveStr = driveStr.strip().lstrip('Drives: ') # typical result (string): 'C:\ D:\ E:\ F:\ G:\ H:\ I:\ J:\ K:\ L:\ M:\ Y:\ Z:\'
drives = driveStr.split() # typical result (array of stings): ['C:\\', 'D:\\', 'E:\\', 'F:\\', 'G:\\', 'H:\\', 'I:\\', 'J:\\', 'K:\\', 'L:\\', 'M:\\', 'Y:\\', 'Z:\\'] drives = driveStr.split() # typical result (array of stings): ['C:\\', 'D:\\', 'E:\\', 'F:\\', 'G:\\', 'H:\\', 'I:\\', 'J:\\', 'K:\\', 'L:\\', 'M:\\', 'Y:\\', 'Z:\\']
#
# scan top directory of each drive for FIRMWARE.CUR
# return first drive found
#
import os
upload_disk = 'Disk not found' upload_disk = 'Disk not found'
target_file_found = False target_file_found = False
target_drive_found = False target_drive_found = False
volume_info = subprocess.check_output('powershell -Command volume ')
volume_info = volume_info.split('\n')
for entry in volume_info:
if target_drive in entry and target_drive_found == False: # set upload if not found target file yet
target_drive_found = True
upload_disk = entry[ : entry.find(' ')] + ':'
for drive in drives: for drive in drives:
final_drive_name = drive.strip().rstrip('\\') # typical result (string): 'C:' final_drive_name = drive.strip().rstrip('\\') # typical result (string): 'C:'
# modified version of walklevel() try:
level=0 volume_info = subprocess.check_output('cmd /C dir ' + final_drive_name, stderr=subprocess.STDOUT)
some_dir = "/" except Exception as e:
some_dir = some_dir.rstrip(os.path.sep) continue
assert os.path.isdir(some_dir) else:
num_sep = some_dir.count(os.path.sep) if target_drive in volume_info and target_file_found == False: # set upload if not found target file yet
for root, dirs, files in os.walk(final_drive_name): target_drive_found = True
num_sep_this = root.count(os.path.sep) upload_disk = final_drive_name
if num_sep + level <= num_sep_this: if target_filename in volume_info:
del dirs[:]
if target_filename in files:
if target_file_found == False: if target_file_found == False:
upload_disk = root upload_disk = final_drive_name
target_file_found = True target_file_found = True
# #
@ -88,7 +68,7 @@ if current_OS == 'Windows':
) )
print 'upload disk: ' , upload_disk print 'upload disk: ' , upload_disk
else: else:
print '\nUnable to find destination disk. File must be copied manually. \n' print '\nUnable to find destination disk. File must be copied manually. \n'
if current_OS == 'Linux': if current_OS == 'Linux':
@ -97,7 +77,6 @@ if current_OS == 'Linux':
# platformio.ini will accept this for a Linux upload port designation: 'upload_port = /media/media_name/drive' # platformio.ini will accept this for a Linux upload port designation: 'upload_port = /media/media_name/drive'
# #
import os
upload_disk = 'Disk not found' upload_disk = 'Disk not found'
target_file_found = False target_file_found = False
target_drive_found = False target_drive_found = False

@ -23,6 +23,8 @@
####################################### #######################################
# #
# Revision: 2.0.1
#
# Description: script to automate PlatformIO builds # Description: script to automate PlatformIO builds
# CLI: python auto_build.py build_option # CLI: python auto_build.py build_option
# build_option (required) # build_option (required)
@ -103,6 +105,7 @@ current_OS = platform.system()
target_env = '' target_env = ''
board_name = '' board_name = ''
######### #########
# Python 2 error messages: # Python 2 error messages:
# Can't find a usable init.tcl in the following directories ... # Can't find a usable init.tcl in the following directories ...
@ -208,6 +211,13 @@ def resolve_path(path):
import os import os
# turn the selection into a partial path # turn the selection into a partial path
if 0 <= path.find('"'):
path = path[ path.find('"') : ]
if 0 <= path.find(', line '):
path = path.replace(', line ', ':')
path = path.replace('"', '')
#get line and column numbers #get line and column numbers
line_num = 1 line_num = 1
column_num = 1 column_num = 1
@ -969,6 +979,7 @@ class output_window(Text):
Text.__init__(self, self.frame, borderwidth=3, relief="sunken") Text.__init__(self, self.frame, borderwidth=3, relief="sunken")
self.config(tabs=(400,)) # configure Text widget tab stops self.config(tabs=(400,)) # configure Text widget tab stops
self.config(background = 'black', foreground = 'white', font= ("consolas", 12), wrap = 'word', undo = 'True') self.config(background = 'black', foreground = 'white', font= ("consolas", 12), wrap = 'word', undo = 'True')
# self.config(background = 'black', foreground = 'white', font= ("consolas", 12), wrap = 'none', undo = 'True')
self.config(height = 24, width = 100) self.config(height = 24, width = 100)
self.config(insertbackground = 'pale green') # keyboard insertion point self.config(insertbackground = 'pale green') # keyboard insertion point
self.pack(side='left', fill='both', expand=True) self.pack(side='left', fill='both', expand=True)
@ -991,6 +1002,25 @@ class output_window(Text):
self.config(yscrollcommand=scrb.set) self.config(yscrollcommand=scrb.set)
scrb.pack(side='right', fill='y') scrb.pack(side='right', fill='y')
# self.scrb_Y = tk.Scrollbar(self.frame, orient='vertical', command=self.yview)
# self.scrb_Y.config(yscrollcommand=self.scrb_Y.set)
# self.scrb_Y.pack(side='right', fill='y')
#
# self.scrb_X = tk.Scrollbar(self.frame, orient='horizontal', command=self.xview)
# self.scrb_X.config(xscrollcommand=self.scrb_X.set)
# self.scrb_X.pack(side='bottom', fill='x')
# 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
# self.config(xscrollcommand=scrb_X.set)
# scrb_X.pack(side='bottom', fill='x')
#
# scrb= tk.Scrollbar(self, orient='vertical', command=self.yview)
# self.config(yscrollcommand=scrb.set)
# scrb.pack(side='right', fill='y')
# self.config(height = 240, width = 1000) # didn't get the size baCK TO NORMAL
# self.pack(side='left', fill='both', expand=True) # didn't get the size baCK TO NORMAL
# pop-up menu # pop-up menu
self.popup = tk.Menu(self, tearoff=0) self.popup = tk.Menu(self, tearoff=0)
@ -1230,6 +1260,10 @@ def main():
target_env = get_env(board_name, Marlin_ver) target_env = get_env(board_name, Marlin_ver)
os.environ["BUILD_TYPE"] = build_type # let sub processes know what is happening
os.environ["TARGET_ENV"] = target_env
os.environ["BOARD_NAME"] = board_name
auto_build = output_window() auto_build = output_window()
if 0 <= target_env.find('USB1286'): if 0 <= target_env.find('USB1286'):
copy_boards_dir() # copy custom boards over to PlatformIO if using custom board copy_boards_dir() # copy custom boards over to PlatformIO if using custom board

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -9,107 +9,133 @@
# Will continue on if a COM port isn't found so that the compilation can be done. # Will continue on if a COM port isn't found so that the compilation can be done.
# #
import subprocess
import os
import sys import sys
from SCons.Script import DefaultEnvironment
import platform
current_OS = platform.system()
import subprocess env = DefaultEnvironment()
build_type = os.environ.get("BUILD_TYPE", 'Not Set')
import platform
current_OS = platform.system()
from SCons.Script import DefaultEnvironment if not(build_type == 'upload' or build_type == 'traceback' or build_type == 'Not Set') :
env.Replace(UPLOAD_PROTOCOL = 'teensy-gui') # run normal Teensy2 scripts
else:
com_first = ''
com_last = ''
com_CDC = ''
description_first = ''
description_last = ''
description_CDC = ''
env = DefaultEnvironment() #
# grab the first com port that pops up unless we find one we know for sure
# is a CDC device
#
def get_com_port(com_search_text, descr_search_text, start):
com_first = '' global com_first
com_last = '' global com_last
com_CDC = '' global com_CDC
description_first = '' global description_first
description_last = '' global description_last
description_CDC = '' global description_CDC
#
# grab the first com port that pops up unless we find one we know for sure
# is a CDC device
#
def get_com_port(com_search_text, descr_search_text, start):
global com_first print '\nLooking for Serial Port\n'
global com_last
global com_CDC # stream output from subprocess and split it into lines
global description_first pio_subprocess = subprocess.Popen(['platformio', 'device', 'list'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
global description_last
global description_CDC looking_for_description = False
for line in iter(pio_subprocess.stdout.readline, ''):
if 0 <= line.find(com_search_text):
looking_for_description = True
com_last = line.replace('\n', '')
if com_first == '':
com_first = com_last
if 0 <= line.find(descr_search_text) and looking_for_description:
looking_for_description = False
description_last = line[ start : ]
if description_first == '':
description_first = description_last
if 0 <= description_last.find('CDC'):
com_CDC = com_last
description_CDC = description_last
if com_CDC == '' and not(com_first == ''):
com_CDC = com_first
description_CDC = description_first
elif com_CDC == '':
com_CDC = 'COM_PORT_NOT_FOUND'
while 0 <= com_CDC.find('\n'):
com_CDC = com_CDC.replace('\n', '')
while 0 <= com_CDC.find('\r'):
com_CDC = com_CDC.replace('\r', '')
if com_CDC == 'COM_PORT_NOT_FOUND':
print com_CDC, '\n'
else:
print 'FOUND: ' ,com_CDC
print 'DESCRIPTION: ', description_CDC , '\n'
if current_OS == 'Windows':
print '\nLooking for Serial Port\n' get_com_port('COM', 'Hardware ID:', 13)
# stream output from subprocess and split it into lines # avrdude_conf_path = env.get("PIOHOME_DIR") + '\\packages\\toolchain-atmelavr\\etc\\avrdude.conf'
pio_subprocess = subprocess.Popen(['platformio', 'device', 'list'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) avrdude_conf_path = 'buildroot\\share\\atom\\avrdude.conf'
looking_for_description = False avrdude_exe_path = 'buildroot\\share\\atom\\avrdude_5.10.exe'
for line in iter(pio_subprocess.stdout.readline, ''):
if 0 <= line.find(com_search_text):
looking_for_description = True
com_last = line.replace('\n', '')
if com_first == '':
com_first = com_last
if 0 <= line.find(descr_search_text) and looking_for_description:
looking_for_description = False
description_last = line[ start : ]
if description_first == '':
description_first = description_last
if 0 <= description_last.find('CDC'):
com_CDC = com_last
description_CDC = description_last
if com_CDC == '' and not(com_first == ''): # source_path = env.get("PROJECTBUILD_DIR") + '\\' + env.get("PIOENV") + '\\firmware.hex'
com_CDC = com_first source_path = '.pioenvs\\' + env.get("PIOENV") + '\\firmware.hex'
description_CDC = description_first
elif com_CDC == '':
com_CDC = 'COM_PORT_NOT_FOUND'
if com_CDC == 'COM_PORT_NOT_FOUND': upload_string = avrdude_exe_path + ' -p usb1286 -c avr109 -P ' + com_CDC + ' -U flash:w:' + source_path + ':i'
print com_CDC, '\n'
else:
print 'FOUND: ' ,com_CDC
print 'DESCRIPTION: ', description_CDC , '\n'
if current_OS == 'Windows':
get_com_port('COM', 'Hardware ID:', 13) if current_OS == 'Darwin': # MAC
avrdude_conf_path = env.get("PIOHOME_DIR") + '\\packages\\toolchain-atmelavr\\etc\\avrdude.conf' get_com_port('usbmodem', 'Description:', 13)
source_path = env.get("PROJECTBUILD_DIR") + '\\' + env.get("PIOENV") + '\\firmware.hex' # avrdude_conf_path = env.get("PIOHOME_DIR") + '/packages/toolchain-atmelavr/etc/avrdude.conf'
avrdude_conf_path = 'buildroot/share/atom/avrdude_macOS.conf'
upload_string = 'avrdude -p usb1286 -c avr109 -P ' + com_CDC + ' -C ' + avrdude_conf_path + ' -U flash:w:' + source_path + ':i'
avrdude_exe_path = 'buildroot/share/atom/avrdude_5.10_macOS'
if current_OS == 'Darwin': # MAC # source_path = env.get("PROJECTBUILD_DIR") + '/' + env.get("PIOENV") + '/firmware.hex'
source_path = '.pioenvs/' + env.get("PIOENV") + '/firmware.hex'
get_com_port('usbmodem', 'Description:', 13)
avrdude_conf_path = env.get("PIOHOME_DIR") + '/packages/toolchain-atmelavr/etc/avrdude.conf' # upload_string = 'avrdude -p usb1286 -c avr109 -P ' + com_CDC + ' -U flash:w:' + source_path + ':i'
upload_string = avrdude_exe_path + ' -p usb1286 -c avr109 -P ' + com_CDC + ' -C ' + avrdude_conf_path + ' -U flash:w:' + source_path + ':i'
print 'upload_string: ', upload_string
source_path = env.get("PROJECTBUILD_DIR") + '/' + env.get("PIOENV") + '/firmware.hex'
upload_string = 'avrdude -p usb1286 -c avr109 -P ' + com_CDC + ' -U flash:w:' + source_path + ':i'
if current_OS == 'Linux':
if current_OS == 'Linux': get_com_port('/dev/tty', 'Description:', 13)
get_com_port('/dev/tty', 'Description:', 13) # avrdude_conf_path = env.get("PIOHOME_DIR") + '/packages/toolchain-atmelavr/etc/avrdude.conf'
avrdude_conf_path = 'buildroot/share/atom/avrdude_linux.conf'
avrdude_conf_path = env.get("PIOHOME_DIR") + '/packages/toolchain-atmelavr/etc/avrdude.conf'
source_path = env.get("PROJECTBUILD_DIR") + '/' + env.get("PIOENV") + '/firmware.hex' avrdude_exe_path = 'buildroot/share/atom/avrdude_5.10_linux'
# source_path = env.get("PROJECTBUILD_DIR") + '/' + env.get("PIOENV") + '/firmware.hex'
source_path = '.pioenvs/' + env.get("PIOENV") + '/firmware.hex'
upload_string = 'avrdude -p usb1286 -c avr109 -P ' + com_CDC + ' -U flash:w:' + source_path + ':i' # upload_string = 'avrdude -p usb1286 -c avr109 -P ' + com_CDC + ' -U flash:w:' + source_path + ':i'
upload_string = avrdude_exe_path + ' -p usb1286 -c avr109 -P ' + com_CDC + ' -C ' + avrdude_conf_path + ' -U flash:w:' + source_path + ':i'
env.Replace( env.Replace(
UPLOADCMD = upload_string, UPLOADCMD = upload_string,
MAXIMUM_RAM_SIZE = 8192, MAXIMUM_RAM_SIZE = 8192,
MAXIMUM_SIZE = 130048 MAXIMUM_SIZE = 130048
) )

@ -9,29 +9,34 @@
# Will continue on if a COM port isn't found so that the compilation can be done. # Will continue on if a COM port isn't found so that the compilation can be done.
# #
import os
import sys import sys
from SCons.Script import DefaultEnvironment from SCons.Script import DefaultEnvironment
import platform import platform
current_OS = platform.system() current_OS = platform.system()
env = DefaultEnvironment() env = DefaultEnvironment()
if current_OS == 'Windows': build_type = os.environ.get("BUILD_TYPE", 'Not Set')
avrdude_conf_path = env.get("PIOHOME_DIR") + '\\packages\\toolchain-atmelavr\\etc\\avrdude.conf' if not(build_type == 'upload' or build_type == 'traceback' or build_type == 'Not Set') :
env.Replace(UPLOAD_PROTOCOL = 'teensy-gui') # run normal Teensy2 scripts
else:
if current_OS == 'Windows':
avrdude_conf_path = env.get("PIOHOME_DIR") + '\\packages\\toolchain-atmelavr\\etc\\avrdude.conf'
source_path = env.get("PROJECTBUILD_DIR") + '\\' + env.get("PIOENV") + '\\firmware.hex' source_path = env.get("PROJECTBUILD_DIR") + '\\' + env.get("PIOENV") + '\\firmware.hex'
upload_string = 'avrdude -p usb1286 -c flip1 -C ' + avrdude_conf_path + ' -U flash:w:' + source_path + ':i' upload_string = 'avrdude -p usb1286 -c flip1 -C ' + avrdude_conf_path + ' -U flash:w:' + source_path + ':i'
else: else:
source_path = env.get("PROJECTBUILD_DIR") + '/' + env.get("PIOENV") + '/firmware.hex' source_path = env.get("PROJECTBUILD_DIR") + '/' + env.get("PIOENV") + '/firmware.hex'
upload_string = 'avrdude -p usb1286 -c flip1 -U flash:w:' + source_path + ':i' upload_string = 'avrdude -p usb1286 -c flip1 -U flash:w:' + source_path + ':i'
env.Replace( env.Replace(
UPLOADCMD = upload_string, UPLOADCMD = upload_string,
MAXIMUM_RAM_SIZE = 8192, MAXIMUM_RAM_SIZE = 8192,
MAXIMUM_SIZE = 130048 MAXIMUM_SIZE = 130048
) )

Loading…
Cancel
Save