2014-09-28 23:25:32 +08:00
Installing ARTIQ
================
2015-06-15 02:55:58 +08:00
The preferred way of installing ARTIQ is through the use of the conda package manager.
The conda package contains pre-built binaries that you can directly flash to your board.
But you can also :ref: `install from sources <install-from-sources>` .
2015-06-15 05:27:36 +08:00
.. note :: Only the linux-64 and linux-32 conda packages contain the FPGA/BIOS/runtime pre-built binaries.
2015-06-15 02:55:58 +08:00
Installing using conda
----------------------
Installing Anaconda or Miniconda
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* You can either install Anaconda (chose Python 3.4) from https://store.continuum.io/cshop/anaconda/
* Or install the more minimalistic Miniconda (chose Python3.4) from http://conda.pydata.org/miniconda.html
After installing either Anaconda or Miniconda, open a new terminal and make sure the following command works::
$ conda
If it prints the help of the `` conda `` command, your install is OK.
If not, then make sure your `` $PATH `` environment variable contains the path to anaconda3/bin (or miniconda3/bin)::
$ echo $PATH
/home/fallen/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
If your `` $PATH `` misses reference the miniconda3/bin or anaconda3/bin you can fix this by typing::
$ export PATH=$HOME/miniconda3:$PATH
Installing the host side software
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2015-06-15 05:27:36 +08:00
For this, you need to add our binstar repository to your conda configuration::
2015-06-15 02:55:58 +08:00
2015-07-10 22:29:43 +08:00
$ conda config --add channels http://conda.anaconda.org/fallen/channel/dev
2015-06-15 02:55:58 +08:00
Then you can install the ARTIQ package, it will pull all the necessary dependencies::
$ conda install artiq
2014-09-28 23:25:32 +08:00
Preparing the core device FPGA board
2015-06-15 02:55:58 +08:00
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
You now need to flash 3 things on the FPGA board:
2015-06-15 04:23:55 +08:00
1. The FPGA bitstream
2. The BIOS
3. The ARTIQ runtime
2015-06-15 02:55:58 +08:00
2015-07-04 20:48:55 +08:00
First you need to :ref: `install xc3sprog <install-xc3sprog>` . Then, you can flash the board:
2015-06-16 08:32:22 +08:00
* For the Pipistrello board::
2015-06-15 02:55:58 +08:00
$ artiq_flash.sh -t pipistrello
2015-06-16 08:32:22 +08:00
* For the KC705 board::
2015-06-15 02:55:58 +08:00
$ artiq_flash.sh
Next step (for KC705) is to flash MAC and IP addresses to the board:
* See :ref: `those instructions <flash-mac-ip-addr>` to flash MAC and IP addresses.
.. _install-from-sources:
Installing from source
----------------------
2015-07-26 14:38:43 +08:00
You can skip the first two steps if you already installed from conda.
2015-06-15 02:55:58 +08:00
2015-07-26 14:38:43 +08:00
Preparing the build environment for the core device
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2014-09-30 18:10:40 +08:00
2015-07-26 14:38:43 +08:00
These steps are required to generate code that can run on the core
device. They are necessary both for building the MiSoC BIOS
and the ARTIQ kernels.
2014-11-17 12:42:37 +08:00
2014-11-05 18:53:39 +08:00
* Create a development directory: ::
2014-10-10 11:16:10 +08:00
2014-11-05 18:53:39 +08:00
$ mkdir ~/artiq-dev
2014-10-10 11:16:10 +08:00
2015-07-26 14:28:11 +08:00
* Install OpenRISC binutils (or1k-linux-...): ::
2014-10-10 11:16:10 +08:00
2014-11-17 12:09:32 +08:00
$ cd ~/artiq-dev
2015-07-26 14:28:11 +08:00
$ wget https://ftp.gnu.org/gnu/binutils/binutils-2.25.1.tar.bz2
$ tar xvf binutils-2.25.1.tar.bz2
$ rm binutils-2.25.1.tar.bz2
$ mkdir binutils-2.25.1/build
$ cd binutils-2.25.1/build
$ ../configure --target=or1k-linux --prefix=/usr/local
2014-11-05 18:53:39 +08:00
$ make -j4
$ sudo make install
2014-10-10 11:16:10 +08:00
2015-07-26 14:28:11 +08:00
.. note ::
We're using an `` or1k-linux `` target because it is necessary to enable
shared library support in `` ld `` , not because Linux is involved.
* Install LLVM and Clang: ::
2014-11-27 22:27:18 +08:00
$ cd ~/artiq-dev
2015-07-26 14:28:11 +08:00
$ git clone https://github.com/openrisc/llvm-or1k
$ cd llvm-or1k/tools
$ git clone https://github.com/openrisc/clang-or1k clang
$ cd ..
2015-06-19 14:10:33 +08:00
$ mkdir build
$ cd build
2015-07-26 14:28:11 +08:00
$ cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/llvm-or1k -DLLVM_TARGETS_TO_BUILD="OR1K;X86" -DCMAKE_BUILD_TYPE=Rel -DLLVM_ENABLE_ASSERTIONS=ON
2014-11-05 18:53:39 +08:00
$ make -j4
$ sudo make install
2014-09-28 23:25:32 +08:00
2015-07-26 14:28:11 +08:00
.. note ::
Compilation of LLVM can take more than 30 min on some machines.
2015-07-26 14:38:43 +08:00
Preparing the core device FPGA board
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
These steps are required to generate bitstream (`` .bit `` ) files, build the MiSoC BIOS and ARTIQ runtime, and flash FPGA boards. If the board is already flashed, you may skip those steps and go directly to `Installing the host-side software` .
* Install the FPGA vendor tools (e.g. Xilinx ISE and/or Vivado):
* Get Xilinx tools from http://www.xilinx.com/support/download/index.htm. ISE can build bitstreams both for boards using the Spartan-6 (Pipistrello) and 7-series devices (KC705), while Vivado supports only boards using 7-series devices.
* The Pipistrello is supported by Webpack, the KC705 is not.
* During the Xilinx toolchain installation, uncheck `` Install cable drivers `` (they are not required as we use better and open source alternatives).
* Install Migen: ::
$ cd ~/artiq-dev
$ git clone https://github.com/m-labs/migen
$ cd migen
$ python3 setup.py develop --user
.. note ::
The options `` develop `` and `` --user `` are for setup.py to install Migen in `` ~/.local/lib/python3.4 `` .
2015-07-04 20:48:55 +08:00
.. _install-xc3sprog:
2015-04-27 20:43:45 +08:00
* Install JTAG tools needed to program the Pipistrello and KC705:
2014-10-10 11:16:10 +08:00
2014-11-05 18:53:39 +08:00
::
2014-10-10 11:16:10 +08:00
2014-11-05 18:53:39 +08:00
$ cd ~/artiq-dev
$ svn co https://xc3sprog.svn.sourceforge.net/svnroot/xc3sprog/trunk xc3sprog
2015-06-19 14:10:33 +08:00
$ cd xc3sprog
2014-11-05 18:53:39 +08:00
$ cmake . && make
$ sudo make install
2014-10-10 11:16:10 +08:00
2014-11-05 18:53:39 +08:00
.. note ::
It is safe to ignore the message "Could NOT find LIBFTD2XX" (libftd2xx is different from libftdi, and is not required).
2014-10-10 11:16:10 +08:00
2015-06-15 02:55:58 +08:00
.. _install-flash-proxy:
2014-11-05 18:53:39 +08:00
* Install the required flash proxy bitstreams:
The purpose of the flash proxy bitstream is to give programming software fast JTAG access to the flash connected to the FPGA.
2015-04-27 20:43:45 +08:00
* Pipistrello:
2014-11-05 18:53:39 +08:00
::
2014-11-07 08:30:40 +08:00
$ cd ~/artiq-dev
2015-04-27 20:43:45 +08:00
$ wget http://www.phys.ethz.ch/~robertjo/bscan_spi_lx45_csg324.bit
2014-11-05 18:53:39 +08:00
2015-04-27 20:43:45 +08:00
Then copy `` ~/artiq-dev/bscan_spi_lx45_csg324.bit `` to `` ~/.migen `` , `` /usr/local/share/migen `` or `` /usr/share/migen `` .
2014-11-05 18:53:39 +08:00
* KC705:
::
2014-11-07 08:30:40 +08:00
$ cd ~/artiq-dev
2014-11-05 18:53:39 +08:00
$ git clone https://github.com/m-labs/bscan_spi_kc705
2015-06-19 14:10:33 +08:00
$ cd bscan_spi_kc705
$ make
2014-10-10 11:16:10 +08:00
2015-06-19 14:10:33 +08:00
Then copy the generated `` bscan_spi_kc705.bit `` to `` ~/.migen `` , `` /usr/local/share/migen `` or `` /usr/share/migen `` .
2014-09-28 23:25:32 +08:00
2014-11-05 18:53:39 +08:00
* Download MiSoC: ::
2014-09-28 23:25:32 +08:00
2014-11-05 18:53:39 +08:00
$ cd ~/artiq-dev
$ git clone --recursive https://github.com/m-labs/misoc
2014-11-17 12:42:37 +08:00
$ export MSCDIR=~/artiq-dev/misoc # append this line to .bashrc
2014-09-28 23:25:32 +08:00
2015-03-21 21:14:40 +08:00
* Download and install ARTIQ: ::
$ cd ~/artiq-dev
$ git clone https://github.com/m-labs/artiq
$ python3 setup.py develop --user
2015-06-15 04:05:06 +08:00
* Build and flash the bitstream and BIOS by running `from the MiSoC top-level directory` :
::
2014-11-05 18:53:39 +08:00
2014-11-07 08:30:40 +08:00
$ cd ~/artiq-dev/misoc
2015-07-26 14:28:11 +08:00
$ export PATH=$PATH:/usr/local/llvm-or1k/bin
2015-06-15 04:05:06 +08:00
* For Pipistrello::
$ ./make.py -X ~/artiq-dev/artiq/soc -t artiq_pipistrello all
* For KC705::
$ ./make.py -X ~/artiq-dev/artiq/soc -t artiq_kc705 all
2014-11-05 18:53:39 +08:00
2015-03-21 21:14:40 +08:00
* Then, build and flash the ARTIQ runtime: ::
2014-11-05 18:53:39 +08:00
2015-04-17 17:38:45 +08:00
$ cd ~/artiq-dev/artiq/soc/runtime && make runtime.fbi
2015-04-27 20:43:45 +08:00
$ ~/artiq-dev/artiq/artiq/frontend/artiq_flash.sh -t pipistrello -d $PWD -r
2014-11-05 18:53:39 +08:00
2015-04-27 20:43:45 +08:00
.. note :: The `-t` option specifies the board your are targeting. Available options are `` kc705 `` and `` pipistrello `` .
2015-04-17 17:38:45 +08:00
* Check that the board boots by running a serial terminal program (you may need to press its FPGA reconfiguration button or power-cycle it to load the bitstream that was newly written into the flash): ::
2014-11-05 18:53:39 +08:00
2015-01-21 10:31:50 +08:00
$ make -C ~/artiq-dev/misoc/tools # do only once
2014-11-07 08:30:40 +08:00
$ ~/artiq-dev/misoc/tools/flterm --port /dev/ttyUSB1
2014-11-05 18:53:39 +08:00
MiSoC BIOS http://m-labs.hk
[...]
Booting from flash...
Loading xxxxx bytes from flash...
Executing booted program.
ARTIQ runtime built <date/time>
2014-09-28 23:25:32 +08:00
The communication parameters are 115200 8-N-1.
2015-06-15 02:55:58 +08:00
.. _flash-mac-ip-addr:
2015-05-07 23:47:48 +08:00
* Set the MAC and IP address in the :ref: `core device configuration flash storage <core-device-flash-storage>` :
* You can either set it by generating a flash storage image and then flash it: ::
2015-05-29 23:44:07 +08:00
$ artiq_mkfs flash_storage.img -s mac xx:xx:xx:xx:xx:xx -s ip xx.xx.xx.xx
2015-05-07 23:47:48 +08:00
$ ~/artiq-dev/artiq/frontend/artiq_flash.sh -f flash_storage.img
* Or you can set it via the runtime test mode command line
* Boot the board.
* Quickly run flterm (in `` path/to/misoc/tools `` ) to access the serial console.
* If you weren't quick enough to see anything in the serial console, press the reset button.
* Wait for "Press 't' to enter test mode..." to appear and hit the `` t `` key.
* Enter the following commands (which will erase the flash storage content).
::
test> fserase
test> fswrite ip xx.xx.xx.xx
test> fswrite mac xx:xx:xx:xx:xx:xx
* Then reboot.
You should see something like this in the serial console: ::
~/dev/misoc$ ./tools/flterm --port /dev/ttyUSB1
[FLTERM] Starting...
MiSoC BIOS http://m-labs.hk
(c) Copyright 2007-2014 Sebastien Bourdeauducq
[...]
Press 't' to enter test mode...
Entering test mode.
test> fserase
test> fswrite ip 192.168.10.2
test> fswrite mac 11:22:33:44:55:66
.. note :: The reset button of the KC705 board is the "CPU_RST" labeled button.
.. warning :: Both those instructions will result in the flash storage being wiped out. However you can use the test mode to change the IP/MAC without erasing everything if you skip the "fserase" command.
2015-05-29 22:30:32 +08:00
* (optional) Flash the `` idle `` kernel
The `` idle `` kernel is the kernel (some piece of code running on the core device) which the core device runs whenever it is not connected to a PC via ethernet.
This kernel is therefore stored in the :ref: `core device configuration flash storage <core-device-flash-storage>` .
To flash the `` idle `` kernel:
* Compile the `` idle `` experiment:
The `` idle `` experiment's `` run() `` method must be a kernel: it must be decorated with the `` @kernel `` decorator (see :ref: `next topic <connecting-to-the-core-device>` for more information about kernels).
2015-06-04 10:42:37 +08:00
Since the core device is not connected to the PC, RPCs (calling Python code running on the PC from the kernel) are forbidden in the `` idle `` experiment.
2015-05-29 22:30:32 +08:00
::
$ artiq_compile idle.py
* Write it into the core device configuration flash storage: ::
2015-06-17 22:46:39 +08:00
$ artiq_coreconfig write -f idle_kernel idle.elf
2015-05-29 22:30:32 +08:00
.. note :: You can find more information about how to use the `` artiq_coreconfig `` tool on the :ref: `Utilities <core-device-configuration-tool>` page.
2014-09-28 23:25:32 +08:00
Installing the host-side software
2015-06-15 02:55:58 +08:00
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2014-09-28 23:25:32 +08:00
2015-07-26 14:28:11 +08:00
* Install the llvmlite Python bindings: ::
2014-11-05 18:53:39 +08:00
2014-11-07 08:30:40 +08:00
$ cd ~/artiq-dev
2014-12-05 17:05:43 +08:00
$ git clone https://github.com/numba/llvmlite
2015-06-19 14:10:33 +08:00
$ cd llvmlite
2015-04-02 17:06:19 +08:00
$ patch -p1 < ~/artiq-dev/artiq/misc/llvmlite-add-all-targets.patch
2015-07-15 23:31:57 +08:00
$ patch -p1 < ~/artiq-dev/artiq/misc/llvmlite-rename.patch
$ patch -p1 < ~/artiq-dev/artiq/misc/llvmlite-build-as-debug-on-windows.patch
2015-07-26 14:38:43 +08:00
$ LLVM_CONFIG=/usr/local/llvm-or1k/bin/llvm-config python3 setup.py install --user
2014-09-28 23:25:32 +08:00
2014-12-05 17:05:43 +08:00
.. note ::
llvmlite is in development and its API is not stable yet. Commit ID `` 11a8303d02e3d6dd2d1e0e9065701795cd8a979f `` is known to work.
2015-05-29 23:45:13 +08:00
* Install ARTIQ: ::
2014-11-05 18:53:39 +08:00
$ cd ~/artiq-dev
2014-11-07 08:30:40 +08:00
$ git clone https://github.com/m-labs/artiq # if not already done
2015-02-09 19:27:36 +08:00
$ cd artiq
2014-11-05 18:53:39 +08:00
$ python3 setup.py develop --user
* Build the documentation: ::
$ cd ~/artiq-dev/artiq/doc/manual
$ make html
2014-09-29 14:50:29 +08:00
2015-03-21 21:14:40 +08:00
Ubuntu 14.04 specific instructions
----------------------------------
2014-09-28 23:25:32 +08:00
2014-11-05 18:53:39 +08:00
This command installs all the required packages: ::
2014-09-28 23:25:32 +08:00
2015-06-15 02:55:58 +08:00
$ sudo apt-get install build-essential autotools-dev file git patch perl xutils-devs python3-pip texinfo flex bison libmpc-dev python3-serial python3-dateutil python3-prettytable python3-setuptools python3-numpy python3-scipy python3-sphinx python3-h5py python3-dev python-dev subversion cmake libusb-dev libftdi-dev pkg-config
2014-09-28 23:25:32 +08:00
2014-11-05 18:53:39 +08:00
Note that ARTIQ requires Python 3.4 or above.
2014-11-17 11:55:12 +08:00
2015-04-27 20:43:45 +08:00
To set user permissions on the JTAG and serial ports of the Pipistrello, create a `` /etc/udev/rules.d/30-usb-papilio.rules `` file containing the following: ::
2014-11-17 11:55:12 +08:00
2014-11-17 12:45:47 +08:00
SUBSYSTEM=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010", GROUP="dialout"
2014-11-17 11:55:12 +08:00
2014-11-17 12:45:47 +08:00
Then reload `` udev `` , add your user to the `` dialout `` group, and log out and log in again: ::
2014-11-17 11:55:12 +08:00
$ sudo invoke-rc.d udev reload
2014-11-17 12:45:47 +08:00
$ sudo adduser <your username> dialout
2014-11-17 11:55:12 +08:00
$ logout