1 |
ron |
1 |
#
|
|
|
2 |
# Builds custom upload command
|
|
|
3 |
# 1) Run platformio as a subprocess to find a COM port
|
|
|
4 |
# 2) Build the upload command
|
|
|
5 |
# 3) Exit and let upload tool do the work
|
|
|
6 |
#
|
|
|
7 |
# This script runs between completion of the library/dependencies installation and compilation.
|
|
|
8 |
#
|
|
|
9 |
# Will continue on if a COM port isn't found so that the compilation can be done.
|
|
|
10 |
#
|
|
|
11 |
|
|
|
12 |
import os
|
|
|
13 |
import sys
|
|
|
14 |
from SCons.Script import DefaultEnvironment
|
|
|
15 |
import platform
|
|
|
16 |
current_OS = platform.system()
|
|
|
17 |
|
|
|
18 |
env = DefaultEnvironment()
|
|
|
19 |
|
|
|
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'
|
|
|
27 |
|
|
|
28 |
source_path = env.get("PROJECTBUILD_DIR") + '\\' + env.get("PIOENV") + '\\firmware.hex'
|
|
|
29 |
|
|
|
30 |
upload_string = 'avrdude -p usb1286 -c flip1 -C ' + avrdude_conf_path + ' -U flash:w:' + source_path + ':i'
|
|
|
31 |
|
|
|
32 |
else:
|
|
|
33 |
source_path = env.get("PROJECTBUILD_DIR") + '/' + env.get("PIOENV") + '/firmware.hex'
|
|
|
34 |
|
|
|
35 |
upload_string = 'avrdude -p usb1286 -c flip1 -U flash:w:' + source_path + ':i'
|
|
|
36 |
|
|
|
37 |
|
|
|
38 |
env.Replace(
|
|
|
39 |
UPLOADCMD = upload_string,
|
|
|
40 |
MAXIMUM_RAM_SIZE = 8192,
|
|
|
41 |
MAXIMUM_SIZE = 130048
|
|
|
42 |
)
|