Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
76e52b5d
Commit
76e52b5d
authored
Jul 05, 2015
by
Daniel Campora
Browse files
cc3200: Make update-wipy.py more robust.
parent
fa655ce1
Changes
1
Hide whitespace changes
Inline
Side-by-side
cc3200/tools/update-wipy.py
View file @
76e52b5d
...
...
@@ -25,26 +25,43 @@ def print_exception(e):
print
(
'Exception: {}, on line {}'
.
format
(
e
,
sys
.
exc_info
()[
-
1
].
tb_lineno
))
def
ftp_directory_exists
(
ftpobj
,
directory_name
):
filelist
=
[]
ftpobj
.
retrlines
(
'LIST'
,
filelist
.
append
)
for
f
in
filelist
:
if
f
.
split
()[
-
1
]
==
directory_name
:
return
True
return
False
def
transfer_file
(
args
):
with
FTP
(
args
.
ip
,
timeout
=
1
0
)
as
ftp
:
with
FTP
(
args
.
ip
,
timeout
=
2
0
)
as
ftp
:
print
(
'FTP connection established'
)
if
'230'
in
ftp
.
login
(
args
.
user
,
args
.
password
):
print
(
'Login successful'
)
if
'250'
in
ftp
.
cwd
(
'/flash/sys'
):
print
(
"Entered '/flash/sys' directory"
)
with
open
(
args
.
file
,
"rb"
)
as
fwfile
:
print
(
'Firmware image found, initiating transfer...'
)
if
'226'
in
ftp
.
storbinary
(
"STOR "
+
'mcuimg.bin'
,
fwfile
,
512
):
print
(
'File transfer complete'
)
return
True
if
'250'
in
ftp
.
cwd
(
'/flash'
):
if
not
ftp_directory_exists
(
ftp
,
'sys'
):
print
(
'/flash/sys directory does not exist'
)
if
not
'550'
in
ftp
.
mkd
(
'sys'
):
print
(
'/flash/sys directory created'
)
else
:
print
(
'Error: file transfer failed'
)
print
(
'Error: cannot create /flash/sys directory'
)
return
False
if
'250'
in
ftp
.
cwd
(
'sys'
):
print
(
"Entered '/flash/sys' directory"
)
with
open
(
args
.
file
,
"rb"
)
as
fwfile
:
print
(
'Firmware image found, initiating transfer...'
)
if
'226'
in
ftp
.
storbinary
(
"STOR "
+
'mcuimg.bin'
,
fwfile
,
512
):
print
(
'File transfer complete'
)
return
True
else
:
print
(
'Error: file transfer failed'
)
else
:
print
(
'Error: cannot enter /flash/sys directory'
)
else
:
print
(
'Error: cannot enter /flash
/sys
directory'
)
print
(
'Error: cannot enter /flash directory'
)
else
:
print
(
'Error: ftp login failed'
)
...
...
@@ -97,12 +114,12 @@ def verify_update(args):
firmware_tag
=
''
def
find_tag
(
tag
):
nonlocal
success
,
firmware_tag
if
tag
in
firmware_tag
:
success
=
True
print
(
"Verification passed"
)
return
True
else
:
print
(
"Error: verification failed, the git tag doesn't match"
)
return
False
try
:
# Specify a longer time out value here because the board has just been
...
...
@@ -114,14 +131,14 @@ def verify_update(args):
tag_file_path
=
args
.
file
.
rstrip
(
'mcuimg.bin'
)
+
'genhdr/mpversion.h'
if
args
.
tag
is
not
None
:
find_tag
(
bytes
(
args
.
tag
,
'ascii'
))
success
=
find_tag
(
bytes
(
args
.
tag
,
'ascii'
))
else
:
with
open
(
tag_file_path
)
as
tag_file
:
for
line
in
tag_file
:
bline
=
bytes
(
line
,
'ascii'
)
if
b
'MICROPY_GIT_HASH'
in
bline
:
bline
=
bline
.
lstrip
(
b
'#define MICROPY_GIT_HASH '
).
replace
(
b
'"'
,
b
''
).
replace
(
b
'
\r
'
,
b
''
).
replace
(
b
'
\n
'
,
b
''
)
find_tag
(
bline
)
success
=
find_tag
(
bline
)
break
except
Exception
as
e
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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