From 0df9c16e69bcdf08487edfeafe31307172b338c2 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Thu, 2 Jul 2015 16:51:03 +0200 Subject: [PATCH] mibuild: Adding error checking around xsvf generation --- mibuild/fpgalink_programmer.py | 2 ++ mibuild/xilinx/programmer.py | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/mibuild/fpgalink_programmer.py b/mibuild/fpgalink_programmer.py index 12fcba32..bac8910e 100644 --- a/mibuild/fpgalink_programmer.py +++ b/mibuild/fpgalink_programmer.py @@ -80,6 +80,8 @@ class FPGALink(GenericProgrammer): xsvf_file = os.path.splitext(bitstream_file)[0]+'.xsvf' print("\nGenerating xsvf formatted bitstream") print("="*n) + if os.path.exists(xsvf_file): + os.unlink(xsvf_file) _create_xsvf(bitstream_file, xsvf_file) print("\n"+"="*n+"\n") diff --git a/mibuild/xilinx/programmer.py b/mibuild/xilinx/programmer.py index 7c76cf2f..f1ee00e0 100644 --- a/mibuild/xilinx/programmer.py +++ b/mibuild/xilinx/programmer.py @@ -1,3 +1,4 @@ +import os import sys import subprocess @@ -73,10 +74,13 @@ def _run_impact(cmds): with subprocess.Popen("impact -batch", stdin=subprocess.PIPE, shell=True) as process: process.stdin.write(cmds.encode("ASCII")) process.communicate() + return process.returncode def _create_xsvf(bitstream_file, xsvf_file): - _run_impact(""" + assert os.path.exists(bitstream_file), bitstream_file + assert not os.path.exists(xsvf_file), xsvf_file + assert 0 == _run_impact(""" setPreference -pref KeepSVF:True setMode -bs setCable -port xsvf -file {xsvf} -- 2.30.2