aboutsummaryrefslogtreecommitdiff
path: root/buildroot/share/vscode/create_custom_upload_command_DFU.py
diff options
context:
space:
mode:
authorGeorgiy Bondarenko <69736697+nehilo@users.noreply.github.com>2021-03-04 20:54:23 +0300
committerGeorgiy Bondarenko <69736697+nehilo@users.noreply.github.com>2021-03-04 20:54:23 +0300
commite8701195e66f2d27ffe17fb514eae8173795aaf7 (patch)
tree9f519c4abf6556b9ae7190a6210d87ead1dfadde /buildroot/share/vscode/create_custom_upload_command_DFU.py
downloadkp3s-lgvl-e8701195e66f2d27ffe17fb514eae8173795aaf7.tar.xz
kp3s-lgvl-e8701195e66f2d27ffe17fb514eae8173795aaf7.zip
Initial commit
Diffstat (limited to 'buildroot/share/vscode/create_custom_upload_command_DFU.py')
-rw-r--r--buildroot/share/vscode/create_custom_upload_command_DFU.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/buildroot/share/vscode/create_custom_upload_command_DFU.py b/buildroot/share/vscode/create_custom_upload_command_DFU.py
new file mode 100644
index 0000000..9082699
--- /dev/null
+++ b/buildroot/share/vscode/create_custom_upload_command_DFU.py
@@ -0,0 +1,42 @@
+#
+# 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.
+#
+
+import os
+import sys
+from SCons.Script import DefaultEnvironment
+import platform
+current_OS = platform.system()
+
+env = DefaultEnvironment()
+
+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'
+
+ 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'
+
+ else:
+ source_path = env.get("PROJECTBUILD_DIR") + '/' + env.get("PIOENV") + '/firmware.hex'
+
+ upload_string = 'avrdude -p usb1286 -c flip1 -U flash:w:' + source_path + ':i'
+
+
+ env.Replace(
+ UPLOADCMD = upload_string,
+ MAXIMUM_RAM_SIZE = 8192,
+ MAXIMUM_SIZE = 130048
+ )