Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use openocd by default instead of fpgalink #122

Merged
merged 9 commits into from
Nov 1, 2015
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ sudo: false
addons:
apt:
packages:
- realpath
- build-essential
- fxload
- gnupg
- libftdi-dev
- libreadline-dev
- libusb-1.0-0-dev
- python-yaml
- fxload
- realpath

env:
matrix:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export PYTHONHASHSEED=0

BOARD ?= atlys
MSCDIR ?= third_party/misoc
PROG ?= impact
PROG ?= openocd
TARGET ?= hdmi2usb
FILTER ?= tee

Expand Down
2 changes: 1 addition & 1 deletion firmware/fx2/download.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -e

DEVS=$(lsusb|grep -E '(04b4|1d50|fb9a|1443)' |sed 's/:.*//;s/Bus //;s/Device //;s/ /\//')
DEVS=$(lsusb|grep -E '(16c0|04b4|1d50|fb9a|1443)' |sed 's/:.*//;s/Bus //;s/Device //;s/ /\//')

if [ -z "$1" ]; then
echo "$0: usage: $0 <file>"
Expand Down
15 changes: 13 additions & 2 deletions platforms/atlys.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

from mibuild.generic_platform import *
from mibuild.xilinx import XilinxPlatform
from mibuild.xilinx import XC3SProg, iMPACT, Adept, UrJTAG

from mibuild.openocd import OpenOCD
# Alternative programmers
from mibuild.xilinx import Adept
from mibuild.xilinx import UrJTAG
from mibuild.xilinx import XC3SProg
from mibuild.xilinx import iMPACT


# There appear to be 4 x LTC2481C on the U1-SCL / U1-SDA lines connected to the Cypress

Expand Down Expand Up @@ -580,7 +587,11 @@ def __init__(self, programmer="xc3sprog"):
self.add_platform_command("""CONFIG VCCAUX="2.5";""")

def create_programmer(self):
if self.programmer == "xc3sprog":
# Preferred programmer - Needs ixo-usb-jtag and latest openocd.
if self.programmer == "openocd":
return OpenOCD(config="board/digilent_atlys.cfg")
# Alternative programmers - not regularly tested.
elif self.programmer == "xc3sprog":
return XC3SProg("jtaghs1_fast", "bscan_spi_digilent_atlys.bit")
elif self.programmer == "impact":
return iMPACT()
Expand Down
20 changes: 11 additions & 9 deletions platforms/opsis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

from mibuild.generic_platform import *
from mibuild.xilinx import XilinxPlatform
from mibuild.xilinx import XC3SProg, iMPACT, Adept, UrJTAG

from mibuild.openocd import OpenOCD
from mibuild.xilinx import UrJTAG
from mibuild.xilinx import iMPACT

