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
7f376c3e
Commit
7f376c3e
authored
Dec 19, 2017
by
Denia Bouhired-Ferrag
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Work in progress: added files for board gateware upgrading procedure
parent
f7b39015
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
521 additions
and
0 deletions
+521
-0
barcode.py
software/gwupdate/barcode.py
+109
-0
ei2cdefine.py
software/gwupdate/ei2cdefine.py
+48
-0
pseudocode-to-delete.txt
software/gwupdate/pseudocode-to-delete.txt
+46
-0
upgrade-log.py
software/gwupdate/upgrade-log.py
+318
-0
No files found.
software/gwupdate/barcode.py
0 → 100644
View file @
7f376c3e
#!/usr/bin/python
#===============================================================================
# CERN (BE-CO-HT)
# Pulse test script
#===============================================================================
# author: Denia Bouhired(t.stana@cern.ch)
#
# date of creation:
#
# version: 1.0
#
# description:
# This script is used during manual upgrade of conv-ttl boards.
# It is used to:
# Read barcodes on card using card reader
#
#===============================================================================
# GNU LESSER GENERAL PUBLIC LICENSE
#===============================================================================
# This source file is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by the
# Free Software Foundation; either version 2.1 of the License, or (at your
# option) any later version. This source is distributed in the hope that it
# will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Lesser General Public License for more details. You should have
# received a copy of the GNU Lesser General Public License along with this
# source; if not, download it from http://www.gnu.org/licenses/lgpl-2.1.html
#===============================================================================
#===============================================================================
# TODO: -
#===============================================================================
import
time
import
sys
import
time
sys
.
path
.
append
(
"../ei2c"
)
from
ei2c
import
*
import
ei2cdefine
import
binascii
import
re
import
subprocess
import
os
##-------------------------------------------------------------------------------------------------
## Method to turn on the VME crate.
##-------------------------------------------------------------------------------------------------
## It calls the men-on script which sends the necessary SMTP commands to the ELMA crate to turn on
## power to the VME backplane.
##-------------------------------------------------------------------------------------------------
def
men_on
():
print
(
"Switching on the ELMA crate"
)
subprocess
.
call
(
"shell/men-on"
,
shell
=
True
,
stdout
=
fnull
,
stderr
=
fnull
)
time
.
sleep
(
1
)
##-------------------------------------------------------------------------------------------------
## Method to turn off the VME crate.
##-------------------------------------------------------------------------------------------------
## It calls the men-off script which sends the necessary SMTP commands to the ELMA crate to turn off
## power to the VME backplane.
##-------------------------------------------------------------------------------------------------
def
men_off
():
print
(
"Switching off the ELMA crate"
)
subprocess
.
call
(
"shell/men-off"
,
shell
=
True
,
stdout
=
fnull
,
stderr
=
fnull
)
time
.
sleep
(
1
)
# Turn off the VME crate
men_off
()
# Scan the first barcode
while
True
:
sn1
=
raw_input
(
"--> Scan the 1st barcode: "
)
if
(
not
len
(
sn1
)):
sn1
=
"0"
m
=
re
.
search
(
r"[^a-z\-A-Z0-9_]+"
,
sn1
)
if
m
:
print
"Bad character in barcode"
else
:
break
# Scan the second barcode
while
True
:
sn2
=
raw_input
(
"--> Scan the 2nd barcode: "
)
if
len
(
sn2
)
>
2
:
m
=
re
.
search
(
r"[^a-z\-A-Z0-9_]+"
,
sn2
)
if
m
:
print
"Bad character in barcode"
else
:
break
else
:
sn2
=
"0"
break
# Ask the user to plug in the board, turn on the crate and call the script to download bitstream
# to FPGA
msg
=
"
\n
--> Plug the CONV-TTL-BLO board '
%
s-
%
s' into the VME crate.
\n
Then type 'ok': "
%
(
sn1
,
sn2
)
ok
=
raw_input
(
msg
)
while
True
:
if
ok
.
find
(
"ok"
)
!=
-
1
or
ok
.
find
(
"OK"
)
!=
-
1
:
break
else
:
ok
=
raw_input
(
"--> Please type 'ok' to continue: "
)
print
"
\n
"
# Turn on the VME crate
men_on
()
\ No newline at end of file
software/gwupdate/ei2cdefine.py
0 → 100644
View file @
7f376c3e
#===============================================================================
# CERN (BE-CO-HT)
# EI2C global definitions file
#===============================================================================
# author: Theodor Stana (t.stana@cern.ch)
#
# date of creation: 2014-03-05
#
# version: 1.0
#
# description:
#
# This module defines some global constants that are used by other scripts in
# the software suite. The constants and their definitions are in the code
# below.
#
#===============================================================================
# GNU LESSER GENERAL PUBLIC LICENSE
#===============================================================================
# This source file is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by the
# Free Software Foundation; either version 2.1 of the License, or (at your
# option) any later version. This source is distributed in the hope that it
# will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Lesser General Public License for more details. You should have
# received a copy of the GNU Lesser General Public License along with this
# source; if not, download it from http://www.gnu.org/licenses/lgpl-2.1.html
#===============================================================================
# last changes:
# 2014-03-05 Theodor Stana File created
# 2017-02-15 Maciej Suminski Added 'SLOT' parameter
#===============================================================================
# TODO: -
#===============================================================================
# Boolean to specify whether hostname, user & password are used
ENABLED
=
False
# Hostname, username and password
HNAME
=
"cfv-774-celma3"
USER
=
"admin"
PWD
=
"ADMIN"
SLOT
=
5
# Boolean to tell the ei2c.py module whether to create a dump file for the ELMA
# command replies
DUMP
=
False
software/gwupdate/pseudocode-to-delete.txt
0 → 100644
View file @
7f376c3e
Mass program procedure
set n = maximum value for i
elmaip
elmausrnmr
elmapwd
- Fill ELMA crate with as many conv-ttl-blo boards as necessary
- Run script "barcodes.py"
For i = 1 to n
- Script asks to scan barcode
- Script asks to insert board to slot number i
- I2C check board is in right slot (check board id)
- Check gw version. Asks if board must be upgraded
- if yes. keeps board in slot
- increment i
- if no. asks user to remove board
- waits for ok (is user does not remove board, then i is not incremented)
- ask if new board should be added if yes repeat, else leave fill crate loop
At the end, should have for each slot: board id, gw-vers-old- barcode1-barcode2 - hw-version - unique board ID
- Run mass multiboot script
- For all boards in crate
- read gw version
- check it corresponds to target version
- write new version on file, last column
- output log file
-concatenate files in the end as a bonus
scan barcode
insert board in slot number x
run program command
wait for program to finish
read hw version
read gw version
read unique id
output board id, gw-vers-old- barcode1-barcode2 - hw-version - unique board ID
to log file
ask if new board needs to be programmed
\ No newline at end of file
software/gwupdate/upgrade-log.py
0 → 100644
View file @
7f376c3e
#!/usr/bin/python
#===============================================================================
# CERN (BE-CO-HT)
# Pulse test script
#===============================================================================
# author: Denia Bouhired(t.stana@cern.ch)
#
# date of creation:
#
# version: 1.0
#
# description:
# This script is used during manual upgrade of conv-ttl boards.
# It is used to:
# - Scan barcode of board
# - Read hw version
# - Read gw version
# - Read unique temperature chip ID
# - Output information on log file
#
#===============================================================================
# GNU LESSER GENERAL PUBLIC LICENSE
#===============================================================================
# This source file is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by the
# Free Software Foundation; either version 2.1 of the License, or (at your
# option) any later version. This source is distributed in the hope that it
# will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Lesser General Public License for more details. You should have
# received a copy of the GNU Lesser General Public License along with this
# source; if not, download it from http://www.gnu.org/licenses/lgpl-2.1.html
#===============================================================================
#===============================================================================
# TODO: -
#===============================================================================
import
time
import
sys
import
time
sys
.
path
.
append
(
"../ei2c"
)
from
ei2c
import
*
import
ei2cdefine
import
binascii
import
re
import
subprocess
import
os
IDREG
=
0x00
SRREG
=
0x04
UIDREGLS
=
0xac
UIDREGMS
=
0xb0
# Status register offsets
CSR_GWVERS_OFS
=
0
CSR_HWVERS_OFS
=
22
if
__name__
==
"__main__"
:
# Get the IP, user and password for the ELMA crate from ei2cdefine.py
ip
=
ei2cdefine
.
HNAME
user
=
ei2cdefine
.
USER
pwd
=
ei2cdefine
.
PWD
slot
=
ei2cdefine
.
SLOT
testelma
=
EI2C
(
ip
,
user
,
pwd
)
testelma
.
open
()
# Get board ID and gateware version, fail if incorrect
bloid
=
testelma
.
read
(
slot
,
0x00
)
gwvers
=
testelma
.
read
(
slot
,
0x04
)
&
0xFF
if
(
bloid
!=
0x54424c4f
):
print
(
"Wrong board ID (
%
s)"
%
binascii
.
unhexlify
(
"
%
s"
%
\
"{0:x}"
.
format
(
bloid
)))
sys
.
exit
(
1
)
print
(
"Current gateware version is (0x
%02
x)"
%
gwvers
)
ans
=
raw_input
(
"Would you like to upgrade (y/n): "
)
if
(
ans
==
"y"
)
upgrade
=
True
elif
(
ans
==
"n"
)
upgrade
=
False
else
print
(
"Wrong input !
\n
"
)
sys
.
exit
(
1
)
if
upgrade
if
(
fwvers
!=
0xff
):
print
(
"Wrong version number (0x
%02
x)"
%
fwvers
)
sys
.
exit
(
1
)
# Reset chan. counters
testelma
.
write
(
slot
,
CHENREG
,
0x00
);
testelma
.
write
(
slot
,
CNTRST
,
1
);
testelma
.
write
(
slot
,
CNTRST
,
0
);
# First, setup the channel enable variable
chen
=
0x00
;
# Setup channel output pulse widths to 1.2us
testelma
.
write
(
slot
,
C1WDTHREG
,
1.2
*
(
10
**
(
-
6
))
/
CTB_CLK_PER
)
testelma
.
write
(
slot
,
C2WDTHREG
,
1.2
*
(
10
**
(
-
6
))
/
CTB_CLK_PER
)
testelma
.
write
(
slot
,
C3WDTHREG
,
1.2
*
(
10
**
(
-
6
))
/
CTB_CLK_PER
)
testelma
.
write
(
slot
,
C4WDTHREG
,
1.2
*
(
10
**
(
-
6
))
/
CTB_CLK_PER
)
testelma
.
write
(
slot
,
C5WDTHREG
,
1.2
*
(
10
**
(
-
6
))
/
CTB_CLK_PER
)
testelma
.
write
(
slot
,
C6WDTHREG
,
1.2
*
(
10
**
(
-
6
))
/
CTB_CLK_PER
)
# Setup channel delays and frequencies
farr
=
[
0
,
0
,
0
,
0
,
0
,
0
]
print
(
""
)
freq
=
input
(
"CH1 freq (Hz): "
)
if
(
freq
==
0
):
print
(
" CH1 not enabled"
)
else
:
chen
|=
(
1
<<
0
)
if
(
freq
>
MAXFREQ
):
freq
=
MAXFREQ
print
(
" Automatically setting channel frequency to
%
d Hz"
%
MAXFREQ
)
farr
[
0
]
=
freq
freq
=
1
/
(
freq
*
CTB_CLK_PER
)
testelma
.
write
(
slot
,
C1FREQREG
,
int
(
freq
))
#print(freq)
#print(hex(int(freq)))
freq
=
input
(
"CH2 freq (Hz): "
)
if
(
freq
==
0
):
print
(
" CH2 not enabled"
)
else
:
chen
|=
(
1
<<
1
)
if
(
freq
>
MAXFREQ
):
freq
=
MAXFREQ
print
(
" Automatically setting channel frequency to
%
d Hz"
%
MAXFREQ
)
farr
[
1
]
=
freq
freq
=
1
/
(
freq
*
CTB_CLK_PER
)
testelma
.
write
(
slot
,
C2FREQREG
,
int
(
freq
))
#print(freq)
#print(hex(int(freq)))
freq
=
input
(
"CH3 freq (Hz): "
)
if
(
freq
==
0
):
print
(
" CH3 not enabled"
)
else
:
chen
|=
(
1
<<
2
)
if
(
freq
>
MAXFREQ
):
freq
=
MAXFREQ
print
(
" Automatically setting channel frequency to
%
d Hz"
%
MAXFREQ
)
farr
[
2
]
=
freq
freq
=
1
/
(
freq
*
CTB_CLK_PER
)
testelma
.
write
(
slot
,
C3FREQREG
,
int
(
freq
))
#print(freq)
#print(hex(int(freq)))
freq
=
input
(
"CH4 freq (Hz): "
)
if
(
freq
==
0
):
print
(
" CH4 not enabled"
)
else
:
chen
|=
(
1
<<
3
)
if
(
freq
>
MAXFREQ
):
freq
=
MAXFREQ
print
(
" Automatically setting channel frequency to
%
d Hz"
%
MAXFREQ
)
farr
[
3
]
=
freq
freq
=
1
/
(
freq
*
CTB_CLK_PER
)
testelma
.
write
(
slot
,
C4FREQREG
,
int
(
freq
))
#print(freq)
#print(hex(int(freq)))
freq
=
input
(
"CH5 freq (Hz): "
)
if
(
freq
==
0
):
print
(
" CH5 not enabled"
)
else
:
chen
|=
(
1
<<
4
);
if
(
freq
>
MAXFREQ
):
freq
=
MAXFREQ
print
(
" Automatically setting channel frequency to
%
d Hz"
%
MAXFREQ
)
farr
[
4
]
=
freq
freq
=
1
/
(
freq
*
CTB_CLK_PER
)
testelma
.
write
(
slot
,
C5FREQREG
,
int
(
freq
))
#print(freq)
#print(hex(int(freq)))
freq
=
input
(
"CH6 freq (Hz): "
)
if
(
freq
==
0
):
print
(
" CH6 not enabled"
)
else
:
chen
|=
(
1
<<
5
);
if
(
freq
>
MAXFREQ
):
freq
=
MAXFREQ
print
(
" Automatically setting channel frequency to
%
d Hz"
%
MAXFREQ
)
farr
[
5
]
=
freq
freq
=
1
/
(
freq
*
CTB_CLK_PER
)
testelma
.
write
(
slot
,
C6FREQREG
,
int
(
freq
))
#print(freq)
#print(hex(int(freq)))
# Ask how long to run the test
print
(
""
)
print
(
"How long would you like to run the test?"
)
while
1
:
try
:
hrs
=
raw_input
(
" hrs: "
)
hrs
=
int
(
hrs
)
if
(
hrs
<
0
):
raise
Exception
break
except
KeyboardInterrupt
:
sys
.
exit
()
except
:
print
(
" Hours must be a decimal number >= 0!"
)
while
1
:
try
:
mins
=
raw_input
(
" mins: "
)
mins
=
int
(
mins
)
if
(
mins
<
0
):
raise
Exception
break
except
KeyboardInterrupt
:
sys
.
exit
()
except
:
print
(
" Minutes must be a decimal number >= 0!"
)
while
1
:
try
:
secs
=
raw_input
(
" secs: "
)
secs
=
int
(
secs
)
if
(
secs
<
0
):
raise
Exception
break
except
KeyboardInterrupt
:
sys
.
exit
()
except
:
print
(
" Seconds must be a decimal number >= 0!"
)
# Compute test end time according to current time
#
# time.time() returns time since start of epoch
# in seconds, so add secs, mins and hrs to that
start_time
=
time
.
time
()
end_time
=
start_time
+
secs
+
60
*
mins
+
3600
*
hrs
# Generate output file named according to current time
fname
=
time
.
strftime
(
"p-
%
Y-
%
m-
%
d-
%
Hh
%
M"
,
time
.
localtime
())
+
".txt"
f
=
open
(
fname
,
"w"
)
# Write current time and start of test to output file
f
.
write
(
"------------------------------------------------------------
\n
"
)
f
.
write
(
"
%
s: starting test
\n
"
%
time
.
strftime
(
"
%
Y-
%
m-
%
d-
%
Hh
%
Mm
%
Ss"
,
time
.
localtime
()))
print
(
"
%
s: starting test"
%
time
.
strftime
(
"
%
Y-
%
m-
%
d-
%
Hh
%
Mm
%
Ss"
,
time
.
localtime
()))
f
.
write
(
"------------------------------------------------------------
\n
"
)
# Enable the needed channels and start generating pulses
testelma
.
write
(
slot
,
CHENREG
,
chen
)
# Run test loop for the specified time
while
time
.
time
()
<
end_time
:
pass
# Disable all channels
while
(
testelma
.
read
(
slot
,
CHENREG
)
!=
0x00
):
testelma
.
write
(
slot
,
CHENREG
,
0x00
)
f
.
write
(
"
%
s: ending test
\n
"
%
time
.
strftime
(
"
%
Y-
%
m-
%
d-
%
Hh
%
Mm
%
Ss"
,
time
.
localtime
()))
print
(
"
%
s: ending test"
%
time
.
strftime
(
"
%
Y-
%
m-
%
d-
%
Hh
%
Mm
%
Ss"
,
time
.
localtime
()))
f
.
write
(
"------------------------------------------------------------
\n
"
)
secs
=
int
(
end_time
-
start_time
)
f
.
write
(
"pulses sent and received:
\n
"
)
# Read counter registers
i
=
testelma
.
read
(
slot
,
C1IREG
)
o
=
testelma
.
read
(
slot
,
C1OREG
)
f
.
write
(
"ch
%
d (f =
%
d) / i:
%
d / o:
%
d
\n
"
%
(
1
,
farr
[
0
],
i
,
o
))
i
=
testelma
.
read
(
slot
,
C2IREG
)
o
=
testelma
.
read
(
slot
,
C2OREG
)
f
.
write
(
"ch
%
d (f =
%
d) / i:
%
d / o:
%
d
\n
"
%
(
2
,
farr
[
1
],
i
,
o
))
i
=
testelma
.
read
(
slot
,
C3IREG
)
o
=
testelma
.
read
(
slot
,
C3OREG
)
f
.
write
(
"ch
%
d (f =
%
d) / i:
%
d / o:
%
d
\n
"
%
(
3
,
farr
[
2
],
i
,
o
))
i
=
testelma
.
read
(
slot
,
C4IREG
)
o
=
testelma
.
read
(
slot
,
C4OREG
)
f
.
write
(
"ch
%
d (f =
%
d) / i:
%
d / o:
%
d
\n
"
%
(
4
,
farr
[
3
],
i
,
o
))
i
=
testelma
.
read
(
slot
,
C5IREG
)
o
=
testelma
.
read
(
slot
,
C5OREG
)
f
.
write
(
"ch
%
d (f =
%
d) / i:
%
d / o:
%
d
\n
"
%
(
5
,
farr
[
4
],
i
,
o
))
i
=
testelma
.
read
(
slot
,
C6IREG
)
o
=
testelma
.
read
(
slot
,
C6OREG
)
f
.
write
(
"ch
%
d (f =
%
d) / i:
%
d / o:
%
d
\n
"
%
(
6
,
farr
[
5
],
i
,
o
))
testelma
.
close
()
f
.
write
(
"------------------------------------------------------------
\n
"
)
# Close output file
f
.
close
()
# Print output file name
print
(
""
)
print
(
"Test results can be found in "
+
fname
)
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