From e7be00baa8113c0222b277fdbe99be0b72026be2 Mon Sep 17 00:00:00 2001 From: Yann Sionneau Date: Tue, 3 Mar 2015 17:23:34 +0100 Subject: [PATCH] Add support for automatic build and upload of dev conda artiq packages to binstar by travis-ci - SoC+BIOS are also built and integrated in the conda package - artiq_flash.sh script is embedded to allow flashing ppro board --- .travis.yml | 19 +++++---- .travis/get-anaconda.sh | 2 + .travis/get-misoc.sh | 6 --- artiq/frontend/artiq_flash.sh | 75 +++++++++++++++++++++++++++++++++++ conda/artiq/build.sh | 16 ++++++++ conda/artiq/meta.yaml | 7 ++-- misc/99-ppro.rules | 1 + 7 files changed, 107 insertions(+), 19 deletions(-) delete mode 100755 .travis/get-misoc.sh create mode 100755 artiq/frontend/artiq_flash.sh create mode 100644 misc/99-ppro.rules diff --git a/.travis.yml b/.travis.yml index 2d7615dc3..cf501b63c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,28 +8,27 @@ env: - CC=gcc-4.7 - CXX=g++-4.7 - ARTIQ_NO_HARDWARE=1 - - BUILD_SOC=0 + - BUILD_SOC=1 - secure: "DUk/Ihg8KbbzEgPF0qrHqlxU8e8eET9i/BtzNvFddIGX4HP/P2qz0nk3cVkmjuWhqJXSbC22RdKME9qqPzw6fJwJ6dpJ3OR6dDmSd7rewavq+niwxu52PVa+yK8mL4yf1terM7QQ5tIRf+yUL9qGKrZ2xyvEuRit6d4cFep43Ws=" before_install: - - if echo "$TRAVIS_COMMIT_MSG" | grep -q "\[soc\]"; then BUILD_SOC=1; fi - if [ $TRAVIS_PULL_REQUEST != false ]; then BUILD_SOC=0; fi - ./.travis/get-toolchain.sh - if [ $BUILD_SOC -ne 0 ]; then ./.travis/get-xilinx.sh; fi - - ./.travis/get-anaconda.sh pip coverage numpy scipy sphinx h5py pyserial dateutil + - ./.travis/get-anaconda.sh pip coverage binstar - source $HOME/miniconda/bin/activate py34 - - ./.travis/get-misoc.sh - - pip install --src . -e 'git+https://github.com/nist-ionstorage/llvmlite.git@artiq#egg=llvmlite' + - sudo apt-get install --force-yes -y iverilog - pip install coveralls + - conda install migen install: - - pip install -e . + - conda build conda/artiq + - conda install $HOME/miniconda/conda-bld/linux-64/artiq-*.tar.bz2 script: - coverage run --source=artiq setup.py test - make -C doc/manual html - - cd misoc; python make.py -X ../soc -t artiq_ppro build-headers build-bios; cd .. - - make -C soc/runtime - - if [ $BUILD_SOC -ne 0 ]; then cd misoc; python make.py -X ../soc -t artiq_ppro build-bitstream; cd ..; fi after_success: - coveralls + - binstar login --hostname $(hostname) --username $binstar_login --password $binstar_password + - binstar upload --user $binstar_login --channel dev --force $HOME/miniconda/conda-bld/linux-64/artiq-*.tar.bz2 + - coveralls notifications: email: false irc: diff --git a/.travis/get-anaconda.sh b/.travis/get-anaconda.sh index 687efdbf8..7894d0dc4 100755 --- a/.travis/get-anaconda.sh +++ b/.travis/get-anaconda.sh @@ -5,5 +5,7 @@ bash miniconda.sh -b -p $HOME/miniconda hash -r conda config --set always_yes yes --set changeps1 no conda update -q conda +conda install conda-build jinja2 conda info -a conda create -q -n py34 python=$TRAVIS_PYTHON_VERSION $@ +conda config --add channels fallen diff --git a/.travis/get-misoc.sh b/.travis/get-misoc.sh deleted file mode 100755 index 08bb61362..000000000 --- a/.travis/get-misoc.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -sudo apt-get install --force-yes -y iverilog -pip install --src . -e 'git+https://github.com/m-labs/migen.git@master#egg=migen' -mkdir vpi && iverilog-vpi --name=vpi/migensim migen/vpi/main.c migen/vpi/ipc.c -git clone --recursive https://github.com/m-labs/misoc diff --git a/artiq/frontend/artiq_flash.sh b/artiq/frontend/artiq_flash.sh new file mode 100755 index 000000000..f184814c3 --- /dev/null +++ b/artiq/frontend/artiq_flash.sh @@ -0,0 +1,75 @@ +#!/bin/bash + +ARTIQ_PREFIX=$(python3 -c "import artiq; print(artiq.__path__[0])") +BIN_PREFIX=$ARTIQ_PREFIX/binaries + +while getopts "bBrh" opt +do + case $opt in + b) + FLASH_BITSTREAM=1 + ;; + B) + FLASH_BIOS=1 + ;; + r) + FLASH_RUNTIME=1 + ;; + *) + echo "ARTIQ flashing tool" + echo "" + echo "To flash everything, do not use any command line option." + echo "" + echo "usage: $0 [-b] [-B] [-r] [-h]" + echo "-b Flash bitstream" + echo "-B Flash BIOS" + echo "-r Flash ARTIQ runtime" + echo "-h Show this help message" + exit 1 + ;; + esac +done + +if [ -z $@ ] +then + FLASH_RUNTIME=1 + FLASH_BIOS=1 + FLASH_BITSTREAM=1 +fi + +check_return() { + echo "Flashing failed, you may want to re-run the flashing tool." + exit +} + +xc3sprog -c papilio -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 "Then unplug/replug your device and try flashing again" + exit +fi + +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 +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 +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 +fi +echo "Done." +xc3sprog -v -c papilio -R 2&>1 > /dev/null diff --git a/conda/artiq/build.sh b/conda/artiq/build.sh index 5b5c44fa8..299280b44 100755 --- a/conda/artiq/build.sh +++ b/conda/artiq/build.sh @@ -1,3 +1,19 @@ #!/bin/bash ARTIQ_GUI=1 $PYTHON setup.py install --single-version-externally-managed --record=record.txt +git clone --recursive https://github.com/m-labs/misoc +git clone https://github.com/GadgetFactory/Papilio-Loader +export MSCDIR=$SRC_DIR/misoc +cd $SRC_DIR/misoc; python make.py -X ../soc -t artiq_ppro build-headers build-bios; cd - +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 +mkdir -p $ARTIQ_PREFIX/misc +cp misc/99-ppro.rules $ARTIQ_PREFIX/misc/ +mkdir -p $BIN_PREFIX +cp $SRC_DIR/misoc/build/artiqminisoc-papilio_pro.bin $BIN_PREFIX/ +cp $SRC_DIR/misoc/software/bios/bios.bin $BIN_PREFIX/ +cp soc/runtime/runtime.fbi $BIN_PREFIX/ +cp artiq/frontend/artiq_flash.sh $PREFIX/bin +cp Papilio-Loader/xc3sprog/trunk/bscan_spi/bscan_spi_lx9_papilio.bit $BIN_PREFIX/ diff --git a/conda/artiq/meta.yaml b/conda/artiq/meta.yaml index 67f8df57e..11d9bf5ff 100644 --- a/conda/artiq/meta.yaml +++ b/conda/artiq/meta.yaml @@ -1,14 +1,13 @@ package: name: artiq - version: "0.0" + version: {{ environ.get("GIT_DESCRIBE_TAG", "") }} source: git_url: https://github.com/m-labs/artiq git_tag: master build: - number: 4 - string: dev + number: {{ environ.get("GIT_DESCRIBE_NUMBER", 0) }} entry_points: - artiq_client = artiq.frontend.artiq_client:main - artiq_gui = artiq.frontend.artiq_gui:main # [not win] @@ -24,6 +23,7 @@ requirements: - python - setuptools - numpy + - migen run: - python - llvmlite-or1k @@ -32,6 +32,7 @@ requirements: - prettytable - pyserial - sphinx + - sphinx-argparse - h5py - dateutil - gbulb-artiq # [not win] diff --git a/misc/99-ppro.rules b/misc/99-ppro.rules new file mode 100644 index 000000000..aae2a97c1 --- /dev/null +++ b/misc/99-ppro.rules @@ -0,0 +1 @@ +SUBSYSTEM=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010", MODE="0666"