2
0
mirror of https://github.com/m-labs/artiq.git synced 2024-12-28 20:53:35 +08:00

artiq_flash: add support for kc705

This commit is contained in:
Yann Sionneau 2015-04-10 14:00:46 +02:00 committed by Sebastien Bourdeauducq
parent a50f2c20ff
commit 8a3be4eca0
3 changed files with 86 additions and 17 deletions

View File

@ -1,9 +1,11 @@
#!/bin/bash
ARTIQ_PREFIX=$(python3 -c "import artiq; print(artiq.__path__[0])")
BIN_PREFIX=$ARTIQ_PREFIX/binaries
while getopts "bBrh" opt
# Default is ppro
BOARD=ppro
while getopts "bBrht:d:" opt
do
case $opt in
b)
@ -15,22 +17,87 @@ do
r)
FLASH_RUNTIME=1
;;
t)
if [ "$OPTARG" == "kc705" ]
then
BOARD=kc705
elif [ "$OPTARG" == "ppro" ]
then
BOARD=ppro
else
echo "Supported targets (-t option) are: kc705 and ppro"
exit 1
fi
;;
d)
if [ -d $OPTARG ]
then
BIN_PATH=$OPTARG
else
echo "You specified a non-existing directory: $OPTARG"
exit 1
fi
;;
*)
echo "ARTIQ flashing tool"
echo ""
echo "To flash everything, do not use any command line option."
echo "To flash everything, do not use any of the -b|-B|-r option."
echo ""
echo "usage: $0 [-b] [-B] [-r] [-h]"
echo "usage: $0 [-b] [-B] [-r] [-h] [-t kc705|ppro] [-d path]"
echo "-b Flash bitstream"
echo "-B Flash BIOS"
echo "-r Flash ARTIQ runtime"
echo "-h Show this help message"
echo "-t Target (kc705 or ppro, default is: ppro)"
echo "-d Directory containing the binaries to be flashed"
exit 1
;;
esac
done
if [ -z $@ ]
if ! [ -z "$BIN_PATH" ]
then
BIN_PREFIX=$BIN_PATH
fi
if [ "$BOARD" == "ppro" ]
then
UDEV_RULES=99-ppro.rules
BITSTREAM=artiq_ppro-up-papilio_pro.bin
CABLE=papilio
PROXY=bscan_spi_lx9_papilio.bit
BIN_PREFIX=$ARTIQ_PREFIX/binaries/ppro
PROXY_PATH=$BIN_PREFIX
BIOS_ADDR=0x60000
RUNTIME_ADDR=0x70000
elif [ "$BOARD" == "kc705" ]
then
UDEV_RULES=99-kc705.rules
BITSTREAM=artiq_kc705-artiqsocbasic-kc705.bit
CABLE=jtaghs1_fast
PROXY=bscan_spi_kc705.bit
BIN_PREFIX=$ARTIQ_PREFIX/binaries/kc705
BIOS_ADDR=0xaf0000
RUNTIME_ADDR=0xb00000
if [ -f $HOME/.migen/$PROXY ]
then
PROXY_PATH=$HOME/.migen/
elif [ -f /usr/local/share/migen/$PROXY ]
then
PROXY_PATH=/usr/local/share/migen/
elif [ -f /usr/share/migen/$PROXY ]
then
PROXY_PATH=/usr/share/migen/
else
echo "KC705 flash proxy ($PROXY) not found."
echo "Please build it from https://github.com/m-labs/bscan_spi_kc705"
echo "and put it in ~/.migen or /usr/local/share/migen or /usr/share/migen"
exit 1
fi
fi
# Check if neither of -b|-B|-r have been used
if [ -z "$FLASH_RUNTIME" -a -z "$FLASH_BIOS" -a -z "$FLASH_BITSTREAM" ]
then
FLASH_RUNTIME=1
FLASH_BIOS=1
@ -42,12 +109,12 @@ check_return() {
exit
}
xc3sprog -c papilio -R 2&>1 > /dev/null
xc3sprog -c $CABLE -R 2&>1 > /dev/null
if [ "$?" != "0" ]
then
echo "Flashing failed because it seems you do not have permission to access the USB device."
echo "To fix this you might want to add a udev rule by doing:"
echo "$ sudo cp $ARTIQ_PREFIX/misc/99-ppro.rules /etc/udev/rules.d"
echo "$ sudo cp $ARTIQ_PREFIX/misc/$UDEV_RULES /etc/udev/rules.d"
echo "Then unplug/replug your device and try flashing again"
exit
fi
@ -57,19 +124,19 @@ trap check_return ERR
if [ "${FLASH_BITSTREAM}" == "1" ]
then
echo "Flashing FPGA bitstream..."
xc3sprog -v -c papilio -I$BIN_PREFIX/bscan_spi_lx9_papilio.bit $BIN_PREFIX/artiqminisoc-papilio_pro.bin:w:0x0:BIN
xc3sprog -v -c $CABLE -I$PROXY_PATH/$PROXY $BIN_PREFIX/$BITSTREAM:w:0x0:BIN
fi
if [ "${FLASH_BIOS}" == "1" ]
then
echo "Flashing BIOS..."
xc3sprog -v -c papilio -I$BIN_PREFIX/bscan_spi_lx9_papilio.bit $BIN_PREFIX/bios.bin:w:0x60000:BIN
xc3sprog -v -c $CABLE -I$PROXY_PATH/$PROXY $BIN_PREFIX/bios.bin:w:$BIOS_ADDR:BIN
fi
if [ "${FLASH_RUNTIME}" == "1" ]
then
echo "Flashing ARTIQ runtime..."
xc3sprog -v -c papilio -I$BIN_PREFIX/bscan_spi_lx9_papilio.bit $BIN_PREFIX/runtime.fbi:w:0x70000:BIN
xc3sprog -v -c $CABLE -I$PROXY_PATH/$PROXY $BIN_PREFIX/runtime.fbi:w:$RUNTIME_ADDR:BIN
fi
echo "Done."
xc3sprog -v -c papilio -R 2&>1 > /dev/null
xc3sprog -v -c $CABLE -R 2&>1 > /dev/null

