Commit 7a145ab6 authored by Theodor-Adrian Stana's avatar Theodor-Adrian Stana

sw: Small changes in PTS build system and additions to flash test

Mainly, the build system changes consist in organizing the makefile better and
building to a local `ubuntu/' folder, which should then be copied directly to
the PTS system.

Then, the flash test changes consist in checking for a BusException error to not
fall in the trap of continuing on other exceptions occuring in the block of code
under `try'. Also, the flash test is more "modular" in that the gateware
versions to be downloaded can be specified at the beginning of the file.
parent f92d9079
ELMAIP = cfvm-864-celma1 ELMAIP =
ELMAPWD = Gr@nBr@st0 ELMAPWD =
ELMASLOT = 1 ELMASLOT =
all: all:
mkdir -p pts-conv-ttl-rs485/boot mkdir -p ubuntu/t485/log
mkdir -p pts-conv-ttl-rs485/tests touch ubuntu/t485/log/fan-speeds
mkdir -p pts-conv-ttl-rs485/lib
cp -r shell/ pts-conv-ttl-rs485/ cp -r shell/ ubuntu/t485/
cp pts-conv-ttl-rs485/shell/program pts-conv-ttl-rs485/boot
cp pts-conv-ttl-rs485/shell/flash pts-conv-ttl-rs485/boot mkdir -p ubuntu/t485/pyts/
cp python/pts.py pts-conv-ttl-rs485 cp python/* ubuntu/t485/pyts/
cp python/jpts.py pts-conv-ttl-rs485
cp python/vv_pts.py pts-conv-ttl-rs485/lib/ sed -i "s/ELMAIP = \"\"/ELMAIP = \"$(ELMAIP)\"/" ubuntu/t485/pyts/ptsdefine.py
cp python/ptsexcept.py pts-conv-ttl-rs485/lib/ sed -i "s/ELMAPWD = \"\"/ELMAPWD = \"$(ELMAPWD)\"/" ubuntu/t485/pyts/ptsdefine.py
sed -i "s/ELMASLOT =/ELMASLOT = $(ELMASLOT)/" ubuntu/t485/pyts/ptsdefine.py
cp python/ptsdefine.py pts-conv-ttl-rs485/lib/
sed -i "s/ELMAIP = \"\"/ELMAIP = \"$(ELMAIP)\"/" pts-conv-ttl-rs485/lib/ptsdefine.py cp ubuntu/t485/pyts/pts.py ubuntu/t485/pts
sed -i "s/ELMAPWD = \"\"/ELMAPWD = \"$(ELMAPWD)\"/" pts-conv-ttl-rs485/lib/ptsdefine.py cp ubuntu/t485/pyts/jpts.py ubuntu/t485/jpts
sed -i "s/ELMASLOT = 4/ELMASLOT = $(ELMASLOT)/" pts-conv-ttl-rs485/lib/ptsdefine.py ln -s pyts/dac_vcxo_pll.py ubuntu/t485/test01.py
ln -s pyts/leds.py ubuntu/t485/test02.py
cp python/leds.py pts-conv-ttl-rs485/tests/ ln -s pyts/ttl_pulse_switch.py ubuntu/t485/test03.py
cp python/dac_vcxo_pll.py pts-conv-ttl-rs485/tests/ ln -s pyts/rs485_pulse.py ubuntu/t485/test04.py
cp python/therm_id.py pts-conv-ttl-rs485/tests/ ln -s pyts/therm_id.py ubuntu/t485/test05.py
cp python/ttl_pulse_switch.py pts-conv-ttl-rs485/tests/ ln -s pyts/sfp_eeprom.py ubuntu/t485/test06.py
cp python/rs485_pulse.py pts-conv-ttl-rs485/tests/ ln -s pyts/sfp_test.py ubuntu/t485/test07.py
cp python/sfp_eeprom.py pts-conv-ttl-rs485/tests/ ln -s pyts/flashtest.py ubuntu/t485/flashtest.py
cp python/sfp_test.py pts-conv-ttl-rs485/tests/
cp python/flashtest.py pts-conv-ttl-rs485/ mkdir -p ubuntu/t485/boot
mv ubuntu/t485/shell/program ubuntu/t485/boot
ln -s tests/dac_vcxo_pll.py pts-conv-ttl-rs485/test01.py mv ubuntu/t485/shell/flash ubuntu/t485/boot
ln -s tests/leds.py pts-conv-ttl-rs485/test02.py wget -P ubuntu/t485/boot http://www.ohwr.org/attachments/download/3671/pts.bit
ln -s tests/ttl_pulse_switch.py pts-conv-ttl-rs485/test03.py wget -P ubuntu/t485/boot http://www.ohwr.org/attachments/download/3650/flash_load.bit
ln -s tests/rs485_pulse.py pts-conv-ttl-rs485/test04.py wget -P ubuntu/t485/boot http://www.ohwr.org/attachments/download/3657/golden-v0.0_release-v1.0.bin
ln -s tests/therm_id.py pts-conv-ttl-rs485/test05.py
ln -s tests/sfp_eeprom.py pts-conv-ttl-rs485/test06.py
ln -s tests/sfp_test.py pts-conv-ttl-rs485/test07.py
wget -P pts-conv-ttl-rs485/boot http://www.ohwr.org/attachments/download/3671/pts.bit
wget -P pts-conv-ttl-rs485/boot http://www.ohwr.org/attachments/download/3650/flash_load.bit
wget -P pts-conv-ttl-rs485/boot http://www.ohwr.org/attachments/download/3657/golden-v0.0_release-v1.0.bin
clean: clean:
rm -rf pts-conv-ttl-rs485 rm -rf ubuntu/
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
# Import system modules # Import system modules
import sys import sys
sys.path.append("../lib/") sys.path.append("pyts")
import time import time
import os import os
import math import math
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
# Import system modules # Import system modules
import sys import sys
sys.path.append("lib/") sys.path.append("log/")
import time import time
import os, errno, re, sys, struct import os, errno, re, sys, struct
import os.path import os.path
...@@ -66,11 +66,30 @@ def main(bus,tname,inf,log): ...@@ -66,11 +66,30 @@ def main(bus,tname,inf,log):
""" """
tests : Flash chip IC62 tests : Flash chip IC62
uses : golden-v0.0_release-v1.0.bit and flashtest.py uses : golden-v0.0_release-v1.0.bin and flashtest.py
""" """
RELEASE_GWVERS = 3.0 GWVERS_RELEASE = 1.0
GOLDEN_GWVERS = 0.2 GWVERS_GOLDEN = 0.0
# Set the precision of gateware versions based on the number of digits the
# fractional part thereof has; this is done to avoid exceptions in the
# printing to file below
#
# gwvers can be between 0.0 to 15.15 (four bits major, four bits minor)
r = GWVERS_RELEASE - int(GWVERS_RELEASE)
r *= 100
r = int(r)
pr = 1
if (r < 20) and (r >= 10):
pr = 2
g = GWVERS_GOLDEN - int(GWVERS_GOLDEN)
g *= 100
g = int(g)
pg = 1
if (g < 20) and (g >= 10):
pg = 2
pel = PTS_ERROR_LOGGER(inf,log) pel = PTS_ERROR_LOGGER(inf,log)
...@@ -101,11 +120,11 @@ def main(bus,tname,inf,log): ...@@ -101,11 +120,11 @@ def main(bus,tname,inf,log):
gwvers = maj + min gwvers = maj + min
# and now check if appropriate # and now check if appropriate
if (gwvers == RELEASE_GWVERS): if (gwvers == GWVERS_RELEASE):
msg = "Release gateware version correct: %2.*f\n" % (p, gwvers) msg = "Release gateware version correct: %2.*f\n" % (p, gwvers)
inf.write(msg) inf.write(msg)
else: else:
msg = "ERROR: Release gateware version (%2.*f) incorrect - expected %f" % (p, gwvers, RELEASE_GWVERS) msg = "ERROR: Release gateware version (%2.*f) incorrect - expected %2.*f" % (p, gwvers, pr, GWVERS_RELEASE)
pel.set(msg) pel.set(msg)
# Fall-back to golden addres by performing IPROG from wrong address # Fall-back to golden addres by performing IPROG from wrong address
...@@ -130,6 +149,18 @@ def main(bus,tname,inf,log): ...@@ -130,6 +149,18 @@ def main(bus,tname,inf,log):
pel.set(msg) pel.set(msg)
break break
# Get board ID and convert it to string
bid = bus.vv_read(0x00)
bid = binascii.unhexlify("%s" % "{0:x}".format(bid))
# and now check if appropriate
if (bid == "T485"):
msg = "Board ID correct: %s\n" % bid
inf.write(msg)
else:
msg = "ERROR: Board ID (%s) incorrect, check IC62" % bid
pel.set(msg)
# Read gateware version after fall-back # Read gateware version after fall-back
gwvers = bus.vv_read(0x04) & 0xff gwvers = bus.vv_read(0x04) & 0xff
maj = float(gwvers >> 4) maj = float(gwvers >> 4)
...@@ -143,16 +174,16 @@ def main(bus,tname,inf,log): ...@@ -143,16 +174,16 @@ def main(bus,tname,inf,log):
gwvers = maj + min gwvers = maj + min
# and now check if appropriate # and now check if appropriate
if (gwvers == GOLDEN_GWVERS): if (gwvers == GWVERS_GOLDEN):
msg = "Golden gateware version correct: %2.*f\n" % (p, gwvers) msg = "Golden gateware version correct: %2.*f\n" % (p, gwvers)
inf.write(msg) inf.write(msg)
else: else:
msg = "ERROR: Golden gateware version (%2.*f) incorrect - expected %f" % (p, gwvers, GOLDEN_GWVERS) msg = "ERROR: Golden gateware version (%2.*f) incorrect - expected %2.*f" % (p, gwvers, pg, GWVERS_GOLDEN)
pel.set(msg) pel.set(msg)
# FPGA up from booting, end the loop # FPGA up from booting, end the loop
break break
except: except BusException:
continue continue
return pel.get() return pel.get()
......
...@@ -48,7 +48,8 @@ ...@@ -48,7 +48,8 @@
## Import ## Import
##------------------------------------------------------------------------------------------------ ##------------------------------------------------------------------------------------------------
import sys import sys
sys.path.append('lib/') sys.path.append('.')
sys.path.append("pyts")
import ptsexcept import ptsexcept
import ptsdefine import ptsdefine
import time import time
......
...@@ -47,7 +47,6 @@ ...@@ -47,7 +47,6 @@
# Import system modules # Import system modules
import sys import sys
sys.path.append("../lib/")
import time import time
import os, errno, re, sys, struct import os, errno, re, sys, struct
import os.path import os.path
......
...@@ -54,14 +54,15 @@ ...@@ -54,14 +54,15 @@
##------------------------------------------------------------------------------------------------- ##-------------------------------------------------------------------------------------------------
import sys import sys
sys.path.append('.')
sys.path.append("pyts")
import time import time
import traceback import traceback
import os import os
import subprocess import subprocess
import re import re
sys.path.append('.')
##------------------------------------------------------------------------------------------------- ##-------------------------------------------------------------------------------------------------
## Method to turn on the ELMA crate. ## Method to turn on the ELMA crate.
##------------------------------------------------------------------------------------------------- ##-------------------------------------------------------------------------------------------------
...@@ -70,14 +71,11 @@ sys.path.append('.') ...@@ -70,14 +71,11 @@ sys.path.append('.')
def men_is_on(): def men_is_on():
on = 0 on = 0
subprocess.call("cd shell; ./get-fan-speeds", shell=True, stdout=fnull, stderr=fnull) subprocess.call("cd shell; ./get-fan-speeds", shell=True, stdout=fnull, stderr=fnull)
try: btxt = tuple(open("log/fan-speeds","r"))
btxt = tuple(open("log/fan-speeds","r")) for i in range(1,len(btxt)):
for i in range(1,len(btxt)): if btxt[i].find("INTEGER: 0") == -1:
if btxt[i].find("INTEGER: 0") == -1: on = on + 1
on = on + 1 return on
return on
except IOError:
return 0
##------------------------------------------------------------------------------------------------- ##-------------------------------------------------------------------------------------------------
## Method to turn on the VME crate. ## Method to turn on the VME crate.
...@@ -150,7 +148,7 @@ if __name__ == '__main__': ...@@ -150,7 +148,7 @@ if __name__ == '__main__':
sn2 = "0" sn2 = "0"
break break
# Ask the user to plug in the board, turn on the crate and call the flash_* script to download bitstream # Ask the user to plug in the board, turn on the crate and call the script to download bitstream
# to FPGA # to FPGA
msg = "\n--> Plug the CONV-TTL-RS485 board '%s-%s' into the VME crate.\n Then type 'ok': " % (sn1, sn2) msg = "\n--> Plug the CONV-TTL-RS485 board '%s-%s' into the VME crate.\n Then type 'ok': " % (sn1, sn2)
ok = raw_input(msg) ok = raw_input(msg)
...@@ -171,7 +169,7 @@ if __name__ == '__main__': ...@@ -171,7 +169,7 @@ if __name__ == '__main__':
print "ERROR: Bitstream download fail. Check JTAG connectivity." print "ERROR: Bitstream download fail. Check JTAG connectivity."
else: else:
# Run JPTS in another shell script; JPTS will handle running each of the test scripts # Run JPTS in another shell script; JPTS will handle running each of the test scripts
cmd = "xterm -e ./jpts.py -s %s %s" % (sn1, sn2) cmd = "xterm -e ./jpts -s %s %s" % (sn1, sn2)
print "Running tests :%s\n" % (cmd) print "Running tests :%s\n" % (cmd)
subprocess.call(cmd, shell=True, stdout=fnull, stderr=fnull) subprocess.call(cmd, shell=True, stdout=fnull, stderr=fnull)
ret = subprocess.call("grep FAIL log/*.log", shell=True, stdout=fnull, stderr=fnull) ret = subprocess.call("grep FAIL log/*.log", shell=True, stdout=fnull, stderr=fnull)
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
# ELMA crate definitions # ELMA crate definitions
ELMAIP = "" ELMAIP = ""
ELMAPWD = "" ELMAPWD = ""
ELMASLOT = 4 ELMASLOT =
# Board ID register # Board ID register
BIDR = 0x000 BIDR = 0x000
......
# Import system modules # Import system modules
import sys import sys
sys.path.append("../lib/")
import time import time
# Import common modules # Import common modules
......
...@@ -49,7 +49,6 @@ ...@@ -49,7 +49,6 @@
# Import system modules # Import system modules
import sys import sys
sys.path.append("../lib/")
import time import time
import os import os
......
...@@ -55,7 +55,6 @@ ...@@ -55,7 +55,6 @@
import ctypes import ctypes
import sys import sys
sys.path.append("../lib/")
import time import time
import os import os
import traceback import traceback
......
...@@ -47,7 +47,6 @@ ...@@ -47,7 +47,6 @@
# Import system modules # Import system modules
import sys import sys
sys.path.append("../lib/")
import time import time
import os import os
......
...@@ -101,7 +101,6 @@ ...@@ -101,7 +101,6 @@
# Import system modules # Import system modules
import sys import sys
sys.path.append("../lib/")
import time import time
import os, errno, re, struct import os, errno, re, struct
import os.path import os.path
......
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