Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
ec8589e4
Commit
ec8589e4
authored
Aug 19, 2015
by
Daniel Campora
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cc3200: Improve uniflash script and make it a bit more verbose.
parent
b864e7af
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
9 deletions
+34
-9
cc3200/tools/uniflash.py
cc3200/tools/uniflash.py
+34
-9
No files found.
cc3200/tools/uniflash.py
View file @
ec8589e4
...
...
@@ -22,6 +22,27 @@ def print_exception(e):
print
(
'Exception: {}, on line {}'
.
format
(
e
,
sys
.
exc_info
()[
-
1
].
tb_lineno
))
def
execute
(
command
):
process
=
subprocess
.
Popen
(
command
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
cmd_log
=
""
# Poll process for new output until finished
while
True
:
nextline
=
process
.
stdout
.
readline
()
if
nextline
==
''
and
process
.
poll
()
!=
None
:
break
sys
.
stdout
.
write
(
nextline
)
sys
.
stdout
.
flush
()
cmd_log
+=
nextline
output
=
process
.
communicate
()[
0
]
exitCode
=
process
.
returncode
if
exitCode
==
0
:
return
cmd_log
else
:
raise
ProcessException
(
command
,
exitCode
,
output
)
def
main
():
cmd_parser
=
argparse
.
ArgumentParser
(
description
=
'Flash the WiPy and optionally run a small test on it.'
)
cmd_parser
.
add_argument
(
'-u'
,
'--uniflash'
,
default
=
None
,
help
=
'the path to the uniflash cli executable'
)
...
...
@@ -30,7 +51,7 @@ def main():
cmd_parser
.
add_argument
(
'-s'
,
'--servicepack'
,
default
=
None
,
help
=
'the path to the servicepack file'
)
args
=
cmd_parser
.
parse_args
()
result
=
1
output
=
""
com_port
=
'com='
+
str
(
args
.
port
)
servicepack_path
=
'spPath='
+
args
.
servicepack
...
...
@@ -38,19 +59,23 @@ def main():
if
args
.
uniflash
==
None
or
args
.
config
==
None
:
raise
ValueError
(
'uniflash path and config path are mandatory'
)
if
args
.
servicepack
==
None
:
subprocess
.
check_call
([
args
.
uniflash
,
'-config'
,
args
.
config
,
'-setOptions'
,
com_port
,
'-operations'
,
'format'
,
'program'
],
stderr
=
subprocess
.
STDOUT
)
output
+=
execute
([
args
.
uniflash
,
'-config'
,
args
.
config
,
'-setOptions'
,
com_port
,
'-operations'
,
'format'
,
'program'
]
)
else
:
subprocess
.
check_call
([
args
.
uniflash
,
'-config'
,
args
.
config
,
'-setOptions'
,
com_port
,
servicepack_path
,
'-operations'
,
'format'
,
'servicePackUpdate'
,
'program'
],
stderr
=
subprocess
.
STDOUT
)
result
=
0
output
+=
execute
([
args
.
uniflash
,
'-config'
,
args
.
config
,
'-setOptions'
,
com_port
,
servicepack_path
,
'-operations'
,
'format'
,
'servicePackUpdate'
,
'program'
])
except
Exception
as
e
:
print_exception
(
e
)
output
=
""
finally
:
if
result
:
print
(
"ERROR: Programming failed!"
)
if
"Finish Executing operation: program"
in
output
:
print
(
"======================================"
)
print
(
"Board programmed OK"
)
print
(
"======================================"
)
sys
.
exit
(
0
)
else
:
print
(
"Board programmed OK"
)
sys
.
exit
(
result
)
print
(
"======================================"
)
print
(
"ERROR: Programming failed!"
)
print
(
"======================================"
)
sys
.
exit
(
1
)
if
__name__
==
"__main__"
:
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment