forked from UnifiedEngineering/T-962-improvements
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom_upload.py
More file actions
26 lines (23 loc) · 910 Bytes
/
custom_upload.py
File metadata and controls
26 lines (23 loc) · 910 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Import("env")
import os
import platform
from platformio.builder.tools.pioupload import AutodetectUploadPort
config = env.GetProjectConfig()
mcu_clock = config.get("upload_settings", "MCU_CLOCK")
flash_baud = config.get("upload_settings", "FLASH_BAUD")
#print("MCU_CLOCK: %s" % str(mcu_clock))
# Python callback
def on_upload(source, target, env):
AutodetectUploadPort(env)
#print(source, target)
firmware_path = str(source[0])
# replace .bin with .hex. Upload needs .hex not .bin
firmware_path = firmware_path[:-3] + "hex"
print("Firmware path: %s" % firmware_path)
# find out what executable to call
uploader = "./lpc21isp_linux"
if platform.system() == "Windows":
uploader = "lpc21isp_win.exe"
# do something
env.Execute("%s \"%s\" %s %s %s" % (uploader, firmware_path, env.subst("$UPLOAD_PORT"), flash_baud, mcu_clock))
env.Replace(UPLOADCMD=on_upload)