_io = [
## FXO-HC536R - component U17
Expand Down Expand Up @@ -329,7 +332,7 @@ class Platform(XilinxPlatform):
default_clk_period = 10.0
hdmi_infos = _hdmi_infos

def __init__(self, programmer="xc3sprog"):
def __init__(self, programmer="openocd"):
# XC6SLX45T-3FGG484C
XilinxPlatform.__init__(self, "xc6slx45t-fgg484-3", _io, _connectors)

Expand All @@ -351,15 +354,14 @@ def __init__(self, programmer="xc3sprog"):
self.add_platform_command("""CONFIG VCCAUX="3.3";""")

def create_programmer(self):
if self.programmer == "xc3sprog":
return XC3SProg("jtaghs1_fast", "bscan_spi_numato_opsis.bit")
# Preferred programmer - Needs ixo-usb-jtag and latest openocd.
if self.programmer == "openocd":
return OpenOCD(config="board/numato_opsis.cfg")
# Alternative programmers - not regularly tested.
elif self.programmer == "urjtag":
return UrJTAG(cable="USBBlaster")
elif self.programmer == "impact":
return iMPACT()
elif self.programmer == "fpgalink":
from mibuild.fpgalink_programmer import FPGALink
return FPGALink("1443:0007")
elif self.programmer == "urjtag":
return UrJTAG(cable="USBBlaster", pld="spartan-6")
else:
raise ValueError("{} programmer is not supported".format(self.programmer))

Expand Down
14 changes: 10 additions & 4 deletions scripts/52-hdmi2usb.rules
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# The ENV{ID_MM_DEVICE_IGNORE}="1" part will make modem-manager ignore the
# device.

# Grant permission to makestuff usb devices.
ATTR{idVendor}=="1d50", MODE:="666"
ATTR{idVendor}=="1d50", MODE:="666", ENV{ID_MM_DEVICE_IGNORE}="1"

# Grant permissions to hdmi2usb usb devices.
ATTR{idVendor}=="fb9a", MODE:="666"
ATTR{idVendor}=="fb9a", MODE:="666", ENV{ID_MM_DEVICE_IGNORE}="1"

# Grant permissions to unconfigured cypress chips.
ATTR{idVendor}=="04b4", MODE:="666"
ATTR{idVendor}=="04b4", MODE:="666", ENV{ID_MM_DEVICE_IGNORE}="1"

# Grant permissions to Digilent Development board JTAG
ATTR{idVendor}=="1443", MODE:="666"
ATTR{idVendor}=="1443", MODE:="666", ENV{ID_MM_DEVICE_IGNORE}="1"

# Grant permissions to Numato usb devices.
ATTR{idVendor}=="2a19", MODE:="666", ENV{ID_MM_DEVICE_IGNORE}="1"
3 changes: 2 additions & 1 deletion scripts/get-env-root.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ apt-get install -y iverilog gtkwave
# Nothing needed

# libfpgalink
sudo apt-get install -y libreadline-dev libusb-1.0-0-dev python-yaml sdcc fxload
sudo apt-get install -y libreadline-dev libusb-1.0-0-dev libftdi-dev python-yaml fxload

# Load custom udev rules
(
Expand All @@ -43,3 +43,4 @@ sudo apt-get install -y software-properties-common
sudo add-apt-repository -y ppa:timvideos/fpga-support
sudo apt-get update
sudo apt-get install -y vizzini-dkms
sudo apt-get install -y ixo-usb-jtag
95 changes: 68 additions & 27 deletions scripts/get-env.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
#!/bin/bash

CALLED=$_
[[ "${BASH_SOURCE[0]}" != "${0}" ]] && SOURCED=1 || SOURCED=0

SETUP_SRC=$(realpath ${BASH_SOURCE[0]})
SETUP_DIR=$(dirname $SETUP_SRC)
TOP_DIR=$(realpath $SETUP_DIR/..)
BUILD_DIR=$TOP_DIR/build
THIRD_DIR=$TOP_DIR/third_party

set -x
set -e

if [ $SOURCED = 1 ]; then
echo "You must run this script, rather then try to source it."
echo "$SETUP_SRC"
return
fi

echo " This script is: $SETUP_SRC"
echo " Firmware directory: $TOP_DIR"
echo " Build directory is: $BUILD_DIR"
Expand All @@ -26,14 +33,12 @@ fi
# 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
Expand Down Expand Up @@ -84,7 +89,36 @@ else
fi
echo " Xilinx directory is: $XILINX_DIR/opt/Xilinx/"

# gcc+binutils for the target
function check_version {
TOOL=$1
VERSION=$2
if $TOOL --version 2>&1 | grep -q $VERSION > /dev/null; then
echo "$TOOL found at $VERSION"
return 0
else
$TOOL --version
echo "$TOOL (version $VERSION) *NOT* found"
echo "Please try running the $SETUP_DIR/get-env.sh script again."
return 1
fi
}

function check_import {
MODULE=$1
if python3 -c "import $MODULE"; then
echo "$MODULE found"
return 0
else
echo "$MODULE *NOT* found!"
echo "Please try running the $SETUP_DIR/get-env.sh script again."
return 1
fi
}

# Install and setup conda for downloading packages
echo ""
echo "Install modules from conda"
echo "---------------------------"
CONDA_DIR=$BUILD_DIR/conda
export PATH=$CONDA_DIR/bin:$PATH
(
Expand All @@ -97,12 +131,36 @@ export PATH=$CONDA_DIR/bin:$PATH
conda update -q conda
fi
conda config --add channels timvideos
)

# binutils for the target
(
conda install binutils-lm32-elf
)
check_version lm32-elf-ld 2.25.1

# gcc+binutils for the target
(
conda install gcc-lm32-elf
)
check_version lm32-elf-gcc 4.9.3

# sdcc for compiling Cypress FX2 firmware
(
conda install sdcc
)
check_version sdcc 3.5.0

# openocd for programming via Cypress FX2
(
conda install openocd
)
check_version openocd 0.10.0-dev-00044-g3edb157

# git submodules
echo ""
echo "Updating git submodules"
echo "-----------------------"
(
cd $TOP_DIR
git submodule update --recursive --init
Expand All @@ -119,7 +177,7 @@ MIGEN_DIR=$THIRD_DIR/migen
#sudo make install
)
export PYTHONPATH=$MIGEN_DIR:$PYTHONPATH
python3 -c "import migen"
check_import migen

# misoc
MISOC_DIR=$THIRD_DIR/misoc
Expand All @@ -129,8 +187,8 @@ MISOC_DIR=$THIRD_DIR/misoc
make
)
export PYTHONPATH=$MISOC_DIR:$PYTHONPATH
$MISOC_DIR/tools/flterm --help
python3 -c "import misoclib"
$MISOC_DIR/tools/flterm --help 2> /dev/null
check_import misoclib

# liteeth
LITEETH_DIR=$THIRD_DIR/liteeth
Expand All @@ -139,26 +197,9 @@ LITEETH_DIR=$THIRD_DIR/liteeth
true
)
export PYTHONPATH=$LITEETH_DIR:$PYTHONPATH
python3 -c "import liteeth"

# libfpgalink
MAKESTUFF_DIR=$BUILD_DIR/makestuff
(
if [ ! -d $MAKESTUFF_DIR ]; then
cd $BUILD_DIR
wget -qO- http://tiny.cc/msbil | tar zxf -
cd makestuff/libs
../scripts/msget.sh makestuff/libfpgalink
cd libfpgalink
else
cd $MAKESTUFF_DIR
cd libs/libfpgalink
fi
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
python3 -c "import fl"
check_import liteeth

echo "-----------------------"
echo ""
echo "Completed. To load environment:"
echo "source HDMI2USB-misoc-firmware/scripts/setup-env.sh"
Loading