2018-05-20 14:30:36 +02:00
|
|
|
#
|
|
|
|
# Builds custom upload command
|
|
|
|
# 1) Run platformio as a subprocess to find a COM port
|
|
|
|
# 2) Build the upload command
|
|
|
|
# 3) Exit and let upload tool do the work
|
|
|
|
#
|
|
|
|
# This script runs between completion of the library/dependencies installation and compilation.
|
|
|
|
#
|
|
|
|
# Will continue on if a COM port isn't found so that the compilation can be done.
|
|
|
|
#
|
|
|
|
|
2018-05-26 08:07:01 +02:00
|
|
|
import os
|
2018-05-20 14:30:36 +02:00
|
|
|
import sys
|
|
|
|
from SCons.Script import DefaultEnvironment
|
|
|
|
import platform
|
|
|
|
current_OS = platform.system()
|
|
|
|
|
|
|
|
env = DefaultEnvironment()
|
|
|
|
|
2018-05-26 08:07:01 +02:00
|
|
|
build_type = os.environ.get("BUILD_TYPE", 'Not Set')
|
|
|
|
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'
|
2018-05-20 14:30:36 +02:00
|
|
|
|
2018-05-26 08:07:01 +02:00
|
|
|
source_path = env.get("PROJECTBUILD_DIR") + '\\' + env.get("PIOENV") + '\\firmware.hex'
|
2018-05-20 14:30:36 +02:00
|
|
|
|
2018-05-26 08:07:01 +02:00
|
|
|
upload_string = 'avrdude -p usb1286 -c flip1 -C ' + avrdude_conf_path + ' -U flash:w:' + source_path + ':i'
|
2018-05-20 14:30:36 +02:00
|
|
|
|
2018-05-26 08:07:01 +02:00
|
|
|
else:
|
|
|
|
source_path = env.get("PROJECTBUILD_DIR") + '/' + env.get("PIOENV") + '/firmware.hex'
|
2018-05-20 14:30:36 +02:00
|
|
|
|
2018-05-26 08:07:01 +02:00
|
|
|
upload_string = 'avrdude -p usb1286 -c flip1 -U flash:w:' + source_path + ':i'
|
2018-05-20 14:30:36 +02:00
|
|
|
|
|
|
|
|
2018-05-26 08:07:01 +02:00
|
|
|
env.Replace(
|
|
|
|
UPLOADCMD = upload_string,
|
|
|
|
MAXIMUM_RAM_SIZE = 8192,
|
|
|
|
MAXIMUM_SIZE = 130048
|
|
|
|
)
|