Last active
August 29, 2015 14:04
-
-
Save nvasilakis/8bcbcdba1a2ae4b63eb7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!env bash | |
| # Xilinx tools: http://www.xilinx.com/support/documentation/boards_and_kits/xtp044.pdf | |
| # Bluespec: http://www.bluespec.com/forum | |
| # Xilix ISE:http://www.xilinx.com/support/download/index.html/content/xilinx/en/downloadNav/design-tools/v2012_4---14_6.html | |
| # This is for bash -- if using interactively with zsh, consider | |
| # setting sh_word_split on, or using $=<PARAM> instead of $PARAM | |
| # TODO: Make sure all updates to $PATH are written to .${SHELL}rc | |
| # TODO: append environment to a particular section of .${SHELL}rc | |
| # TODO: add key-generation | |
| # Haskell sudo apt-get install libgmp3-dev OR: | |
| # https://gist.github.com/Dexyne/5791465 | |
| # this won't expand correctly in zsh | |
| OPTIONAL_PKG="vim htop zsh" | |
| GIT_USER=nvas | |
| HOSTNAME=`hostname` | |
| GHC_VERSION=7.6.3 | |
| CABAL_VERSION=1.18.0.2 | |
| GHC_INSTALL_DIR=$HOME/ghc | |
| DEFAULT_CABAL_LIBS="happy alex mtl" | |
| SVNROOT="~/crash" | |
| # Add user to Sudoers list | |
| sed 's/^\(.*deb cdrom\)/#\1'/ /etc/apt/sources.list > ~/tmp | |
| sudo cp /etc/apt/sources.list /etc/apt/sources.list_BAK | |
| sudo mv ~/tmp /etc/apt/sources.list | |
| sudo apt-get update | |
| sudo apt-get upgrade | |
| # everything but Haskell | |
| sudo apt-get -y install g++ git make python-dev binutils-dev libusb-dev vnc4server xtightvncviewer fxload csh texlive openssh-server tomcat6 libncurses5-dev $OPTIONAL_PKG | |
| #Xilinx ISE Design Suite ##.# Logic Edition license generation | |
| #Xilinx ISE Design Suite ##.# Logic Edition installation | |
| #FPGA card installation | |
| #USB driver for Xilinx devices installation | |
| cd ~ | |
| wget 'http://git.zerfleddert.de/cgi-bin/gitweb.cgi/usb-driver?a=snapshot;h=HEAD;sf=tgz' -O usb-driver-HEAD.tar.gz | |
| tar -xzvf usb-driver-HEAD.tar.gz | |
| cd usb-driver-HEAD-* # the commit hash might be different, thus `*` | |
| make | |
| sudo export LD_PRELOAD=$(pwd)/libusb-driver.so | |
| # not needed: | |
| # sudo . /opt/Xilinx/##.#/ISE_DS/settings64.sh | |
| # | |
| sudo mkdir -p /etc/udev/rules.d/ | |
| sudo echo 'ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="03fd", MODE="666"' > /etc/udev/rules.d/libusb-driver.rules | |
| echo '<This is step can fail, make sure it does not>' | |
| ./setup_pcusb # <====== $XILIX_DIR/ISE_DS/ISE | |
| # Seemed to be needed: | |
| #As Root, enter “cp /opt/Xilinx/##.#/ISE_DS/ISE/bin/lin64/xusb*.hex /usr/share/”. | |
| #As Root, enter “cp /opt/Xilinx/##.#/ISE_DS/ISE/bin/lin/xusbdfwu.rules/etc/udev/rules.d/”, | |
| #As Root, enter “sed -i -e 's/TEMPNODE/tempnode/' -e 's/SYSFS/ATTRS/g' -e 's/BUS/SUBSYSTEMS/' /etc/udev/rules.d/xusbdfwu.rules”, and | |
| echo '</This is step can fail, make sure it does not>' | |
| sudo /etc/init.d/udev restart | |
| echo 'Connect the FPGA USB cable between the FPGA card and one of the USB ports on the back of the Debian computer. Type `OK`' | |
| read USR_RES # just to stop process, we don't check | |
| lsusb | |
| lsusb | grep -q | |
| if $(lsusb | grep -q '03fd:0008'); then | |
| echo '03fd:0008 not found in the output of lsusb -- something went wrong, restart machine' | |
| exit | |
| else | |
| echo 'Select OK to create a project, Xilinx devices should display in the main window and exit.' | |
| impact | |
| fi | |
| # SAFE source code checkout | |
| # TODO: verify --recursive | |
| # Because parent repo takes a lot of time, when it requests for submodule clone password, we usually miss it. | |
| cd ~ | |
| git clone ssh://${GIT_USER}@git.crash-safe.org/proj/crash/git/crash.git | |
| cd $SVNROOT | |
| git submodule update --init --recursive | |
| # Host program build and configuration | |
| sed 's;quiet;quiet memmap=512M\\\$0x5f700000;' /etc/default/grub > ~/tmp | |
| sudo cp /etc/default/grub /etc/default/grub_BAK | |
| sudo mv ~/tmp /etc/default/grub | |
| update-grub | |
| echo "Type `reboot` to reboot the system (or do it manually). After reboot type ./$0 --continue" | |
| read USR_RES | |
| if [[ $USR_RES == "reboot" ]]; then | |
| sudo reboot | |
| else | |
| echo 'Please reboot manually' | |
| exit | |
| done | |
| # ..if --continue | |
| chmod -R 777 ~crash/isa/fpga/platform/host_interface | |
| ~crash/isa/fpga/platform/host_interface/Lib | |
| . ./ocpi_env_linux_x86_64.sh | |
| export OCPI_DMA_MEMORY=512M\$0x5f700000 | |
| ~crash/isa/fpga/platform/host_interface | |
| ./opencpi_compile.sh &> log.txt | |
| echo 'Appending the following lines to your .${SHELL}rc -- Add other things to the same session' | |
| HERE=$(<<EOF | |
| if [[ \$(hostname) == $HOSTNAME ]]; then | |
| pushd \$PWD 2>&1 > /dev/null | |
| export SVNROOT=$HOME/crash | |
| . /var/lib/fpga_users/all_conf.sh 2>&1 > /dev/null | |
| popd 2>&1 > /dev/null | |
| export BITSTREAM=${HOME}/bitstreams/dram/newest.bit | |
| export GIT_USER=${GIT_USER} | |
| fi | |
| EOF | |
| ) | |
| echo $HERE >> .${SHELL}rc | |
| sudo mkdir -p /var/lib/fpga_users | |
| # Next ones: Turn of parameter expansion: | |
| sudo cat <<'EOF' | |
| #!/bin/bash | |
| . /var/lib/fpga_users/path_conf.sh | |
| . /var/lib/fpga_users/fpga_conf.sh | |
| . /var/lib/fpga_users/bluespec_conf.sh | |
| EOF > /var/lib/fpga_users/all_conf.sh | |
| sudo cat <<'EOF' | |
| #!/bin/bash | |
| # path configuration and LD path configuration | |
| if [ -z "$SVNROOT" ] | |
| then | |
| echo "SVNROOT not set" | |
| exit 1 | |
| fi | |
| export PATH=$SVNROOT/isa/fpga/platform/host_interface/Lib/test/hdl/linux-x86_64-bin:/usr/lib/ghc/bin:$HOME/.cabal/bin:/opt/Xilinx14.6/LabTools/LabTools/bin/lin64:$PATH | |
| export LD_LIBRARY_PATH=/usr/lib/ghc/lib:/usr/local/lib:$LD_LIBRARY_PATH | |
| EOF > /var/lib/fpga_users/path_conf.sh | |
| sudo cat <<'EOF' | |
| #!/bin/bash | |
| export LD_PRELOAD=<path to>/libusb-driver.so | |
| export OCPI_DMA_MEMORY=512M\$0x5f700000 | |
| cd $SVNROOT/isa/fpga/platform/host_interface/Lib | |
| . ./ocpi_env_linux_x86_64.sh | |
| cd $SVNROOT/isa/fpga/platform/host_interface | |
| # . /opt/Xilinx/14.6/ISE_DS/settings64.sh | |
| export FPGA_SLOT=1c | |
| export SWCTL_REGION_0=0xFC000000 | |
| export SWCTL_REGION_1=0xFD000000 | |
| export LD_LIBRARY_PATH=$OCPI_BASE_DIR/lib/$OCPI_BUILD_HOST-bin: | |
| $OPCI_GTEST_DIR/lib:$LD_LIBRARY_PATH | |
| EOF > /var/lib/fpga_users/fpga_conf.sh | |
| sudo cat <<'EOF' | |
| #!/bin/bash | |
| # bluespec variables | |
| #export BLUESPEC_HOME=/opt/Bluespec-2012.01.A | |
| export BLUESPEC_HOME=/opt/Bluespec-2013.05.beta2 | |
| export BLUESPECDIR=$BLUESPEC_HOME/lib | |
| export [email protected]:[email protected]:[email protected] | |
| export [email protected]:[email protected]:[email protected] | |
| export XILINXD_LICENSE_FILE=/opt/Xilinx/Xilinx.lic | |
| export PATH=/opt/Xilinx/14.6/ISE_DS/ISE/bin/lin64:$BLUESPECDIR/../bin:$BLUESPEC_HOME/util/flexlm/x86_64_re3:$BLUESPECDIR/bin:$PATH | |
| export OCPI_XILINX_TOOLS_DIR=/opt/Xilinx/14.6/ISE_DS/ISE | |
| EOF > /var/lib/fpga_users/bluespec_conf.sh | |
| # Haskell and Cabal Installation | |
| GHC_URL=http://www.haskell.org/ghc/dist/${GHC_VERSION}/ghc-${GHC_VERSION}-x86_64-unknown-linux.tar.bz2 | |
| TMP_DIR=`mktemp -d` | |
| pushd $TMP_DIR &> /dev/null | |
| # [ We are in temp | |
| wget "$GHC_URL" | |
| tar xjf ghc*.tar.bz2 | |
| pushd ghc*/ &> /dev/null | |
| ./configure --prefix=$GHC_INSTALL_DIR | |
| make install | |
| popd &> /dev/null | |
| CABAL_URL=http://www.haskell.org/cabal/release/cabal-install-${CABAL_VERSION}/cabal-install-${CABAL_VERSION}.tar.gz | |
| wget "$CABAL_URL" | |
| tar xzf cabal*.tar.gz | |
| pushd cabal*/ &> /dev/null | |
| chmod 700 bootstrap.sh | |
| PATH_ADD=$GHC_INSTALL_DIR/bin:$CABAL_INSTALL_DIR/bin | |
| export PATH=$PATH_ADD:$PATH | |
| echo "Make sure to update your PATH to include ${PATH_ADD}" | |
| #### TODO: Update $PATH | |
| read OK | |
| ./bootstrap.sh --user ## Where does someone pass the $CABAL_INSTALL_DIR variable? | |
| popd &> /dev/null | |
| cabal update | |
| cabal install ${DEFAULT_CABAL_LIBS} | |
| popd &> /dev/null | |
| # Does not create personality | |
| cd $SVNROOT | |
| make install |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment