Skip to content

Commit fce7c0e

Browse files
committed
Add pysiwiflasher support for non windows platform
Signed-off-by: Ajay Bhargav <[email protected]>
1 parent 84c1854 commit fce7c0e

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

builder/main.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,27 @@
3232
SIZECHECKCMD="$SIZETOOL -A -d $SOURCES",
3333
SIZEPRINTCMD='$SIZETOOL -B -d $SOURCES',
3434

35-
PROGSUFFIX=".elf",
36-
SIWIFLASHER=join(platform.get_package_dir(
37-
"tool-siwiflasher") or "", "siwiflasher"),
38-
REFLASH_FLAGS=[
39-
"-r",
40-
"-b", "$UPLOAD_SPEED",
41-
"-p", '"$UPLOAD_PORT"',
42-
],
43-
REFLASH_CMD='"$SIWIFLASHER" $REFLASH_FLAGS'
35+
PROGSUFFIX=".elf"
4436
)
4537

38+
# Setup tools based on system type
39+
if "windows" in util.get_systype():
40+
env.Replace(
41+
SIWIFLASHER=join(platform.get_package_dir("tool-siwiflasher") or "", "siwiflasher"),
42+
REFLASH_FLAGS=[
43+
"-r",
44+
"-b", "$UPLOAD_SPEED",
45+
"-p", '"$UPLOAD_PORT"',
46+
],
47+
REFLASH_CMD='"$SIWIFLASHER" $REFLASH_FLAGS'
48+
)
49+
else:
50+
env.Replace(
51+
SIWIFLASHER='"$PYTHONEXE"' + join(platform.get_package_dir(
52+
"tool-pysiwiflasher") or "", "siwiflasher.py"),
53+
REFLASH_CMD="echo Sorry! Reflashing is only supported on windows!"
54+
)
55+
4656
# Allow user to override via pre:script
4757
if env.get("PROGNAME", "program") == "program":
4858
env.Replace(PROGNAME="firmware")
@@ -102,7 +112,7 @@
102112
upload_source = target_firm
103113
upload_actions = [env.VerboseAction("$UPLOADCMD", "Uploading $SOURCE")]
104114

105-
if env.subst("$UPLOAD_PORT") == "":
115+
if "windows" not in util.get_systype() and env.subst("$UPLOAD_PORT") == "":
106116
env.Append(
107117
UPLOADERFLAGS=[
108118
"-u"

platform.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@
4444
"type": "uploader",
4545
"optional": true,
4646
"version": "~1.3.0"
47+
},
48+
"tool-pysiwiflasher": {
49+
"type": "uploader",
50+
"optional": true,
51+
"version": "~0.2.0"
4752
}
4853
},
4954
"pythonPackages": {

0 commit comments

Comments
 (0)