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>` .
2016-01-07 04:12:42 +08:00
.. warning ::
NIST users need to pay close attention to their `` umask `` . The sledgehammer
called `` secureconfig `` leaves you (and root) with umask 027 and files
2016-01-07 10:06:43 +08:00
created by root (e.g. `` sudo make install `` ) inaccessible to you.
2016-01-07 04:12:42 +08:00
The usual umask is 022.
2015-06-15 02:55:58 +08:00
Installing using conda
----------------------
2016-02-11 06:37:21 +08:00
.. warning ::
Conda packages are supported for Linux (64-bit) and Windows (32- and 64-bit). Users of other
operating systems (32-bit Linux, BSD, ...) should install from source.
2015-06-15 02:55:58 +08:00
Installing Anaconda or Miniconda
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2015-10-16 12:06:22 +08:00
* You can either install Anaconda (choose Python 3.5) from https://store.continuum.io/cshop/anaconda/
2015-06-15 02:55:58 +08:00
2015-10-16 12:06:22 +08:00
* Or install the more minimalistic Miniconda (choose Python 3.5) from http://conda.pydata.org/miniconda.html
2015-08-26 20:22:13 +08:00
2015-06-15 02:55:58 +08:00
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
2015-10-30 09:18:42 +08:00
/home/.../miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
2015-06-15 02:55:58 +08:00
2016-02-22 17:52:18 +08:00
If your `` $PATH `` misses reference the `` miniconda3/bin `` or `` anaconda3/bin `` you can fix this by typing::
2015-06-15 02:55:58 +08:00
2016-02-22 17:52:18 +08:00
$ export PATH=$HOME/miniconda3/bin:$PATH
2015-06-15 02:55:58 +08:00
Installing the host side software
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2015-10-30 09:18:42 +08:00
For this, you need to add our Anaconda repository to your conda configuration::
2015-06-15 02:55:58 +08:00
2015-10-16 12:06:22 +08:00
$ conda config --add channels http://conda.anaconda.org/m-labs/channel/main
2015-08-13 14:47:05 +08:00
$ conda config --add channels http://conda.anaconda.org/m-labs/channel/dev
2015-06-15 02:55:58 +08:00
2015-10-30 09:18:42 +08:00
Then you can install the ARTIQ package, it will pull all the necessary dependencies.
2015-06-15 02:55:58 +08:00
2015-10-30 09:18:42 +08:00
* For the Pipistrello board::
$ ENV=$(date +artiq-%Y-%m-%d); conda create -n $ENV artiq-pipistrello-nist_qc1; \
echo "Created environment $ENV for ARTIQ"
2015-10-30 10:07:01 +08:00
* For the KC705 board with SCSI cables and AD9858 DDS chips::
2015-10-30 09:18:42 +08:00
2015-10-30 10:07:01 +08:00
$ ENV=$(date +artiq-%Y-%m-%d); conda create -n $ENV artiq-kc705-nist_qc1; \
echo "Created environment $ENV for ARTIQ"
* For the KC705 board with the FMC backplane and AD9914 DDS chips::
$ ENV=$(date +artiq-%Y-%m-%d); conda create -n $ENV artiq-kc705-nist_qc2; \
2015-10-30 09:18:42 +08:00
echo "Created environment $ENV for ARTIQ"
This creates a new Conda "environment" (i.e. an isolated installation) and prints its name.
If you ever need to upgrade ARTIQ, it is advised to install it again
in a new environment so that you can roll back to a version that is known to
work correctly.
After this, add the newly created environment to your `` $PATH `` . This can be easily
done using the following command::
$ source activate artiq-[date]
You will need to invoke this command in every new shell. When in doubt, you can list
the existing environments using::
$ conda env list
2015-06-15 02:55:58 +08:00
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
2016-01-05 07:54:14 +08:00
First you need to :ref: `install openocd <install-openocd>` . Then, you can flash the board:
2015-07-04 20:48:55 +08:00
2015-06-16 08:32:22 +08:00
* For the Pipistrello board::
2015-06-15 02:55:58 +08:00
2016-01-05 07:54:14 +08:00
$ artiq_flash -t pipistrello
2015-06-15 02:55:58 +08:00
2015-06-16 08:32:22 +08:00
* For the KC705 board::
2015-06-15 02:55:58 +08:00
2016-01-05 07:54:14 +08:00
$ artiq_flash
2015-06-15 02:55:58 +08:00
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
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-08-10 04:33:00 +08:00
* Clone ARTIQ repository: ::
$ cd ~/artiq-dev
$ git clone --recursive https://github.com/m-labs/artiq
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
2016-02-16 02:24:11 +08:00
$ wget https://ftp.gnu.org/gnu/binutils/binutils-2.26.tar.bz2
$ tar xvf binutils-2.26.tar.bz2
$ rm binutils-2.26.tar.bz2
2015-08-10 04:33:00 +08:00
$ mkdir build
$ cd build
2015-07-26 14:28:11 +08:00
$ ../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
2015-11-07 18:39:39 +08:00
$ python3.5 setup.py develop --user
2015-07-26 14:38:43 +08:00
.. note ::
2015-10-03 14:33:18 +08:00
The options `` develop `` and `` --user `` are for setup.py to install Migen in `` ~/.local/lib/python3.5 `` .
2015-07-26 14:38:43 +08:00
2016-01-05 07:54:14 +08:00
.. _install-openocd:
2015-07-04 20:48:55 +08:00
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
2016-01-05 07:54:14 +08:00
$ git clone https://github.com/ntfreak/openocd.git
$ cd openocd
2016-01-07 04:12:42 +08:00
$ sudo apt-get install build-essentials libtool libusb-1.0-0-dev libftdi-dev
2016-01-05 07:54:14 +08:00
$ ./bootstrap
$ ./configure
$ make
2014-11-05 18:53:39 +08:00
$ sudo make install
2016-01-05 07:54:14 +08:00
$ sudo cp contrib/99-openocd.rules /etc/udev/rules.d
$ adduser $USER plugdev
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.
2016-01-05 07:54:14 +08:00
* Pipistrello and KC705:
2014-11-05 18:53:39 +08:00
::
2014-11-07 08:30:40 +08:00
$ cd ~/artiq-dev
2016-01-06 01:23:50 +08:00
$ wget https://raw.githubusercontent.com/jordens/bscan_spi_bitstreams/master/bscan_spi_xc7k325t.bit
$ wget https://raw.githubusercontent.com/jordens/bscan_spi_bitstreams/master/bscan_spi_xc6slx45.bit
2014-11-05 18:53:39 +08:00
2016-01-07 02:24:05 +08:00
Then move both files `` ~/artiq-dev/bscan_spi_xc6slx45.bit `` and `` ~/artiq-dev/bscan_spi_xc7k325t.bit `` to `` ~/.migen `` , `` /usr/local/share/migen `` , or `` /usr/share/migen `` .
2014-11-05 18:53:39 +08:00
2014-09-28 23:25:32 +08:00
2015-11-04 23:38:24 +08:00
* Download and install 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
2015-11-04 23:38:24 +08:00
$ cd misoc
2015-11-07 18:39:39 +08:00
$ python3.5 setup.py develop --user
2014-09-28 23:25:32 +08:00
2015-03-21 21:14:40 +08:00
* Download and install ARTIQ: ::
$ cd ~/artiq-dev
2015-08-04 17:00:48 +08:00
$ git clone --recursive https://github.com/m-labs/artiq
2015-11-04 23:38:24 +08:00
$ cd artiq
2015-11-07 18:39:39 +08:00
$ python3.5 setup.py develop --user
2015-03-21 21:14:40 +08:00
2015-08-28 23:50:39 +08:00
.. note ::
If you have any trouble during ARTIQ setup about `` pygit2 `` installation,
refer to the section dealing with
:ref: `installing the host-side software <installing-the-host-side-software>` .
2015-11-04 23:38:24 +08:00
* Build the bitstream, BIOS and runtime by running:
2015-06-15 04:05:06 +08:00
::
2014-11-05 18:53:39 +08:00
2015-11-04 23:38:24 +08:00
$ cd ~/artiq-dev
2015-08-04 20:20:56 +08:00
$ export PATH=/usr/local/llvm-or1k/bin:$PATH
.. note :: Make sure that `` /usr/local/llvm-or1k/bin `` is first in your `` PATH `` , so that the `` clang `` command you just built is found instead of the system one, if any.
2015-06-15 04:05:06 +08:00
* For Pipistrello::
2015-11-07 18:39:39 +08:00
$ python3.5 -m artiq.gateware.targets.pipistrello
2015-06-15 04:05:06 +08:00
* For KC705::
2015-11-07 18:39:39 +08:00
$ python3.5 -m artiq.gateware.targets.kc705 -H qc1 # or qc2
2014-11-05 18:53:39 +08:00
2015-11-04 23:38:24 +08:00
* Then, gather the binaries and flash them: ::
2014-11-05 18:53:39 +08:00
2015-11-04 23:38:24 +08:00
$ mkdir binaries
$ cp misoc_nist_qcX_<board>/gateware/top.bit binaries
$ cp misoc_nist_qcX_<board>/software/bios/bios.bin binaries
$ cp misoc_nist_qcX_<board>/software/runtime/runtime.fbi binaries
$ cd binaries
2016-01-05 07:54:14 +08:00
$ artiq_flash -d . -t <board>
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
2016-01-06 01:23:50 +08:00
The communication parameters are 115200 8-N-1. Ensure that your user has access
to the serial device (`` sudo adduser $USER dialout `` assuming standard setup).
2014-09-28 23:25:32 +08:00
2015-08-28 23:50:39 +08:00
.. _installing-the-host-side-software:
2015-08-07 20:48:48 +08:00
Installing the host-side software
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* Install the llvmlite Python bindings: ::
$ cd ~/artiq-dev
$ git clone https://github.com/m-labs/llvmlite
$ cd llvmlite
2015-11-21 04:47:31 +08:00
$ git checkout artiq
2015-11-07 18:39:39 +08:00
$ LLVM_CONFIG=/usr/local/llvm-or1k/bin/llvm-config python3.5 setup.py install --user
2015-08-07 20:48:48 +08:00
* Install ARTIQ: ::
$ cd ~/artiq-dev
$ git clone --recursive https://github.com/m-labs/artiq # if not already done
$ cd artiq
2015-11-07 18:39:39 +08:00
$ python3.5 setup.py develop --user
2015-08-07 20:48:48 +08:00
2015-08-28 23:50:39 +08:00
.. note ::
If you have any trouble during ARTIQ setup about `` pygit2 `` installation,
you can install it by using `` pip `` :
On Ubuntu 14.04::
2015-11-07 18:39:39 +08:00
$ python3.5 `which pip3` install --user pygit2==0.19.1
2015-08-28 23:50:39 +08:00
On Ubuntu 14.10::
2015-11-07 18:39:39 +08:00
$ python3.5 `which pip3` install --user pygit2==0.20.3
2015-08-28 23:50:39 +08:00
On Ubuntu 15.04 and 15.10::
2015-11-07 18:39:39 +08:00
$ python3.5 `which pip3` install --user pygit2==0.22.1
2015-08-28 23:50:39 +08:00
The rationale behind this is that pygit2 and libgit2 must have the same
major.minor version numbers.
See http://www.pygit2.org/install.html#version-numbers
2015-08-07 20:48:48 +08:00
* Build the documentation: ::
$ cd ~/artiq-dev/artiq/doc/manual
$ make html
Configuring the core device
---------------------------
2015-11-01 00:24:44 +08:00
This should be done after either installation method (conda or source).
2015-08-07 20:48:48 +08:00
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
2016-01-05 07:54:14 +08:00
$ artiq_flash -f flash_storage.img proxy storage start
2015-05-07 23:47:48 +08:00
* 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: ::
2015-08-10 15:16:52 +08:00
$ ./tools/flterm --port /dev/ttyUSB1
2015-05-07 23:47:48 +08:00
[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-11-01 00:24:44 +08:00
* (optional) Flash the idle kernel
2015-05-29 22:30:32 +08:00
2015-11-01 00:24:44 +08:00
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.
2015-05-29 22:30:32 +08:00
This kernel is therefore stored in the :ref: `core device configuration flash storage <core-device-flash-storage>` .
2015-11-01 00:24:44 +08:00
To flash the idle kernel:
2015-05-29 22:30:32 +08:00
2015-11-01 00:24:44 +08:00
* 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-05-29 22:30:32 +08:00
2015-11-01 00:24:44 +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-12-24 18:54:23 +08:00
$ artiq_coreconfig write -f idle_kernel idle.elf
2015-05-29 22:30:32 +08:00
2015-12-24 18:51:11 +08:00
.. note :: You can find more information about how to use the `` artiq_coreconfig `` utility on the :ref: `Utilities <core-device-configuration-tool>` page.
2015-05-29 22:30:32 +08:00
2015-11-01 00:24:44 +08:00
* (optional) Flash the startup kernel
2015-12-24 18:51:11 +08:00
The startup kernel is executed once when the core device powers up. It should initialize DDSes, set up TTL directions, etc. Proceed as with the idle kernel, but using the `` startup_kernel `` key in `` artiq_coreconfig `` .
2015-11-01 00:24:44 +08:00
* (optional) Select the startup clock
The core device may use either an external clock signal or its internal clock. This clock can be switched dynamically after the PC is connected using the `` external_clock `` parameter of the core device driver; however, one may want to select the clock at power-up so that it is used for the startup and idle kernels. Use one of these commands: ::
2015-12-24 18:54:23 +08:00
$ artiq_coreconfig write -s startup_clock i # internal clock (default)
$ artiq_coreconfig write -s startup_clock e # external clock