From c33984b35e1803bafe33384c895b1b83e1a86980 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sun, 13 Sep 2015 00:05:31 -0700 Subject: [PATCH 01/20] Build gateware on travis. --- .travis/run.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis/run.sh b/.travis/run.sh index 24dc06ff..3974ed2b 100644 --- a/.travis/run.sh +++ b/.travis/run.sh @@ -27,7 +27,12 @@ for BOARD in $BOARDS; do echo "---------------------------------------------" BOARD=$BOARD TARGET=$TARGET make help - # FIXME: Add ability to compile gateware. + echo "" + echo "" + echo "" + echo "- make gateware" + echo "---------------------------------------------" + BOARD=$BOARD TARGET=$TARGET make gateware echo "" echo "" From f998912562599288988ca699a9ddcd5e5fe3531e Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sun, 13 Sep 2015 01:18:13 -0700 Subject: [PATCH 02/20] Disable IRC announcement for now. --- .travis.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5fca79d7..21940836 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,9 +17,9 @@ script: notifications: email: - hdmi2usb-spam@googlegroups.com - irc: - channels: - - "chat.freenode.net#hdmi2usb" - - "chat.freenode.net#timvideos" - template: - - "[%{repository_slug}/%{branch}#%{build_number}] (%{commit}): %{message} (%{build_url})" +# irc: +# channels: +# - "chat.freenode.net#hdmi2usb" +# - "chat.freenode.net#timvideos" +# template: +# - "[%{repository_slug}/%{branch}#%{build_number}] (%{commit}): %{message} (%{build_url})" From 5612bda2376de5caf660be44a628adc0d5173c70 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sat, 12 Sep 2015 18:08:43 -0700 Subject: [PATCH 03/20] Adding encrypted stripped back Xilinx ISE for travis-ci --- .travis/package-xilinx.sh | 27 ++++++++++++++++++++ .travis/run.sh | 18 +++++++++++--- Makefile | 8 +++++- scripts/get-env.sh | 52 +++++++++++++++++++++++++++++++++++++-- scripts/setup-env.sh | 18 ++++++++++++-- 5 files changed, 114 insertions(+), 9 deletions(-) create mode 100755 .travis/package-xilinx.sh diff --git a/.travis/package-xilinx.sh b/.travis/package-xilinx.sh new file mode 100755 index 00000000..e45354fc --- /dev/null +++ b/.travis/package-xilinx.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +set -x +set -e + +#XILINX_PASSPHRASE +#RACKSPACE_USER +#RACKSPACE_API + +export PREFIX="/opt/Xilinx/" + +TB_COMMAND="turbolift -u $RACKSPACE_USER -a $RACKSPACE_API --os-rax-auth iad upload -c xilinx" + +./build/migen/tools/strace_tailor.sh $PREFIX bash .travis/run.sh + +FILENAME="xilinx-ise-$(git describe).tar.bz2" +echo $FILENAME + +tar --preserve-permissions -jcvf $FILENAME opt +echo $XILINX_PASSPHRASE_IN | gpg --passphrase-fd 0 --cipher-algo AES256 -c $FILENAME + +# Upload the tar bz +$TB_COMMAND -s . --sync --pattern-match ".*\.gpg" + +# Generate an index file +md5sum *.gpg | sort -k2 > index.txt +$TB_COMMAND -s index.txt diff --git a/.travis/run.sh b/.travis/run.sh index 3974ed2b..c47f8058 100644 --- a/.travis/run.sh +++ b/.travis/run.sh @@ -2,6 +2,12 @@ . scripts/setup-env.sh +if [ -f $XILINX_DIR/opt/Xilinx/14.7/ISE_DS/ISE/bin/lin64/xreport ]; then + HAVE_XILINX_ISE=1 +else + HAVE_XILINX_ISE=0 +fi + set +x set -e @@ -30,16 +36,20 @@ for BOARD in $BOARDS; do echo "" echo "" echo "" - echo "- make gateware" + echo "- make firmware ($BOARD $TARGET)" echo "---------------------------------------------" - BOARD=$BOARD TARGET=$TARGET make gateware + BOARD=$BOARD TARGET=$TARGET make firmware echo "" echo "" echo "" - echo "- make firmware ($BOARD $TARGET)" + echo "- make gatewaree ($BOARD $TARGET)" echo "---------------------------------------------" - BOARD=$BOARD TARGET=$TARGET make firmware + if [ $HAVE_XILINX_ISE -eq 0 ]; then + echo "Skipping gateware" + else + BOARD=$BOARD TARGET=$TARGET make gateware + fi echo "" echo "" diff --git a/Makefile b/Makefile index 3df97829..afaf5cbd 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,13 @@ HDMI2USBDIR = ../.. PYTHON = python3 DATE = `date +%Y_%m_%d` -CMD = $(PYTHON) make.py -X $(HDMI2USBDIR) -t $(BOARD)_$(TARGET) -Ot firmware_filename $(HDMI2USBDIR)/firmware/lm32/firmware.bin -Op programmer $(PROG) +CMD = $(PYTHON) \ + make.py \ + -X $(HDMI2USBDIR) \ + -t $(BOARD)_$(TARGET) \ + -Ot firmware_filename $(HDMI2USBDIR)/firmware/lm32/firmware.bin \ + -Op programmer $(PROG) \ + $(MISOC_EXTRA_CMDLINE) ifeq ($(OS),Windows_NT) FLTERM = $(PYTHON) $(MSCDIR)/tools/flterm.py diff --git a/scripts/get-env.sh b/scripts/get-env.sh index 620b3b7f..b016ba43 100755 --- a/scripts/get-env.sh +++ b/scripts/get-env.sh @@ -6,7 +6,6 @@ SETUP_DIR=$(dirname $SETUP_SRC) TOP_DIR=$(realpath $SETUP_DIR/..) BUILD_DIR=$TOP_DIR/build - set -x set -e @@ -14,10 +13,59 @@ echo " This script is: $SETUP_SRC" echo " Firmware directory: $TOP_DIR" echo " Build directory is: $BUILD_DIR" +# Check the build dir if [ ! -d $BUILD_DIR ]; then mkdir -p $BUILD_DIR fi +# Xilinx ISE +if [ ! -z "$XILINX_PASSPHRASE" ]; then + + # Need gpg to do the unencryption + sudo apt-get install gnupg + + XILINX_DIR=$BUILD_DIR/Xilinx + if [ ! -d "$XILINX_DIR" ]; then + ( + cd $BUILD_DIR + mkdir Xilinx + cd Xilinx + + wget -q http://xilinx.timvideos.us/index.txt -O xilinx-details.txt + XILINX_TAR_INFO=$(cat xilinx-details.txt | grep tar.bz2.gpg | tail -n 1) + XILINX_TAR_FILE=$(echo $XILINX_TAR_INFO | sed -e's/[^ ]* //' -e's/.gpg$//') + XILINX_TAR_MD5=$(echo $XILINX_TAR_INFO | sed -e's/ .*//') + + # This setup was taken from https://github.com/m-labs/artiq/blob/master/.travis/get-xilinx.sh + wget -c http://xilinx.timvideos.us/${XILINX_TAR_FILE}.gpg + echo "$XILINX_PASSPHRASE" | gpg --batch --passphrase-fd 0 ${XILINX_TAR_FILE}.gpg + tar -xjf $XILINX_TAR_FILE + + # Relocate ISE from /opt to $XILINX_DIR + for i in $(grep -Rsn "/opt/Xilinx" $XILINX_DIR/opt | cut -d':' -f1) + do + sed -i -e "s!/opt/Xilinx!$XILINX_DIR/opt/Xilinx!g" $i + done + + wget -c http://xilinx.timvideos.us/Xilinx.lic.gpg + echo "$XILINX_PASSPHRASE" | gpg --batch --passphrase-fd 0 Xilinx.lic.gpg + + git clone https://github.com/mithro/impersonate_macaddress + cd impersonate_macaddress + make + ) + fi + export MISOC_EXTRA_CMDLINE="-Ob ise_path $XILINX_DIR/opt/Xilinx/" + # Reserved MAC address from documentation block, see + # http://www.iana.org/assignments/ethernet-numbers/ethernet-numbers.xhtml + export XILINXD_LICENSE_FILE=$XILINX_DIR + export MACADDR=90:10:00:00:00:01 + #export LD_PRELOAD=$XILINX_DIR/impersonate_macaddress/impersonate_macaddress.so + #ls -l $LD_PRELOAD +else + XILINX_DIR=/ +fi + # gcc+binutils for the target CONDA_DIR=$SETUP_DIR/build/conda export PATH=$CONDA_DIR/bin:$PATH @@ -108,7 +156,7 @@ MAKESTUFF_DIR=$BUILD_DIR/makestuff cd $MAKESTUFF_DIR cd libs/libfpgalink fi - make deps + make deps 2>&1 | grep -E "^make" ) export LD_LIBRARY_PATH=$MAKESTUFF_DIR/libs/libfpgalink/lin.x64/rel:$LD_LIBRARY_PATH export PYTHONPATH=$MAKESTUFF_DIR/libs/libfpgalink/examples/python/:$PYTHONPATH diff --git a/scripts/setup-env.sh b/scripts/setup-env.sh index adb50342..de5c3965 100755 --- a/scripts/setup-env.sh +++ b/scripts/setup-env.sh @@ -8,6 +8,7 @@ SETUP_DIR=$(dirname $SETUP_SRC) TOP_DIR=$(realpath $SETUP_DIR/..) BUILD_DIR=$TOP_DIR/build + if [ $SOURCED = 0 ]; then echo "You must source this script, rather then try and run it." echo ". $SETUP_SRC" @@ -23,11 +24,26 @@ echo " This script is: $SETUP_SRC" echo " Firmware directory: $TOP_DIR" echo " Build directory is: $BUILD_DIR" +# Check the build dir if [ ! -d $BUILD_DIR ]; then echo "Build directory not found!" return fi +# Xilinx ISE +if [ ! -z "$XILINX_PASSPHRASE" ]; then + XILINX_DIR=$BUILD_DIR/Xilinx + export MISOC_EXTRA_CMDLINE="-Ob ise_path $XILINX_DIR/opt/Xilinx/" + # Reserved MAC address from documentation block, see + # http://www.iana.org/assignments/ethernet-numbers/ethernet-numbers.xhtml + export XILINXD_LICENSE_FILE=$XILINX_DIR + export MACADDR=90:10:00:00:00:01 + #export LD_PRELOAD=$XILINX_DIR/impersonate_macaddress/impersonate_macaddress.so + #ls -l $LD_PRELOAD +else + XILINX_DIR=/ +fi + # gcc+binutils for the target CONDA_DIR=$SETUP_DIR/build/conda export PATH=$CONDA_DIR/bin:$PATH @@ -53,8 +69,6 @@ export LD_LIBRARY_PATH=$MAKESTUFF_DIR/libs/libfpgalink/lin.x64/rel:$LD_LIBRARY_P export PYTHONPATH=$MAKESTUFF_DIR/libs/libfpgalink/examples/python/:$PYTHONPATH python3 -c "import fl" || (echo "libfpgalink broken"; return) -export PATH=$PATH:/opt/Xilinx/14.7/ISE_DS/ISE/bin/lin64/ - alias python=python3 HDMI2USB_ENV=1 From f736bfa0f91c40a1f6fa52a062c5d1a0f11f1631 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sun, 13 Sep 2015 03:57:36 -0700 Subject: [PATCH 04/20] Adding matrix. --- .travis.yml | 8 ++++++++ .travis/package-xilinx.sh | 1 + .travis/run.sh | 20 +++++++++++++++----- scripts/get-env.sh | 1 + scripts/setup-env.sh | 1 + 5 files changed, 26 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 21940836..605d5354 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,14 @@ language: compiler: - gcc +env: + matrix: + - BOARD=atlys TARGET=base + - BOARD=atlys TARGET=hdmi2usb + - BOARD=atlys TARGET=hdmi2ethernet + - BOARD=opsis TARGET=base + - BOARD=opsis TARGET=hdmi2usb + install: - wget -q -O- https://raw.githubusercontent.com/mithro/travis-trusty/master/setup.sh | bash - chmod a+rx $PWD/.travis/*.sh diff --git a/.travis/package-xilinx.sh b/.travis/package-xilinx.sh index e45354fc..eb26df08 100755 --- a/.travis/package-xilinx.sh +++ b/.travis/package-xilinx.sh @@ -12,6 +12,7 @@ export PREFIX="/opt/Xilinx/" TB_COMMAND="turbolift -u $RACKSPACE_USER -a $RACKSPACE_API --os-rax-auth iad upload -c xilinx" ./build/migen/tools/strace_tailor.sh $PREFIX bash .travis/run.sh +cp $PREFIX/14.7/ISE_DS/ISE/bin/lin64/xreport opt/Xilinx/14.7/ISE_DS/ISE/bin/lin64/ FILENAME="xilinx-ise-$(git describe).tar.bz2" echo $FILENAME diff --git a/.travis/run.sh b/.travis/run.sh index c47f8058..bf371e56 100644 --- a/.travis/run.sh +++ b/.travis/run.sh @@ -2,6 +2,7 @@ . scripts/setup-env.sh +ls -l $XILINX_DIR/opt/Xilinx/14.7/ISE_DS/ISE/bin/lin64/xreport if [ -f $XILINX_DIR/opt/Xilinx/14.7/ISE_DS/ISE/bin/lin64/xreport ]; then HAVE_XILINX_ISE=1 else @@ -11,13 +12,22 @@ fi set +x set -e -BOARDS="atlys opsis" +if [ -z "$BOARD" ]; then + BOARDS="atlys opsis" +else + BOARDS="$BOARD" +fi for BOARD in $BOARDS; do - TARGETS="base hdmi2usb" - # FIXME: Get hdmi2ethernet working on the Opsis - if [ "$BOARD" = "atlys" ]; then - TARGETS="$TARGETS hdmi2ethernet" + if [ -z "$TARGET" ]; then + TARGETS="base hdmi2usb" + # FIXME: Get hdmi2ethernet working on the Opsis + # https://github.com/timvideos/HDMI2USB-misoc-firmware/issues/51 + if [ "$BOARD" = "atlys" ]; then + TARGETS="$TARGETS hdmi2ethernet" + fi + else + TARGETS="$TARGET" fi for TARGET in $TARGETS; do diff --git a/scripts/get-env.sh b/scripts/get-env.sh index b016ba43..914551b0 100755 --- a/scripts/get-env.sh +++ b/scripts/get-env.sh @@ -65,6 +65,7 @@ if [ ! -z "$XILINX_PASSPHRASE" ]; then else XILINX_DIR=/ fi +echo " Xilinx directory is: $XILINX_DIR/opt/Xilinx/" # gcc+binutils for the target CONDA_DIR=$SETUP_DIR/build/conda diff --git a/scripts/setup-env.sh b/scripts/setup-env.sh index de5c3965..9a19f30b 100755 --- a/scripts/setup-env.sh +++ b/scripts/setup-env.sh @@ -43,6 +43,7 @@ if [ ! -z "$XILINX_PASSPHRASE" ]; then else XILINX_DIR=/ fi +echo " Xilinx directory is: $XILINX_DIR/opt/Xilinx/" # gcc+binutils for the target CONDA_DIR=$SETUP_DIR/build/conda From 7a899f53c757332063dbb705bb38bdc199ccead8 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Mon, 14 Sep 2015 17:56:29 -0700 Subject: [PATCH 05/20] Run inner loop in subshell (so $TARGET doesn't escape). --- .travis/run.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis/run.sh b/.travis/run.sh index bf371e56..80f207d8 100644 --- a/.travis/run.sh +++ b/.travis/run.sh @@ -29,7 +29,7 @@ for BOARD in $BOARDS; do else TARGETS="$TARGET" fi - + ( for TARGET in $TARGETS; do echo "" echo "" @@ -69,4 +69,5 @@ for BOARD in $BOARDS; do BOARD=$BOARD TARGET=$TARGET make clean echo "=============================================" done + ) done From 833d7d97b2bed6f361ee36bdd9a05fb33dcab436 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sun, 13 Sep 2015 16:08:32 -0700 Subject: [PATCH 06/20] Making packaging Xilinx ISE. --- .travis/package-xilinx-filter-strace.py | 108 ++++++++++++++++++++++++ .travis/package-xilinx.sh | 60 ++++++++++--- 2 files changed, 154 insertions(+), 14 deletions(-) create mode 100755 .travis/package-xilinx-filter-strace.py diff --git a/.travis/package-xilinx-filter-strace.py b/.travis/package-xilinx-filter-strace.py new file mode 100755 index 00000000..92255678 --- /dev/null +++ b/.travis/package-xilinx-filter-strace.py @@ -0,0 +1,108 @@ +#!/usr/bin/python + +import sys +import re +import os + +if "--verbose" not in sys.argv: + verbose = False + def write(*args, **kw): + pass +else: + verbose = True + write = sys.stderr.write + +prefix = sys.argv[-1] +prefix_re = '"(%s[^"]*)"' % prefix.replace('/', '/+') + +cmds = {} +finished_cmds = {} +waiting_on = {} +files = set() + +last_pid = None +for lineno, rawline in enumerate(sys.stdin.readlines()): + try: + bits = re.match(r"^(?P[0-9]+) (?P.*?)(?P )?$", rawline) + + pid = bits.group('pid') + line = bits.group('line') + + if pid != last_pid: + if pid not in cmds: + if "execve" in line: + write("%08i: fork+exec, using new line %r\n" % (lineno, line)) + cmds[pid] = line + else: + if last_pid in cmds: + last_command = cmds[last_pid] + else: + last_command = finished_cmds[last_pid] + write("%08i: Not a fork+exec (%r), using last line %r\n" % (lineno, line, last_command)) + cmds[pid] = last_command + last_pid = pid + + # Connect together lines where the kernel switched between processes + # 31093 vfork( + # 31439 execve("/opt/Xilinx/14.7/ISE_DS/ISE/bin/lin64/unwrapped/wbtc", ["/opt/Xilinx/14.7/ISE_DS/ISE/bin/"..., "-f", "/home/tansell/foss/timvideos/hdm"...], [/* 79 vars */]) = 0 + # 31093 <... vfork resumed> ) + unfinished = bits.group('unfinished') + assert "" not in line + if unfinished: + assert pid not in waiting_on + waiting_on[pid] = line + unfinished + continue + if "resumed>" in line: + assert pid in waiting_on + line = waiting_on[pid] + " " + line + del waiting_on[pid] + + if "exited with" in line: + assert pid not in waiting_on + finished_cmds[pid] = cmds[pid] + del cmds[pid] + continue + else: + assert pid in cmds + + # Command exec tracking + if "execve" in line and cmds[pid] != line: + write("%08i: Replacing %r with %r\n" % (lineno, cmds[pid], line)) + cmds[pid] = line + + # Did the syscall succeed? + success = "-1 ENOENT" not in line + + # Does the syscall use the prefix? + bits = re.search(prefix_re, line) + if not bits: + continue + + # Normalize the path + path = bits.group(1) + path = os.path.normpath(path) + if path.startswith('//'): + path = path[1:] + + assert path.startswith(prefix) + + # Did the file exist? + if not success: + assert not os.path.exists(path) + continue + else: + assert os.path.exists(path) + + # Skip directories + if os.path.isdir(path): + continue + + write("%08i: Found %r via command %r (Previously seen: %r)\n" % (lineno, path, cmds[pid], path in files)) + + files.add(path) + except Exception as e: + sys.stderr.write("%08i: %r %r\n" % (lineno, e, rawline)) + raise + +for filename in sorted(files): + print filename diff --git a/.travis/package-xilinx.sh b/.travis/package-xilinx.sh index eb26df08..73e73f25 100755 --- a/.travis/package-xilinx.sh +++ b/.travis/package-xilinx.sh @@ -3,26 +3,58 @@ set -x set -e -#XILINX_PASSPHRASE -#RACKSPACE_USER -#RACKSPACE_API +SETUP_SRC=$(realpath ${BASH_SOURCE[0]}) +SETUP_DIR=$(dirname $SETUP_SRC) +TOP_DIR=$(realpath $SETUP_DIR/..) + +for ARG in XILINX_PASSPHRASE_IN RACKSPACE_USER RACKSPACE_API; do + if [ -z "${!ARG}" ]; then + echo "$ARG not set" + exit 1 + else + echo "$ARG='${!ARG}'" + fi +done + +BASE=$TOP_DIR/build/package-xilinx +echo $BASE +mkdir -p $BASE export PREFIX="/opt/Xilinx/" -TB_COMMAND="turbolift -u $RACKSPACE_USER -a $RACKSPACE_API --os-rax-auth iad upload -c xilinx" +# This is based on https://github.com/m-labs/migen/blob/master/tools/strace_tailor.sh +STRACE_LOG=$BASE/strace.log +if [ ! -f $STRACE_LOG ]; then + strace -e trace=file,process -f -o $STRACE_LOG bash $SETUP_DIR/run.sh +fi -./build/migen/tools/strace_tailor.sh $PREFIX bash .travis/run.sh -cp $PREFIX/14.7/ISE_DS/ISE/bin/lin64/xreport opt/Xilinx/14.7/ISE_DS/ISE/bin/lin64/ +STRACE_FILES=$BASE/strace.files.log +cat $STRACE_LOG | python $SETUP_DIR/package-xilinx-filter-strace.py $PREFIX > $STRACE_FILES -FILENAME="xilinx-ise-$(git describe).tar.bz2" -echo $FILENAME +XILINX_DIR=$BASE/xilinx-stripped +if [ -d $XILINX_DIR ]; then + rm -rf $XILINX_DIR +fi + +mkdir -p $XILINX_DIR +cat $STRACE_FILES | xargs -d '\n' \ + cp --parents --no-dereference --preserve=all -t $XILINX_DIR -tar --preserve-permissions -jcvf $FILENAME opt +FILENAME="$BASE/xilinx-ise-$(git describe).tar.bz2" +echo $FILENAME +( + cd $XILINX_DIR + tar --preserve-permissions -jcvf $FILENAME opt +) echo $XILINX_PASSPHRASE_IN | gpg --passphrase-fd 0 --cipher-algo AES256 -c $FILENAME -# Upload the tar bz -$TB_COMMAND -s . --sync --pattern-match ".*\.gpg" +( + cd $BASE + TB_COMMAND="turbolift -u $RACKSPACE_USER -a $RACKSPACE_API --os-rax-auth iad upload -c xilinx" -# Generate an index file -md5sum *.gpg | sort -k2 > index.txt -$TB_COMMAND -s index.txt + # Upload the tar bz + $TB_COMMAND -s . --sync --pattern-match ".*\.gpg" + # Upload the index file + md5sum *.gpg | sort -k2 > index.txt + $TB_COMMAND -s index.txt +) From dac0a0e56a8e7f27df56319f569b8ae76c33c554 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sun, 13 Sep 2015 16:21:29 -0700 Subject: [PATCH 07/20] Be more careful not to expose the passphrase. --- scripts/get-env.sh | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/scripts/get-env.sh b/scripts/get-env.sh index 914551b0..6a35a033 100755 --- a/scripts/get-env.sh +++ b/scripts/get-env.sh @@ -19,8 +19,22 @@ if [ ! -d $BUILD_DIR ]; then fi # Xilinx ISE + +# -------- +# Save the passphrase to a file so we don't echo it in the logs +XILINX_PASSPHRASE_FILE=$(tempfile) +trap "rm -f -- '$XILINX_PASSPHRASE_FILE'" EXIT +set +x if [ ! -z "$XILINX_PASSPHRASE" ]; then + echo $XILINX_PASSPHRASE >> $XILINX_PASSPHRASE_FILE +else + rm $XILINX_PASSPHRASE_FILE + trap - EXIT +fi +set -x +# -------- +if [ -f $XILINX_PASSPHRASE_FILE ]; then # Need gpg to do the unencryption sudo apt-get install gnupg @@ -38,7 +52,7 @@ if [ ! -z "$XILINX_PASSPHRASE" ]; then # This setup was taken from https://github.com/m-labs/artiq/blob/master/.travis/get-xilinx.sh wget -c http://xilinx.timvideos.us/${XILINX_TAR_FILE}.gpg - echo "$XILINX_PASSPHRASE" | gpg --batch --passphrase-fd 0 ${XILINX_TAR_FILE}.gpg + cat $XILINX_PASSPHRASE_FILE | gpg --batch --passphrase-fd 0 ${XILINX_TAR_FILE}.gpg tar -xjf $XILINX_TAR_FILE # Relocate ISE from /opt to $XILINX_DIR @@ -48,7 +62,7 @@ if [ ! -z "$XILINX_PASSPHRASE" ]; then done wget -c http://xilinx.timvideos.us/Xilinx.lic.gpg - echo "$XILINX_PASSPHRASE" | gpg --batch --passphrase-fd 0 Xilinx.lic.gpg + cat $XILINX_PASSPHRASE_FILE | gpg --batch --passphrase-fd 0 Xilinx.lic.gpg git clone https://github.com/mithro/impersonate_macaddress cd impersonate_macaddress @@ -65,6 +79,8 @@ if [ ! -z "$XILINX_PASSPHRASE" ]; then else XILINX_DIR=/ fi +rm $XILINX_PASSPHRASE_FILE +trap - EXIT echo " Xilinx directory is: $XILINX_DIR/opt/Xilinx/" # gcc+binutils for the target From 7f369b29b49b80ae0c89ce534ebce9548a84898d Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sun, 13 Sep 2015 23:14:12 -0700 Subject: [PATCH 08/20] Temporary fix for libfpgalink --- scripts/setup-env.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/setup-env.sh b/scripts/setup-env.sh index 9a19f30b..4c3a58e4 100755 --- a/scripts/setup-env.sh +++ b/scripts/setup-env.sh @@ -31,8 +31,8 @@ if [ ! -d $BUILD_DIR ]; then fi # Xilinx ISE -if [ ! -z "$XILINX_PASSPHRASE" ]; then - XILINX_DIR=$BUILD_DIR/Xilinx +XILINX_DIR=$BUILD_DIR/Xilinx +if [ -d "$XILINX_DIR" ]; then export MISOC_EXTRA_CMDLINE="-Ob ise_path $XILINX_DIR/opt/Xilinx/" # Reserved MAC address from documentation block, see # http://www.iana.org/assignments/ethernet-numbers/ethernet-numbers.xhtml @@ -44,6 +44,9 @@ else XILINX_DIR=/ fi echo " Xilinx directory is: $XILINX_DIR/opt/Xilinx/" +# FIXME: Remove this when build/migen/mibuild/xilinx/programmer.py:_create_xsvf +# understands the $MISOC_EXTRA_CMDLINE option. +export PATH=$PATH:$XILINX_DIR/opt/Xilinx/14.7/ISE_DS/ISE/bin/lin64 # gcc+binutils for the target CONDA_DIR=$SETUP_DIR/build/conda From 0a7b5047e3901b48b118db0a1c64c0f9edb8a9ea Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sun, 13 Sep 2015 23:24:22 -0700 Subject: [PATCH 09/20] Allow failure for Opsis HDMI2USB target for now. --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 605d5354..0f3d2856 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,10 @@ env: - BOARD=opsis TARGET=base - BOARD=opsis TARGET=hdmi2usb +matrix: + allow_failures: + - env: BOARD=opsis TARGET=hdmi2usb + install: - wget -q -O- https://raw.githubusercontent.com/mithro/travis-trusty/master/setup.sh | bash - chmod a+rx $PWD/.travis/*.sh From ea47ce84e4998158e50d78075ca659578680e71f Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sun, 13 Sep 2015 23:30:27 -0700 Subject: [PATCH 10/20] Also include running the load step (and allow it to fail). (So impact gets included in the package.) --- .travis/package-xilinx.sh | 3 ++- .travis/run.sh | 14 +++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.travis/package-xilinx.sh b/.travis/package-xilinx.sh index 73e73f25..a089e202 100755 --- a/.travis/package-xilinx.sh +++ b/.travis/package-xilinx.sh @@ -25,7 +25,8 @@ export PREFIX="/opt/Xilinx/" # This is based on https://github.com/m-labs/migen/blob/master/tools/strace_tailor.sh STRACE_LOG=$BASE/strace.log if [ ! -f $STRACE_LOG ]; then - strace -e trace=file,process -f -o $STRACE_LOG bash $SETUP_DIR/run.sh + export PROGS=fpgalink + strace -e trace=file,process -f -o ${STRACE_LOG} bash $SETUP_DIR/run.sh fi STRACE_FILES=$BASE/strace.files.log diff --git a/.travis/run.sh b/.travis/run.sh index 80f207d8..eef08cd8 100644 --- a/.travis/run.sh +++ b/.travis/run.sh @@ -53,7 +53,7 @@ for BOARD in $BOARDS; do echo "" echo "" echo "" - echo "- make gatewaree ($BOARD $TARGET)" + echo "- make gateware ($BOARD $TARGET)" echo "---------------------------------------------" if [ $HAVE_XILINX_ISE -eq 0 ]; then echo "Skipping gateware" @@ -61,6 +61,18 @@ for BOARD in $BOARDS; do BOARD=$BOARD TARGET=$TARGET make gateware fi + if [ ! -z "$PROGS" ]; then + for PROG in $PROGS; do + echo "" + echo "" + echo "" + echo "- make load-gateware ($PROG $BOARD $TARGET)" + echo "---------------------------------------------" + # Allow the programming to fail. + PROG=$PROG BOARD=$BOARD TARGET=$TARGET make load-gateware || true + done + fi + echo "" echo "" echo "" From 46612c240c697957df13521e90a73e43f89bc676 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Mon, 14 Sep 2015 00:01:09 -0700 Subject: [PATCH 11/20] Use same test as run.sh --- scripts/setup-env.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/setup-env.sh b/scripts/setup-env.sh index 4c3a58e4..f32d27ac 100755 --- a/scripts/setup-env.sh +++ b/scripts/setup-env.sh @@ -32,7 +32,7 @@ fi # Xilinx ISE XILINX_DIR=$BUILD_DIR/Xilinx -if [ -d "$XILINX_DIR" ]; then +if [ -f "$XILINX_DIR/opt/Xilinx/14.7/ISE_DS/ISE/bin/lin64/xreport" ]; then export MISOC_EXTRA_CMDLINE="-Ob ise_path $XILINX_DIR/opt/Xilinx/" # Reserved MAC address from documentation block, see # http://www.iana.org/assignments/ethernet-numbers/ethernet-numbers.xhtml From dc11a2b41dfdb264acee3ac85631ac8f428bced1 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Mon, 14 Sep 2015 00:08:05 -0700 Subject: [PATCH 12/20] Reenable the IRC announcements. --- .travis.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0f3d2856..395cd69b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,9 +29,9 @@ script: notifications: email: - hdmi2usb-spam@googlegroups.com -# irc: -# channels: -# - "chat.freenode.net#hdmi2usb" -# - "chat.freenode.net#timvideos" -# template: -# - "[%{repository_slug}/%{branch}#%{build_number}] (%{commit}): %{message} (%{build_url})" + irc: + channels: + - "chat.freenode.net#hdmi2usb" + - "chat.freenode.net#timvideos" + template: + - "[%{repository_slug}/%{branch}#%{build_number}] (%{commit}): %{message} (%{build_url})" From 203be48fa8c6a44bd1f3afc3a5bf95e0b16e3ce7 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Mon, 14 Sep 2015 01:02:40 -0700 Subject: [PATCH 13/20] Small fix. --- scripts/get-env.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/get-env.sh b/scripts/get-env.sh index 6a35a033..566f0b13 100755 --- a/scripts/get-env.sh +++ b/scripts/get-env.sh @@ -76,11 +76,12 @@ if [ -f $XILINX_PASSPHRASE_FILE ]; then export MACADDR=90:10:00:00:00:01 #export LD_PRELOAD=$XILINX_DIR/impersonate_macaddress/impersonate_macaddress.so #ls -l $LD_PRELOAD + + rm $XILINX_PASSPHRASE_FILE + trap - EXIT else XILINX_DIR=/ fi -rm $XILINX_PASSPHRASE_FILE -trap - EXIT echo " Xilinx directory is: $XILINX_DIR/opt/Xilinx/" # gcc+binutils for the target From 745b3b81a3ed932e4272f0bf4c369f0b395e08a1 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Mon, 14 Sep 2015 01:44:03 -0700 Subject: [PATCH 14/20] Add missing build-essential package. --- scripts/get-env.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/get-env.sh b/scripts/get-env.sh index 566f0b13..b00123fd 100755 --- a/scripts/get-env.sh +++ b/scripts/get-env.sh @@ -18,6 +18,8 @@ if [ ! -d $BUILD_DIR ]; then mkdir -p $BUILD_DIR fi +sudo apt-get install -y build-essential + # Xilinx ISE # -------- @@ -36,7 +38,7 @@ set -x if [ -f $XILINX_PASSPHRASE_FILE ]; then # Need gpg to do the unencryption - sudo apt-get install gnupg + sudo apt-get install -y gnupg XILINX_DIR=$BUILD_DIR/Xilinx if [ ! -d "$XILINX_DIR" ]; then From 4fe5868284ceb18f3e05b8afa2395451cdee3d99 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Sun, 13 Sep 2015 20:29:37 -0700 Subject: [PATCH 15/20] Start of a script to prettify the Xilinx ISE output. --- .travis/run-make-gateware-filter.py | 345 ++++++++++++++++++++ .travis/run-make-gateware-suppression.regex | 2 + 2 files changed, 347 insertions(+) create mode 100755 .travis/run-make-gateware-filter.py create mode 100644 .travis/run-make-gateware-suppression.regex diff --git a/.travis/run-make-gateware-filter.py b/.travis/run-make-gateware-filter.py new file mode 100755 index 00000000..1980b3c3 --- /dev/null +++ b/.travis/run-make-gateware-filter.py @@ -0,0 +1,345 @@ +#!/usr/bin/python + +import collections +import os +import pprint +import re +import signal +import subprocess +import sys +import threading +import time + +log_file = open(sys.argv[1], 'w') + +# Suppressions for warning / info messages +suppressions = [x.strip() for x in open(sys.argv[2], 'r').readlines() if not x.startswith('#')] +pprint.pprint(suppressions) +suppressions = [re.compile(x) for x in suppressions] + +top_path = os.path.normpath(os.getcwd()) + +def output(s, *args, **kw): + keepalive_thread.output = True + if args: + assert not kw + sys.stdout.write((s % args).encode('utf-8')) + elif kw: + sys.stdout.write((s % kw).encode('utf-8')) + else: + sys.stdout.write(s.encode('utf-8')) + + # Flush every second + if (time.time() - keepalive_thread.last_output_time) > 1: + sys.stdout.flush() + + keepalive_thread.last_output_time = time.time() + + +class KeepAliveThread(threading.Thread): + def __init__(self): + threading.Thread.__init__(self) + self.daemon = True + self.output = False + self.last_output_time = time.time() + + def run(self): + while True: + if (time.time() - self.last_output_time) > 30: + output(u"\U0001F436") + time.sleep(1) + +keepalive_thread = KeepAliveThread() +keepalive_thread.start() + +BUFFER_SIZE=100 +DELIM_MAJOR = "=========================================================================" +ERROR = "*~"*35+"*" + +linesbuffer = collections.deque() +for i in range(0, BUFFER_SIZE): + linesbuffer.appendleft('') + +def shorten_path(line): + outputline = line + for path in re.finditer('"([^"]+)"', line): + pathname = os.path.normpath(path.group(1)) + if os.path.exists(pathname) and os.path.isfile(pathname): + common_path = os.path.commonprefix([top_path, pathname]) + relative_path = pathname[len(common_path)+1:] + + outputline = outputline.replace(path.group(1), relative_path) + return outputline + + +fsm_triggered = False +found_specials = [] + +last_path = None +for lineno, rawline in enumerate(sys.stdin.readlines()): + log_file.write(rawline+'\n') + log_file.flush() + + line = rawline.strip('\n\r') + sline = line.strip() + linesbuffer.appendleft(line) + while len(linesbuffer) > BUFFER_SIZE: + linesbuffer.pop() + + if line.startswith("make"): + output('\n'+line+'\n') + continue + + if not sline: + continue + + if line.startswith("ERROR:"): + output("\nError detected! - %s\n%s\n%s\n%s\n", line, ERROR, "\n".join(reversed(linesbuffer)), ERROR) + continue + + # WARNING:HDLCompiler:1016 - "/home/tansell/foss/timvideos/hdmi2usb/HDMI2USB-misoc-firmware/build/misoc/build/atlys_hdmi2usb-hdmi2usbsoc-atlys.v" Line 24382: Port I_LOCK_O is not connected to this instance + # WARNING:HDLCompiler:1016 - "/home/tansell/foss/timvideos/hdmi2usb/HDMI2USB-misoc-firmware/build/misoc/build/atlys_hdmi2usb-hdmi2usbsoc-atlys.v" Line 24475: Port IOCLK is not connected to this instance + # WARNING:Xst:3035 - Index value(s) does not match array range for signal , simulation mismatch. + # INFO:Xst:2774 - HDL ADVISOR - KEEP property attached to signal eth_rx_clk may hinder XST clustering optimizations. + keepalive_thread.output = False + if line.startswith("WARNING:"): + output("w") + continue + elif line.startswith("INFO:"): + output("i") + continue + + # Output a header which looks like this unless it is a summary header + # ========================================================================= + # * HDL Parsing * + # ========================================================================= + if linesbuffer[0] == DELIM_MAJOR and \ + linesbuffer[1].startswith("*") and \ + linesbuffer[2] == DELIM_MAJOR: + if "Summary" in linesbuffer[1]: + continue + else: + output("\n\n%s\n%s\n%s\n", linesbuffer[0], linesbuffer[1], linesbuffer[2]) + continue + + # When we see a filename, output it. Examples; + # Analyzing Verilog file "/home/tansell/foss/timvideos/hdmi2usb/HDMI2USB-misoc-firmware/build/misoc/extcores/lm32/submodule/rtl/lm32_dp_ram.v" into library work + # Parsing verilog file "/home/tansell/foss/timvideos/hdmi2usb/HDMI2USB-misoc-firmware/build/misoc/extcores/lm32/submodule/rtl/lm32_include.v" included at line 31. + # Parsing module . + # Analyzing Verilog file "/home/tansell/foss/timvideos/hdmi2usb/HDMI2USB-misoc-firmware/build/misoc/extcores/lm32/submodule/rtl/lm32_shifter.v" into library work + # Parsing verilog file "/home/tansell/foss/timvideos/hdmi2usb/HDMI2USB-misoc-firmware/build/misoc/extcores/lm32/submodule/rtl/lm32_include.v" included at line 50. + # Parsing module . + #for path in re.finditer('"([^"]+)"', line): + # pathname = os.path.normpath(path.group(1)) + # if os.path.exists(pathname) and os.path.isfile(pathname): + # if pathname != last_path: + # last_path = pathname + # + # common_path = os.path.commonprefix([top_path, pathname]) + # relative_path = pathname[len(common_path)+1:] + # + # output("\n %s ", relative_path) + + ######################################################################### + # Synthesis Options Summary && 8) Design Summary + ########################################################################### + # ========================================================================= + # * Synthesis Options Summary * + # ========================================================================= + # ---- Source Parameters + # Input File Name : "atlys_hdmi2usb-hdmi2usbsoc-atlys.prj" + # ... + # ... + # ========================================================================= + ########################################################################### + # ========================================================================= + # * Design Summary * + # ========================================================================= + # ... + # + # ========================================================================= + if line == DELIM_MAJOR: + summary_start = None + for bufferno, bufline in enumerate(linesbuffer): + if bufferno == 0: + continue + sbufline = bufline.strip() + if sbufline != DELIM_MAJOR: + continue + + summaryline = linesbuffer[bufferno+1].strip() + if not summaryline.startswith("*") or "Summary" not in summaryline: + break + summary_start = bufferno+2 + break + + if summary_start: + output("\n") + for i in range(summary_start, 0, -1): + output("%s\n", linesbuffer[i]) + + ######################################################################### + # 2) HDL Parsing + # ----------------------------------------------------------------------- + # Analyzing Verilog file "/home/tansell/foss/timvideos/hdmi2usb/HDMI2USB-misoc-firmware/build/misoc/extcores/lm32/submodule/rtl/lm32_dtlb.v" into library work + ANALYZING_VERILOG = "Analyzing Verilog" + if sline.startswith(ANALYZING_VERILOG): + output("\n\n%s ", shorten_path(sline)) + + # Parsing package . + # Parsing module . + # Parsing entity . + # Parsing architecture of entity . + PARSING = "Parsing " + if sline.startswith(PARSING): + if sline.startswith("Parsing VHDL"): + output("\n\n%s ", shorten_path(sline)) + else: + if sline.endswith('.'): + sline = sline[:-1] + output("\n %s ", shorten_path(sline)) + #bits = re.match(PARSING+"([^ ]+) .*<([^>]+)>\\.", sline) + #if bits: + # output("\nParsing %s %s ", bits.group(1), bits.group(2)) + + + ######################################################################### + # 3) HDL Elaboration + # ----------------------------------------------------------------------- + # Elaborating module <$unit_1>. + ELABORATION = "Elaborating " + if sline.startswith(ELABORATION): + if sline.endswith('.'): + sline = sline[:-1] + output("\n%s ", sline) + #bits = re.match(ELABORATION+"([^ ]+) .*?<([^>]+)>(.+from library <[^>]+>)?\\.", sline) + #if bits: + # output("\nElaborating %s %s ", bits.group(1), bits.group(2)) + + # Reading initialization file + READING_INIT = "Reading initialization file" + if sline.startswith(READING_INIT): + if sline.endswith('.'): + sline = sline[:-1] + output("\n %s ", sline.replace('\\"', '"')) + + ######################################################################### + # 4) HDL Synthesis + # ----------------------------------------------------------------------- + + # Synthesizing Unit . + # Related source file is "/home/tansell/foss/timvideos/hdmi2usb/HDMI2USB-misoc-firmware/build/misoc/build/atlys_hdmi2usb-hdmi2usbsoc-atlys.v". + # Set property "register_balancing = no" for signal . + # Set property "register_balancing = no" for signal . + # Set property "register_balancing = no" for signal . + SYNTH = "Synthesizing Unit" + if sline.startswith(SYNTH): + if sline.endswith('.'): + sline = sline[:-1] + output("\n%s ", sline) + + RELATED_SOURCE = "Related source file is" + if sline.startswith(RELATED_SOURCE): + if sline.endswith('.'): + sline = sline[:-1] + output("\n %s ", shorten_path(sline)) + + # Collect special blocks for output in summary. + # Found 128x24-bit dual-port RAM for signal . + SPECIALS = ["RAM"] + if sline.startswith("Found"): + special_found = False + for special in SPECIALS: + if special in sline: + special_found = True + break + if special_found: + found_specials.append(sline) + + # Summary: + # inferred 64 RAM(s). + # inferred 16 Multiplier(s). + # inferred 409 Adder/Subtractor(s). + # inferred 8597 D-type flip-flop(s). + # inferred 140 Comparator(s). + # inferred 1536 Multiplexer(s). + # inferred 6 Combinational logic shifter(s). + # inferred 2 Tristate(s). + # inferred 32 Finite State Machine(s). + # Unit synthesized. + SUMMARY = "Summary:" + SYTH = "synthesized." + if sline.endswith(SYTH): + summary_start = None + for bufferno, bufline in enumerate(linesbuffer): + sbufline = bufline.strip() + if sbufline.endswith(SUMMARY): + summary_start = bufferno + break + if summary_start: + output("\n Summary:\n") + for special in sorted(found_specials): + output(" %s\n", special) + found_specials = [] + output(" %s\n", "--") + for bufferno in range(summary_start-1, 0, -1): + sbufline = linesbuffer[bufferno].strip() + output(" %s\n", sbufline[0].upper()+sbufline[1:-1]) + output("\n") + + ######################################################################### + # 5) Advanced HDL Synthesis + # ----------------------------------------------------------------------- + SYNTH_ADV = "Synthesizing (advanced) Unit" + if sline.startswith(SYNTH_ADV): + if sline.endswith('.'): + sline = sline[:-1] + output("\n%s ", sline) + + ######################################################################### + # 6) Low Level Synthesis + # ----------------------------------------------------------------------- + + # Analyzing FSM for best encoding. + # Optimizing FSM on signal with user encoding. + if sline.startswith("Analyzing FSM") or sline.startswith("Optimizing FSM"): + if not fsm_triggered: + output("\nAnalyzing and optimizing FSMs ") + fsm_triggered = True + else: + output(".") + continue + + # Optimizing unit ... + # Optimizing unit ... + OPTIMIZING = "Optimizing unit" + if sline.startswith(OPTIMIZING): + if sline.endswith('.'): + sline = sline[:-1] + output("\n%s ", sline) + + # Processing Unit : + PROCESSING = "Processing Unit " + if sline.startswith(PROCESSING): + if sline.endswith(' :'): + sline = sline[:-2] + output("\n%s ", sline) + + # Final Macro Processing ... + if sline == "Final Macro Processing ...": + output("\n\n%s\n" % sline) + + + ######################################################################### + # 7) Partition Report + # ----------------------------------------------------------------------- + + # Nothing? + + ######################################################################### + # 8) Design Summary + # ----------------------------------------------------------------------- + + # If the line wasn't caught elsewhere, just output a dot. + if not keepalive_thread.output: + output(".") diff --git a/.travis/run-make-gateware-suppression.regex b/.travis/run-make-gateware-suppression.regex new file mode 100644 index 00000000..06ed8cd7 --- /dev/null +++ b/.travis/run-make-gateware-suppression.regex @@ -0,0 +1,2 @@ +# Line one +Blah.* From f64f11ab57999c445058cff6f1690b483ba852e6 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Mon, 14 Sep 2015 01:43:47 -0700 Subject: [PATCH 16/20] More work on the filter. --- .travis/run-make-gateware-filter.py | 122 ++++++++++++++++++++++++---- 1 file changed, 106 insertions(+), 16 deletions(-) diff --git a/.travis/run-make-gateware-filter.py b/.travis/run-make-gateware-filter.py index 1980b3c3..b323ed58 100755 --- a/.travis/run-make-gateware-filter.py +++ b/.travis/run-make-gateware-filter.py @@ -23,11 +23,14 @@ def output(s, *args, **kw): keepalive_thread.output = True if args: assert not kw - sys.stdout.write((s % args).encode('utf-8')) + data = (s % args).encode('utf-8') elif kw: - sys.stdout.write((s % kw).encode('utf-8')) + data = (s % kw).encode('utf-8') else: - sys.stdout.write(s.encode('utf-8')) + data = s.encode('utf-8') + + keepalive_thread.last_output = data + sys.stdout.write(data) # Flush every second if (time.time() - keepalive_thread.last_output_time) > 1: @@ -52,7 +55,7 @@ def run(self): keepalive_thread = KeepAliveThread() keepalive_thread.start() -BUFFER_SIZE=100 +BUFFER_SIZE=200 DELIM_MAJOR = "=========================================================================" ERROR = "*~"*35+"*" @@ -76,7 +79,7 @@ def shorten_path(line): found_specials = [] last_path = None -for lineno, rawline in enumerate(sys.stdin.readlines()): +for lineno, rawline in enumerate(sys.stdin.xreadlines()): log_file.write(rawline+'\n') log_file.flush() @@ -87,15 +90,16 @@ def shorten_path(line): linesbuffer.pop() if line.startswith("make"): - output('\n'+line+'\n') + output('\n%s ', line) continue if not sline: continue if line.startswith("ERROR:"): - output("\nError detected! - %s\n%s\n%s\n%s\n", line, ERROR, "\n".join(reversed(linesbuffer)), ERROR) - continue + linesbuffer.popleft() + output("\n\nError detected! - %s\n%s\n%s\n%s\n%s", line, ERROR, "\n".join(reversed(linesbuffer)), ERROR, rawline) + break # WARNING:HDLCompiler:1016 - "/home/tansell/foss/timvideos/hdmi2usb/HDMI2USB-misoc-firmware/build/misoc/build/atlys_hdmi2usb-hdmi2usbsoc-atlys.v" Line 24382: Port I_LOCK_O is not connected to this instance # WARNING:HDLCompiler:1016 - "/home/tansell/foss/timvideos/hdmi2usb/HDMI2USB-misoc-firmware/build/misoc/build/atlys_hdmi2usb-hdmi2usbsoc-atlys.v" Line 24475: Port IOCLK is not connected to this instance @@ -108,6 +112,17 @@ def shorten_path(line): elif line.startswith("INFO:"): output("i") continue + + # Different tools start with the following + # Release 14.7 - Map P.20131013 (lin64) + # Copyright (c) 1995-2013 Xilinx, Inc. All rights reserved. + if sline.startswith("Copyright (c)"): + output("\n\n\n%s\n# %-66s #\n%s\n", "#"*70, linesbuffer[1], "#"*70) + continue + + ###################################################################### + # Release 14.7 - xst P.20131013 (lin64) # + ###################################################################### # Output a header which looks like this unless it is a summary header # ========================================================================= @@ -119,7 +134,7 @@ def shorten_path(line): if "Summary" in linesbuffer[1]: continue else: - output("\n\n%s\n%s\n%s\n", linesbuffer[0], linesbuffer[1], linesbuffer[2]) + output("\n\n%s\n* %-66s *\n%s\n", '*'*70, linesbuffer[1][2:-2].strip(), '*'*70) continue # When we see a filename, output it. Examples; @@ -174,9 +189,18 @@ def shorten_path(line): break if summary_start: - output("\n") + output("\n\n") for i in range(summary_start, 0, -1): - output("%s\n", linesbuffer[i]) + sbufline = linesbuffer[i].strip() + if sbufline == DELIM_MAJOR: + output("%s\n", "*"*70) + elif sbufline.startswith('*'): + output("* %-66s *\n", sbufline[2:-2].strip()) + else: + if linesbuffer[i].startswith('#'): + output("%s\n", linesbuffer[i][1:]) + else: + output("%s\n", linesbuffer[i]) ######################################################################### # 2) HDL Parsing @@ -184,7 +208,7 @@ def shorten_path(line): # Analyzing Verilog file "/home/tansell/foss/timvideos/hdmi2usb/HDMI2USB-misoc-firmware/build/misoc/extcores/lm32/submodule/rtl/lm32_dtlb.v" into library work ANALYZING_VERILOG = "Analyzing Verilog" if sline.startswith(ANALYZING_VERILOG): - output("\n\n%s ", shorten_path(sline)) + output("\n%s ", shorten_path(sline)) # Parsing package . # Parsing module . @@ -193,7 +217,7 @@ def shorten_path(line): PARSING = "Parsing " if sline.startswith(PARSING): if sline.startswith("Parsing VHDL"): - output("\n\n%s ", shorten_path(sline)) + output("\n%s ", shorten_path(sline)) else: if sline.endswith('.'): sline = sline[:-1] @@ -280,12 +304,12 @@ def shorten_path(line): output("\n Summary:\n") for special in sorted(found_specials): output(" %s\n", special) + if found_specials: + output(" %s\n", "--") found_specials = [] - output(" %s\n", "--") for bufferno in range(summary_start-1, 0, -1): sbufline = linesbuffer[bufferno].strip() output(" %s\n", sbufline[0].upper()+sbufline[1:-1]) - output("\n") ######################################################################### # 5) Advanced HDL Synthesis @@ -327,7 +351,7 @@ def shorten_path(line): # Final Macro Processing ... if sline == "Final Macro Processing ...": - output("\n\n%s\n" % sline) + output("\n%s" % sline) ######################################################################### @@ -340,6 +364,72 @@ def shorten_path(line): # 8) Design Summary # ----------------------------------------------------------------------- + ###################################################################### + # Release 14.7 - ngdbuild P.20131013 (lin64) # + ###################################################################### + + ###################################################################### + # Release 14.7 - Map P.20131013 (lin64) # + ###################################################################### + + if sline.startswith("Peak Memory Usage"): + summary_start = None + for bufferno, bufline in enumerate(linesbuffer): + sbufline = bufline.strip() + if sbufline.startswith("Design Summary:"): + summary_start = bufferno + break + if summary_start: + output("""\n +********************************************************************** +* Design Summary * +********************************************************************** +""") + for bufferno in range(summary_start-1, 0, -1): + bufline = linesbuffer[bufferno] + output("%s\n", bufline) + output("%s\n", "*" * 70) + + ###################################################################### + # Release 14.7 - par P.20131013 (lin64) # + ###################################################################### + + if sline.startswith("Starting initial Timing Analysis"): + summary_start = None + for bufferno, bufline in enumerate(linesbuffer): + sbufline = bufline.strip() + if sbufline.startswith("Device Utilization Summary:"): + summary_start = bufferno + break + if summary_start: + output("""\n +********************************************************************** +* Device Utilization Summary * +********************************************************************** +""") + for bufferno in range(summary_start-1, 0, -1): + bufline = linesbuffer[bufferno] + output("%s\n", bufline) + output("%s\n", "*" * 70) + + + if sline.startswith("Phase"): + if "REAL time:" in sline and not "unrouted": + phase, rtime = sline.split("REAL time:") + output(" (completed in %s)\n", rtime.strip()) + else: + bits = sline.split() + if keepalive_thread.last_output[-1] != '\n': + output('\n') + output("%5s %-5s - %s ", bits[0], bits[1], " ".join(bits[2:])) + + # Saving bit stream in + if sline.startswith("Saving bit stream in"): + output("\n%s", sline) + # If the line wasn't caught elsewhere, just output a dot. if not keepalive_thread.output: output(".") + +for lineno, rawline in enumerate(sys.stdin.xreadlines()): + output(rawline) From f8feef801d6fb8eec481c2905b8bb8023f9052ce Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Mon, 14 Sep 2015 02:52:09 -0700 Subject: [PATCH 17/20] Make a little spinner. --- .travis/run-make-gateware-filter.py | 60 +++++++++++++++++++---------- 1 file changed, 39 insertions(+), 21 deletions(-) diff --git a/.travis/run-make-gateware-filter.py b/.travis/run-make-gateware-filter.py index b323ed58..34a5d81e 100755 --- a/.travis/run-make-gateware-filter.py +++ b/.travis/run-make-gateware-filter.py @@ -13,43 +13,58 @@ log_file = open(sys.argv[1], 'w') # Suppressions for warning / info messages -suppressions = [x.strip() for x in open(sys.argv[2], 'r').readlines() if not x.startswith('#')] -pprint.pprint(suppressions) -suppressions = [re.compile(x) for x in suppressions] +#suppressions = [x.strip() for x in open(sys.argv[2], 'r').readlines() if not x.startswith('#')] +#suppressions = [re.compile(x) for x in suppressions] top_path = os.path.normpath(os.getcwd()) def output(s, *args, **kw): - keepalive_thread.output = True - if args: - assert not kw - data = (s % args).encode('utf-8') - elif kw: - data = (s % kw).encode('utf-8') - else: - data = s.encode('utf-8') - - keepalive_thread.last_output = data - sys.stdout.write(data) + with keepalive_thread.lock: + if "before_next_output" in kw: + before_next_output = kw["before_next_output"] + del kw["before_next_output"] + else: + before_next_output = "" + + keepalive_thread.output = True + if args: + assert not kw + data = (s % args).encode('utf-8') + elif kw: + data = (s % kw).encode('utf-8') + else: + data = s.encode('utf-8') - # Flush every second - if (time.time() - keepalive_thread.last_output_time) > 1: - sys.stdout.flush() + if data: + sys.stdout.write(keepalive_thread.before_next_output) + keepalive_thread.before_next_output = before_next_output + sys.stdout.flush() - keepalive_thread.last_output_time = time.time() + sys.stdout.write(data) + keepalive_thread.last_output_time = time.time() + keepalive_thread.last_output = data + sys.stdout.flush() class KeepAliveThread(threading.Thread): + ROTATE = [" - ", " \\ ", " | ", " / "] + def __init__(self): threading.Thread.__init__(self) + self.lock = threading.RLock() self.daemon = True + + self.pos = 0 self.output = False + self.before_next_output = "" self.last_output_time = time.time() + self.last_output = "" def run(self): while True: - if (time.time() - self.last_output_time) > 30: - output(u"\U0001F436") + if (time.time() - self.last_output_time) > 1: + output(self.ROTATE[self.pos], before_next_output="\b\b\b") + self.pos = (self.pos + 1) % len(self.ROTATE) time.sleep(1) keepalive_thread = KeepAliveThread() @@ -80,7 +95,7 @@ def shorten_path(line): last_path = None for lineno, rawline in enumerate(sys.stdin.xreadlines()): - log_file.write(rawline+'\n') + log_file.write(rawline) log_file.flush() line = rawline.strip('\n\r') @@ -433,3 +448,6 @@ def shorten_path(line): for lineno, rawline in enumerate(sys.stdin.xreadlines()): output(rawline) + +output("\n\n") +output("Raw output saved in %r\n", sys.argv[1]) From 487378683f16d6d987dedf8d73b56bfd59a99fcb Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Mon, 14 Sep 2015 02:52:21 -0700 Subject: [PATCH 18/20] Integrate the filter into the Makefile. --- .travis/run.sh | 2 +- Makefile | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.travis/run.sh b/.travis/run.sh index eef08cd8..f0f0b69a 100644 --- a/.travis/run.sh +++ b/.travis/run.sh @@ -58,7 +58,7 @@ for BOARD in $BOARDS; do if [ $HAVE_XILINX_ISE -eq 0 ]; then echo "Skipping gateware" else - BOARD=$BOARD TARGET=$TARGET make gateware + FILTER=$PWD/.travis/run-make-gateware-filter.py BOARD=$BOARD TARGET=$TARGET make gateware fi if [ ! -z "$PROGS" ]; then diff --git a/Makefile b/Makefile index afaf5cbd..8149d433 100644 --- a/Makefile +++ b/Makefile @@ -3,11 +3,15 @@ MSCDIR ?= build/misoc PROG ?= impact SERIAL ?= /dev/ttyVIZ0 TARGET ?= hdmi2usb +FILTER ?= tee HDMI2USBDIR = ../.. PYTHON = python3 DATE = `date +%Y_%m_%d` +# We use the special PIPESTATUS which is bash only below. +SHELL := /bin/bash + CMD = $(PYTHON) \ make.py \ -X $(HDMI2USBDIR) \ @@ -50,7 +54,8 @@ load: load-gateware load-$(TARGET) gateware: gateware-$(TARGET) cd $(MSCDIR) && $(CMD) --csr_csv $(HDMI2USBDIR)/test/csr.csv clean cp hdl/encoder/vhdl/header.hex $(MSCDIR)/build/header.hex - cd $(MSCDIR) && $(CMD) --csr_csv $(HDMI2USBDIR)/test/csr.csv build-csr-csv build-bitstream + cd $(MSCDIR) && $(CMD) --csr_csv $(HDMI2USBDIR)/test/csr.csv build-csr-csv build-bitstream \ + | $(FILTER) $(PWD)/build/output.$(DATE).log; (exit $${PIPESTATUS[0]}) load-gateware: cd $(MSCDIR) && $(CMD) load-bitstream From 539460f71c63dee11500939b23d1cf3db5d8b9e7 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Mon, 14 Sep 2015 04:32:33 -0700 Subject: [PATCH 19/20] Fixing small typo. --- .travis/run-make-gateware-filter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis/run-make-gateware-filter.py b/.travis/run-make-gateware-filter.py index 34a5d81e..f61bd94a 100755 --- a/.travis/run-make-gateware-filter.py +++ b/.travis/run-make-gateware-filter.py @@ -429,7 +429,7 @@ def shorten_path(line): if sline.startswith("Phase"): - if "REAL time:" in sline and not "unrouted": + if "REAL time:" in sline and not "unrouted" in sline: phase, rtime = sline.split("REAL time:") output(" (completed in %s)\n", rtime.strip()) else: From 5b7006360d762fc5125647b814631fadd4e983de Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Thu, 17 Sep 2015 10:24:17 +1000 Subject: [PATCH 20/20] Removing allow fail. --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 395cd69b..e9559e11 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,10 +14,6 @@ env: - BOARD=opsis TARGET=base - BOARD=opsis TARGET=hdmi2usb -matrix: - allow_failures: - - env: BOARD=opsis TARGET=hdmi2usb - install: - wget -q -O- https://raw.githubusercontent.com/mithro/travis-trusty/master/setup.sh | bash - chmod a+rx $PWD/.travis/*.sh