@ -9,30 +9,33 @@
# Will continue on if a COM port isn't found so that the compilation can be done.
#
import sys
import subprocess
import os
import sys
from SCons . Script import DefaultEnvironment
import platform
current_OS = platform . system ( )
from SCons . Script import DefaultEnvironment
env = DefaultEnvironment ( )
com_first = ' '
com_last = ' '
com_CDC = ' '
description_first = ' '
description_last = ' '
description_CDC = ' '
build_type = os . environ . get ( " BUILD_TYPE " , ' Not Set ' )
#
# 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 ) :
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 = ' '
#
# 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
global com_last
@ -69,47 +72,70 @@ def get_com_port(com_search_text, descr_search_text, start):
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 ' :
if current_OS == ' Windows ' :
get_com_port ( ' COM ' , ' Hardware ID: ' , 13 )
avrdude_conf_path = env . get ( " PIOHOME_DIR " ) + ' \\ packages \\ toolchain-atmelavr \\ etc \\ avrdude.conf '
# avrdude_conf_path = env.get("PIOHOME_DIR") + '\\packages\\toolchain-atmelavr\\etc\\avrdude.conf'
avrdude_conf_path = ' buildroot \\ share \\ atom \\ avrdude.conf '
source_path = env . get ( " PROJECTBUILD_DIR " ) + ' \\ ' + env . get ( " PIOENV " ) + ' \\ firmware.hex '
avrdude_exe_path = ' buildroot \\ share \\ atom \\ avrdude_5.10.exe '
upload_string = ' avrdude -p usb1286 -c avr109 -P ' + com_CDC + ' -C ' + avrdude_conf_path + ' -U flash:w: ' + source_path + ' :i '
# source_path = env.get("PROJECTBUILD_DIR") + '\\' + env.get("PIOENV") + '\\firmware.hex'
source_path = ' .pioenvs \\ ' + env . get ( " PIOENV " ) + ' \\ firmware.hex '
upload_string = avrdude_exe_path + ' -p usb1286 -c avr109 -P ' + com_CDC + ' -U flash:w: ' + source_path + ' :i '
if current_OS == ' Darwin ' : # MAC
if current_OS == ' Darwin ' : # MAC
get_com_port ( ' usbmodem ' , ' Description: ' , 13 )
avrdude_conf_path = env . get ( " PIOHOME_DIR " ) + ' /packages/toolchain-atmelavr/etc/avrdude.conf '
# avrdude_conf_path = env.get("PIOHOME_DIR") + '/packages/toolchain-atmelavr/etc/avrdude.conf'
avrdude_conf_path = ' buildroot/share/atom/avrdude_macOS.conf '
source_path = env . get ( " PROJECTBUILD_DIR " ) + ' / ' + env . get ( " PIOENV " ) + ' /firmware.hex '
avrdude_exe_path = ' buildroot/share/atom/avrdude_5.10_macOS '
upload_string = ' avrdude -p usb1286 -c avr109 -P ' + com_CDC + ' -U flash:w: ' + source_path + ' :i '
# source_path = env.get("PROJECTBUILD_DIR") + '/' + env.get("PIOENV") + '/firmware.hex'
source_path = ' .pioenvs/ ' + env . get ( " PIOENV " ) + ' /firmware.hex '
if current_OS == ' Linux ' :
# 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
if current_OS == ' Linux ' :
get_com_port ( ' /dev/tty ' , ' Description: ' , 13 )
avrdude_conf_path = env . get ( " PIOHOME_DIR " ) + ' /packages/toolchain-atmelavr/etc/avrdude.conf '
# avrdude_conf_path = env.get("PIOHOME_DIR") + '/packages/toolchain-atmelavr/etc/avrdude.conf'
avrdude_conf_path = ' buildroot/share/atom/avrdude_linux.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 ,
MAXIMUM_RAM_SIZE = 8192 ,
MAXIMUM_SIZE = 130048
)
)