View File

@ -8,12 +8,12 @@ cd $SRC_DIR/misoc; python make.py -X ../soc -t artiq_ppro build-headers build-bi
make -C soc/runtime runtime.fbi
cd $SRC_DIR/misoc; python make.py -X $SRC_DIR/soc -t artiq_ppro build-bitstream; cd -
ARTIQ_PREFIX=$PREFIX/lib/python3.4/site-packages/artiq
BIN_PREFIX=$ARTIQ_PREFIX/binaries
BIN_PREFIX=$ARTIQ_PREFIX/binaries/
mkdir -p $ARTIQ_PREFIX/misc
cp misc/99-ppro.rules $ARTIQ_PREFIX/misc/
mkdir -p $BIN_PREFIX
cp $SRC_DIR/misoc/build/artiq_ppro-up-papilio_pro.bin $BIN_PREFIX/
cp $SRC_DIR/misoc/software/bios/bios.bin $BIN_PREFIX/
cp soc/runtime/runtime.fbi $BIN_PREFIX/
mkdir -p $BIN_PREFIX/ppro $BIN_PREFIX/kc705
cp $SRC_DIR/misoc/build/artiq_ppro-up-papilio_pro.bin $BIN_PREFIX/ppro
cp $SRC_DIR/misoc/software/bios/bios.bin $BIN_PREFIX/ppro
cp soc/runtime/runtime.fbi $BIN_PREFIX/ppro
cp artiq/frontend/artiq_flash.sh $PREFIX/bin
cp Papilio-Loader/xc3sprog/trunk/bscan_spi/bscan_spi_lx9_papilio.bit $BIN_PREFIX/
cp Papilio-Loader/xc3sprog/trunk/bscan_spi/bscan_spi_lx9_papilio.bit $BIN_PREFIX/ppro

2
misc/99-kc705.rules Normal file
View File

@ -0,0 +1,2 @@
ATTR{idVendor}=="1443", MODE:="666"
ACTION=="add", ATTR{idVendor}=="0403", ATTR{manufacturer}=="Digilent", MODE:="666"