Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
Conv TTL Blocking
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
5
Issues
5
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Conv TTL Blocking
Commits
1310345b
Commit
1310345b
authored
Apr 10, 2018
by
Denia Bouhired-Ferrag
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Final remote upgrade script
parent
67815dc6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
89 additions
and
79 deletions
+89
-79
remote-mass-gw-upgrade.py
software/gwupdate/remote-mass-gw-upgrade.py
+89
-79
No files found.
software/gwupdate/remote-mass-gw-upgrade.py
View file @
1310345b
...
...
@@ -88,7 +88,8 @@ gwvers_target = 4.1
gwvers_gold_target
=
0.3
#gateware to write
gw_file
=
"golden-v"
+
str
(
gwvers_gold_target
)
+
"_release-v"
+
str
(
gwvers_target
".bin"
#gw_file="golden-v"+str(gwvers_gold_target)+".bin"
gw_file
=
"golden-v"
+
str
(
gwvers_gold_target
)
+
"_release-v"
+
str
(
gwvers_target
)
+
".bin"
##-------------------------------------------------------------------------------------------------
## Method to check hardware and gateware version
...
...
@@ -108,104 +109,113 @@ def gw_hw_version():
##-------------------------------------------------------------------------------------------------
if
__name__
==
"__main__"
:
crate_list
=
"crate_list.txt"
crate_list
=
"crate_list.txt"
fin
=
open
(
'./crate_list.txt'
,
'r'
)
for
crate_line
in
fin
for
crate_line
in
fin
:
#Split each line into list of strings
crate_info
=
crate_line
.
split
()
crate_info
=
crate_line
.
split
()
# Get the IP, user and password for the ELMA crate from ei2cdefine.py
ip
=
crate_info
[
0
]
user
=
crate_info
[
1
]
pwd
=
crate_info
[
2
]
slot
=
int
(
crate_info
[
3
])
elma
=
EI2C
(
ip
,
user
,
pwd
)
elma
.
open
()
try
:
elma
.
open
()
print
(
"---------------------------------"
)
print
(
"Connecting to crate
%
s ...
\n
"
%
ip
)
# Get board ID and gateware version, fail if incorrect
bid
=
elma
.
get_bid
(
slot
)
(
hwvers
,
gwvers
)
=
gw_hw_version
()
upgrade
=
True
#Check whether upgrade is required
if
(
gwvers
==
gwvers_target
):
upgrade
=
False
# Get board ID and gateware version, fail if incorrect
bid
=
elma
.
get_bid
(
slot
)
(
hwvers
,
gwvers
)
=
gw_hw_version
()
baseaddr
=
0x100
if
(
bid
==
"TBLO"
):
gw_path
=
"./gw-blo/"
elif
(
bid
==
"T485"
):
gw_path
=
"./gw-rs485/"
# if (gwvers == 0xff):
# baseaddr = 0x300
# elif ((gwvers >= 0x10) and (gwvers <= 0x22)) or \
# (((gwvers & 0xf0) == 0x00) and (gwvers < 0x02)):
# baseaddr = 0x040
if
upgrade
==
True
:
print
(
"Upgrade file is
%
s
\n
"
%
gw_path
+
gw_file
)
mb
=
XilMultiboot
(
ELMA_I2C_MULTIBOOT
,
elma
,
slot
,
baseaddr
,
""
)
mb
.
set_bitstream_file
(
gw_path
+
gw_file
)
multiboot_addr
=
"0x0"
multiboot_addr
=
int
(
multiboot_addr
,
16
)
mb
.
write
(
multiboot_addr
)
mb
.
iprog
(
multiboot_addr
)
# Turn off the VME crate
#ret = subprocess.call("snmpset -v2c -c "+ pwd +" "+ ip +" 1.3.6.1.4.1.37968.1.1.7.2.1.3.1 i 1", shell=True, stdout=None, stderr=None)
# Turn on the VME crate
#ret = subprocess.call("snmpset -v2c -c "+ pwd +" "+ ip +" 1.3.6.1.4.1.37968.1.1.7.2.1.3.1 i 0", shell=True, stdout=None, stderr=None)
upgrade
=
True
#Check whether upgrade is required
if
(
gwvers
==
gwvers_target
):
upgrade
=
False
break
time
.
sleep
(
10
)
(
hwvers_new
,
gwvers_new
)
=
gw_hw_version
()
if
(
hwvers_new
==
0.0
):
hwvers_new_str
=
"<4.0"
else
:
hwvers_new_str
=
str
(
hwvers_new
)
IDMS
=
elma
.
read
(
slot
,
UIDREGMS
)
IDLS
=
elma
.
read
(
slot
,
UIDREGLS
)
except
BadHostnameError
:
print
(
"... Bad crate name ...
\n
"
)
(
IDMS
,
IDLS
,
hwvers_new_str
,
gwvers
,
gwvers_new
)
=
(
0
,
0
,
"BadHostname"
,
0
,
0
)
except
BadUsernameError
:
print
(
"... Bad user name ...
\n
"
)
(
IDMS
,
IDLS
,
hwvers_new_str
,
gwvers
,
gwvers_new
)
=
(
0
,
0
,
"BadUsername"
,
0
,
0
)
except
BadPasswordError
:
print
(
"... Bad password ...
\n
"
)
(
IDMS
,
IDLS
,
hwvers_new_str
,
gwvers
,
gwvers_new
)
=
(
0
,
0
,
"BadPassword"
,
0
,
0
)
except
NAckError
:
print
(
"... Board not responding...
\n
"
)
(
IDMS
,
IDLS
,
hwvers_new_str
,
gwvers
,
gwvers_new
)
=
(
0
,
0
,
"NAckError"
,
0
,
0
)
baseaddr
=
0x100
if
(
bid
==
"TBLO"
):
gw_path
=
"./gw-blo/"
elif
(
bid
==
"T485"
):
gw_path
=
"./gw-rs485/"
# if (gwvers == 0xff):
# baseaddr = 0x300
# elif ((gwvers >= 0x10) and (gwvers <= 0x22)) or \
# (((gwvers & 0xf0) == 0x00) and (gwvers < 0x02)):
# baseaddr = 0x040
if
upgrade
==
True
mb
=
XilMultiboot
(
ELMA_I2C_MULTIBOOT
,
elma
,
slot
,
baseaddr
,
""
)
mb
.
set_bitstream_file
(
gw_path
+
gw_file
)
multiboot_addr
=
0x170000
multiboot_addr
=
int
(
multiboot_addr
,
16
)
mb
.
write
(
multiboot_addr
)
mb
.
iprog
(
multiboot_addr
)
if
(
upgrade
==
True
):
# Turn off the VME crate
ret
=
subprocess
.
call
(
"snmpset -v2c -c "
+
pwd
+
" "
+
ip
+
" 1.3.6.1.4.1.37968.1.1.7.2.1.3.1 i 1"
,
shell
=
True
,
stdout
=
None
,
stderr
=
None
)
# Turn on the VME crate
ret
=
subprocess
.
call
(
"snmpset -v2c -c "
+
pwd
+
" "
+
ip
+
" 1.3.6.1.4.1.37968.1.1.7.2.1.3.1 i 0"
,
shell
=
True
,
stdout
=
None
,
stderr
=
None
time
.
sleep
(
10
)
(
hwvers_new
,
gwvers_new
)
=
gw_hw_version
()
if
(
hwvers_new
==
0.0
):
hwvers_new_str
=
"<4.0"
else
:
hwvers_new_str
=
str
(
hwvers_new
)
IDMS
=
elma
.
read
(
slot
,
UIDREGMS
)
IDLS
=
elma
.
read
(
slot
,
UIDREGLS
)
#Generate log file
#subprocess.call("cd./log; chmod 777 log", shell=True, stdout=None, stderr=None)
#Generate log file
# Generate output file named according to current time
# Generate output file named according to current time
fname
=
time
.
strftime
(
"remote-gw-upgrade-
%
Y-
%
m-
%
d"
,
time
.
localtime
())
+
".txt"
ret
=
subprocess
.
call
([
"ls ./log | grep "
+
fname
],
shell
=
True
,
stdout
=
None
,
stderr
=
None
)
print
(
"
%
d"
%
ret
)
if
(
ret
!=
0
):
f
=
open
(
"./log/"
+
fname
,
"w"
)
fname
=
time
.
strftime
(
"gw-upgrade-
%
Y-
%
m-
%
d"
,
time
.
localtime
())
+
".txt"
ret
=
subprocess
.
call
([
"ls ./log | grep "
+
fname
],
shell
=
True
,
stdout
=
None
,
stderr
=
None
)
#print ("%d" % ret)
if
(
ret
!=
0
):
f
=
open
(
"./log/"
+
fname
,
"w"
)
f
.
write
(
"
\n
"
)
f
.
write
(
"CONV-TTL-XXX Upgrade log created on
%
s
\n
"
%
time
.
strftime
(
"
%
Y-
%
m-
%
d-
%
Hh
%
Mm
%
Ss"
,
time
.
localtime
()))
f
.
write
(
"
\n
"
)
f
.
write
(
"CONV-TTL-XXX Upgrade log created on
%
s
\n
"
%
time
.
strftime
(
"
%
Y-
%
m-
%
d-
%
Hh
%
Mm
%
Ss"
,
time
.
localtime
()))
f
.
write
(
"---------------------------------------------------------------------------------
\n
"
)
f
.
write
(
"* Target version is (v
%2.1
f)
\n
"
%
gwvers_target
)
f
.
write
(
"* Hardware (v0.0) means board is (v3.0) or earlier
\n
"
)
f
.
write
(
"
\n
"
)
f
.
write
(
"---------------------------------------------------------------------------------
\n
"
)
f
.
write
(
"Crate name| Slot |Barcode | PCB ID | HW version | Old gw version | New gw version
\n
"
)
f
.
write
(
"---------------------------------------------------------------------------------
\n
"
)
f
.
write
(
"---------------------------------------------------------------------------------
\n
"
)
f
.
write
(
"* Target version is (v
%2.1
f)
\n
"
%
gwvers_target
)
f
.
write
(
"* Hardware (v0.0) means board is (v3.0) or earlier
\n
"
)
f
.
write
(
"
\n
"
)
f
.
write
(
"---------------------------------------------------------------------------------
\n
"
)
f
.
write
(
"Crate name| Slot |Barcode | PCB ID | HW version | Old gw version | New gw version
\n
"
)
f
.
write
(
"---------------------------------------------------------------------------------
\n
"
)
f
.
close
()
print
(
"Upgrade log can be found in ./log/
%
s
\n
"
%
fname
)
f
=
open
(
"./log/"
+
fname
,
"a"
)
f
.
write
(
"
%
s
\t
%
d
\t
%
x
%
x
\t
(
%
s)
\t
(
%2.1
f)
\t
(
%2.1
f)
\n
"
%
(
ip
,
slot
,
IDMS
,
IDLS
,
hwvers_new_str
,
gwvers
,
gwvers_new
)
)
f
.
close
()
print
(
"Upgrade log can be found in ./log/
%
s
\n
"
%
fname
)
f
=
open
(
"./log/"
+
fname
,
"a"
)
f
.
write
(
"
%
s
\t
%
d
\t
%
s
\t
%
d
%
d
\t
(
%2.1
f)
\t
(
%2.1
f)
\t
(
%2.1
f)
\n
"
%
(
ip
,
slot
,
sn1
,
IDMS
,
IDLS
,
hwvers
,
gwvers
,
gwvers_new
)
)
f
.
close
()
men_off
()
...
...
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