Commit 8cf29a42 authored by Denia Bouhired-Ferrag's avatar Denia Bouhired-Ferrag

Finalised gw upgrade procedure, with final folder structure and scripts

parent 7f376c3e
* Run script gw-upgrade.py, by running the command
python gw-upgrade.py
* Type "y" if you have a board you would like to upgrade gateware for, "n" if not
* Place ESD strap on your wrist
* Take conv-ttl-xxx board carefully out of box and ESD bag
* Scan both LHC barcodes on the board. Press Enter after each scan
* Place board on slot X of Elma crate, without engaging it all the way.
* Plug the Xilinx Cable on the Xiling connector (JTAG) of the conv-ttl-xxx board
* Engage the conv-ttl-xx board al the way in the VME crate, and press the front panel handles until they make a click noise
* Type ok on the terminal prompt
* The script checks the board ID and states whether the board in the slot is a conv-ttl-blo or conv-ttl-rs485. If board information is correct, press y, if not press n and restart the script with the correct board.
* The script then checks the current board hardware and gateware version number. If the the hardware version is older than v4.0 then the script will not be able to identify the exact version number, only that it is v3.0 or earlier.
* The script checks that the gateware version is different than the target upgrade. If it is the same as the target version, then upgrade is not necessary and the script aborts. If the current version does not match target version, than script proceeds with upgrade.
* Once upgrade starts, you need to wait a few minutes for it to be completed. The script will then display the new gateware version (hardware version should NOT change). The information is all saved in the log file.
* The script will ask you to remove the board and type ok. Make sure you are wearing the ESD bracelet. Put the board back in ESD bag and then in box.
* If more boards need upgrading, type "y" and start the procedure from the top again.
Note:
The log file is created with the current date. All tests for the day are appended to the same file.
If you want to restart a new log file, it needs to be manually renamed and the script will write on a new one
#!/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
......@@ -38,7 +38,7 @@
ENABLED = False
# Hostname, username and password
HNAME = "cfv-774-celma3"
HNAME = "cfvm-774-elma3"
USER = "admin"
PWD = "ADMIN"
SLOT = 5
......
This diff is collapsed.
#!/bin/bash
echo Power OFF ELMA crate
snmpset -v2c -c ADMIN cfvm-774-elma3 1.3.6.1.4.1.37968.1.1.7.2.1.3.1 i 1
#!/bin/bash
echo Power ON ELMA crate
snmpset -v2c -c ADMIN cfvm-774-elma3 1.3.6.1.4.1.37968.1.1.7.2.1.3.1 i 0
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
#!/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%02x)" % 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%02x)" % 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)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment