Commit 4f518266 authored by Evangelia Gousiou's avatar Evangelia Gousiou

updated python tests and spec.sh

parent eed3c448
FMC 0 d21
FMC 1 h23
FMC 2 h22
FMC 3 g21
FMC 4 g22
FMC 5 c19
FMC 6 c18
FMC 7 d20
FMC 8 d18
FMC 9 d17
FMC 10 h19
FMC 11 h20
FMC 12 g18
FMC 13 h38
FMC 14 g36
FMC 15 g37
FMC 16 h13
FMC 17 d11
FMC 18 h14
FMC 19 g13
FMC 20 g12
FMC 21 c11
FMC 22 g15
FMC 23 d15
FMC 24 g19
FMC 25 g16
FMC 26 h16
FMC 27 c15
FMC 28 h17
FMC 29 c14
FMC 30 d14
FMC 31 d12
FMC 32 c26
FMC 33 d24
FMC 34 g24
FMC 35 g25
FMC 36 c23
FMC 37 c22
FMC 38 d23
FMC 39 h25
FMC 40 h28
FMC 41 g28
FMC 42 d29
FMC 43 g27
FMC 44 c27
FMC 45 d26
FMC 46 h26
FMC 47 d27
FMC 48 h37
FMC 49 h35
FMC 50 d35
FMC 51 g34
FMC 52 h34
FMC 53 c34
FMC 54 d34
FMC 55 d33
FMC 56 g30
FMC 57 g31
FMC 58 d31
FMC 59 g33
FMC 60 h32
FMC 61 h31
FMC 62 d30
FMC 63 h29
FMC 64 h2
FMC 65 h4
FMC 66 h5
FMC 81 d1
FMC 82 d8
FMC 83 c10
FMC 84 d9
FMC 85 g10
FMC 86 h10
FMC 87 g9
FMC 88 h1
FMC 89 g3
FMC 90 g2
FMC 91 g6
FMC 93 g6
FMC 95 h11
\ No newline at end of file
......@@ -2,6 +2,9 @@
LOGDIR=./log
sudo rmmod rawrabbit
sudo insmod gnurabbit/kernel/rawrabbit.ko
mkdir -p $LOGDIR
sudo rm -fr $LOGDIR/pts*
......@@ -37,7 +40,7 @@ cmd="sudo ./pts.py -b SPEC -s "$serial" -e "$extra_serial
if [ ! x$mac_addr = x"" ]; then
cmd=$cmd" -m "$mac_addr
fi
cmd=$cmd" -t./test/spec/python -l "$LOGDIR" 00 01 02 03 04 05 06 07 08 09 10 12"
cmd=$cmd" -t./test/spec/python -l "$LOGDIR" 00 01 02 03 04 05 06 07 08 09 10 12" #01 02 04 05 06" #
# Execute pts.py
$cmd
......
......@@ -38,14 +38,15 @@ class EEPROM_GENNUM:
while i > 0:
i-=1
tmp = self.gennum.iread(4, self.TWI_STATUS, 4)
#print 'TWI_STATUS=%.8X' % tmp
#time.sleep(.5)
print 'TWI_STATUS=%.8X' % tmp
time.sleep(.5)
if tmp & 0x100 == 0:
#print 'I2C bus is idle'
break
# Read to clear TWI_IRT_STATUS
tmp = self.gennum.iread(4, self.TWI_IRT_STATUS, 4)
print("IRT status %x" % tmp)
# Write word offset
tmp=(0xFF & offset)
self.gennum.iwrite(4, self.I2C_DATA, 4, tmp)
......@@ -58,6 +59,9 @@ class EEPROM_GENNUM:
i=2000000
while i > 0:
tmp = self.gennum.iread(4, self.TWI_IRT_STATUS, 4)
print 'TWI_IRT_STATUS=%.8X' % tmp
time.sleep(.5)
if tmp & 0x1:
break
elif tmp & 0xC:
......
#!/usr/bin/python
################################################################################
##
## The script is part of the SPEC and SVEC PTS. It is used to generate SDBFS
## image that is then stored in Flash or EEPROM memory. The image contains MAC
## address and optionally also an FPGA bitstream. The main purpose of including
## it to the PTS is to allow manufacturers assigning official MAC addresses to
## SPEC and SVEC boards.
##
## Copyright (C) 2017 CERN (www.cern.ch)
## Author: Grzegorz Daniluk <grzegorz.daniluk@cern.ch>
##
################################################################################
import sys
import re
import subprocess
import os
import shutil
#class CSDBGenerator :
SDBFS_MAC = "{path}sdbfs-{type}/mac-address"
SDBFS_BSTR = "{path}sdbfs-{type}/bitstream"
SDBFS_IMG = "{path}sdbfs-{type}-{mac}.bin"
GEN_SPEC_CMD = "{path}./gensdbfs -b 65536 {path}sdbfs-spec {img}"
GEN_SVEC_CMD = "{path}./gensdbfs -b 262144 {path}sdbfs-svec {img}"
###########################################################
def check_mac(mac):
if not re.match("[0-9a-f]{2}([-:])[0-9a-f]{2}(\\1[0-9a-f]{2}){4}$", mac.lower()):
print "Not a valid MAC address"
return 0
return 1
###########################################################
# type can be either "spec" or "svec"
def gen_sdb_image(type, mac, bstr, output=None):
if mac and not check_mac(mac):
return
# Translate MAC to be always in XX-XX-XX-XX-XX-XX format
mac = mac.replace(':', '-')
# Get the absolute path where this script resides. This lets us have always
# access to the sdbfs-spec/svec structure, no matter where this script is
# called.
abs_path = os.path.dirname(os.path.abspath(__file__)) + '/'
# 1. write MAC address to the file in SDBFS
mac_bytes = [int(i, 16) for i in mac.split('-')]
sdbfs_mac = SDBFS_MAC.format(path=abs_path, type=type)
f = open(sdbfs_mac, 'wb')
f.truncate()
for byte in mac_bytes:
f.write(chr(byte))
f.close()
# 2. copy bitstream to SDBFS, if needed
sdbfs_bstr = SDBFS_BSTR.format(path=abs_path, type=type) #<abs_path>/sdbfs-<type>/bitstream
if bstr:
print "Including bitstream " + bstr
shutil.copy(bstr, sdbfs_bstr)
else:
#truncate bitstream file if not given
f = open(sdbfs_bstr, 'wb')
f.truncate()
f.close()
# 3. generate SDBFS image
sdbfs_img = SDBFS_IMG.format(path=abs_path, type=type, mac=mac)
# gensdbfs for spec/svec
if type == "spec":
cmd = GEN_SPEC_CMD.format(path=abs_path, img=sdbfs_img)
else:
cmd = GEN_SVEC_CMD.format(path=abs_path, img=sdbfs_img)
subprocess.Popen(cmd, shell=True).wait()
print "Generated " + sdbfs_img
# 4. Copy generated SDBFS image to <output>
if output:
shutil.copy(sdbfs_img, output)
print "Generated image (" + sdbfs_img + ") copied to " + output
###########################################################
if __name__ == "__main__":
if len(sys.argv) < 3:
print "Wrong syntax"
print sys.argv[0] + " <spec/svec> <mac> [bitstream]"
sys.exit()
type = sys.argv[1]
if type != "spec" and type != "svec":
print "Wrong syntax"
print sys.argv[0] + " <spec/svec> <mac> [bitstream]"
sys.exit()
#mac = check_mac(sys.argv[2])
mac = sys.argv[2]
if len(sys.argv) > 3:
bitstream = sys.argv[3]
else:
bitstream = ""
gen_sdb_image(type, mac, bitstream)
......@@ -113,42 +113,43 @@ def main (default_directory='.'):
# Load board library and open the corresponding device
print "Loading hardware access library and opening devices\n"
spec = rr.Gennum();
spec_csr = CCSR(spec, 0x10000, CARRIER_CSR);
if spec_csr.get_field('CARRIER', 'TYPE') != 0x0001 :
spec_csr.print_reg_map()
raise PtsCritical("CRITICAL: Carrier is not a SPEC board")
pcb_rev = spec_csr.get_field('CARRIER', 'PCB_REV')
if pcb_rev < 3 :
raise PtsError("ERROR: SPEC PCB board not of a supported revision")
else :
print "SPEC board PCB Rev: %d\n" % pcb_rev
tmp_stdout = sys.stdout;
sys.stdout = sys.__stdout__;
print "SPEC board PCB Rev: %d\n" % pcb_rev
sys.stdout = tmp_stdout;
i2c = COpenCoresI2C(spec, 0x40000, 99); # Prescaler value calculated using 50 MHz clock
# The address of the AD7997 is 0x23, pin 15 connected to GND.
adc = ADC_AD7997(i2c, 0x23);
print "Test01 Start"
init_test_time = time.time()
ret_error = None
# Retrieving the voltage measurements
value8 = adc_value(adc.rd_reg16(0xF0)); # P2V5_FMC
value7 = adc_value(adc.rd_reg16(0xE0)); # P12V_FMC
value6 = adc_value(adc.rd_reg16(0xD0)); # P3V3_FMC
value5 = adc_value(adc.rd_reg16(0xC0));
value4 = adc_value(adc.rd_reg16(0xB0));
value3 = adc_value(adc.rd_reg16(0xA0));
value2 = adc_value(adc.rd_reg16(0x90));
value1 = adc_value(adc.rd_reg16(0x80));
spec = rr.Gennum();
spec_csr = CCSR(spec, 0x10000, CARRIER_CSR);
if spec_csr.get_field('CARRIER', 'TYPE') != 0x0001 :
spec_csr.print_reg_map()
raise PtsCritical("CRITICAL: Carrier is not a SPEC board")
pcb_rev = spec_csr.get_field('CARRIER', 'PCB_REV')
if pcb_rev < 3 :
raise PtsError("ERROR: SPEC PCB board not of a supported revision")
else :
print "SPEC board PCB Rev: %d\n" % pcb_rev
tmp_stdout = sys.stdout;
sys.stdout = sys.__stdout__;
print "SPEC board PCB Rev: %d\n" % pcb_rev
sys.stdout = tmp_stdout;
i2c = COpenCoresI2C(spec, 0x40000, 99); # Prescaler value calculated using 50 MHz clock
# The address of the AD7997 is 0x23, pin 15 connected to GND.
adc = ADC_AD7997(i2c, 0x23);
print "Test01 Start"
init_test_time = time.time()
ret_error = None
# Retrieving the voltage measurements
value8 = adc_value(adc.rd_reg16(0xF0)); # P2V5_FMC
value7 = adc_value(adc.rd_reg16(0xE0)); # P12V_FMC
value6 = adc_value(adc.rd_reg16(0xD0)); # P3V3_FMC
value5 = adc_value(adc.rd_reg16(0xC0));
value4 = adc_value(adc.rd_reg16(0xB0));
value3 = adc_value(adc.rd_reg16(0xA0));
value2 = adc_value(adc.rd_reg16(0x90));
value1 = adc_value(adc.rd_reg16(0x80));
ret_error=""
# Evaluating the results
# P2V5_FMC acceptable limits: >2.37V and <2.62V
......
......@@ -203,7 +203,9 @@ class GPIO_slave:
##-------------------------------------------------------------------------------------------------
def pin_str(bit):
btxt = tuple(open("./SPEC_FMC_pinout.txt","r"))
print btxt
for i in range(1,len(btxt)):
mch = "FMC %d" % (bit)
if btxt[i].find(mch) != -1:
......@@ -311,6 +313,8 @@ def test_bit(x27, x24, x22, x26, x21, x25, fpga_inputs0, fpga_inputs1, fpga_inpu
msg = "ERROR: FMC Connector: pin %s, received=%x expected=%x" % (pin_str(bit), received, expected)
print(msg)
return msg
else:
msg = "OK: FMC Connector: pin %s, received=%x expected=%x" % (pin_str(bit), received, expected)
##-------------------------------------------------------------------------------------------------
## main --
......@@ -331,6 +335,7 @@ def main (default_directory='.'):
os.system( firmware_loader + ' ' + bitstream)
#time.sleep(2);
# Load board library and open the corresponding device
print "Loading hardware access library and opening devices\n"
spec = rr.Gennum();
......
......@@ -88,6 +88,7 @@ def main (default_directory='.'):
start = time.time();
flash.lib.gpio_bootselect(flash.GENNUM_FLASH);
version = hex(flash.lib.flash_read_id());
print ("EEPROM version %s")%version
#if (version != "0x202016"):
# added the version for the new parts M25P64-VMF6TP and W25Q64JVSFIQ:
if (version != "0x202016" and version != "0x202017" and version != "0xef4017"):
......@@ -108,7 +109,7 @@ def main (default_directory='.'):
print "Time elapsed: " + str(finish - start) + " seconds"
time.sleep(5)
time.sleep(25)
ask = "";
tmp_stdout = sys.stdout;
......
......@@ -146,10 +146,18 @@ def main (default_directory='.'):
# Test with Si570 output disabled
time.sleep(2)
spec.iwrite(0,SI570_COUNTER_RST_WB_ADDR,4,1) # Reset the counter
time.sleep(2)
spec.iwrite(0,SI570_OE_WB_ADDR,4,0) # Disable oscillator output
time.sleep(2)
spec.iwrite(0,SI570_COUNTER_RST_WB_ADDR,4,0) # Remove counter reset
time.sleep(2) # Count during 2sec
counter_value = spec.iread(0,SI570_COUNTER_VALUE_WB_ADDR,4)# Get counter value
print ("Counter value: %d")%counter_value
time.sleep(2) # Count during 2sec
counter_value = spec.iread(0,SI570_COUNTER_VALUE_WB_ADDR,4)# Get counter value
if counter_value >= (COUNTER_2SEC):
......
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