Fix correct commit hash for release 0.7.0 of openXC7
[dev-env-setup.git] / nextpnr-xilinx-install
1 #!/bin/bash
2 if [ "$EUID" -ne 0 ]
3 then echo "Please run as root using 'sudo bash'"
4 exit
5 fi
6
7 # change into $SUDO_USER home directory
8 cd /home/$SUDO_USER
9 mkdir -p src/nextpnr-xilinx
10 cd src/nextpnr-xilinx
11
12 apt-get install -y libcurl3-gnutls git git-man
13
14 git clone https://github.com/f4pga/prjxray.git
15 git clone https://github.com/SymbiFlow/prjxray-db.git
16 # switch to the nextpnr-xilinx source provided by the openXC7 project
17 # it seems more stable than upstream, for now
18 # See: https://bugs.libre-soc.org/show_bug.cgi?id=1004#c13
19 git clone https://github.com/openXC7/nextpnr-xilinx.git
20
21 ## Steps to compile prjxray
22
23 ### Necessary software to install
24
25 apt-get install -y build-essential make cmake python3 python3-setuptools \
26 python3-dev python3-numpy cython3 python3-pip
27
28 pip3 install textx sortedcontainers
29
30 # this really doesn't work properly, antlr is still not correctly
31 # detected, (missing ANTLRconfig.cmake) but at least fasm falls back
32 # to the python version
33 sudo apt install -y cmake default-jre-headless uuid-dev libantlr4-runtime-dev
34
35 apt-get install -y wget
36 wget https://files.pythonhosted.org/packages/78/4c/94fb3bdb87bea21406c0e5da375f0b10d7b1e4b5103cea453a2de23b5d61/fasm-0.0.2.post88.tar.gz
37 tar -xvzf fasm-0.0.2.post88.tar.gz
38 cd fasm-0.0.2.post88
39 python3 setup.py install
40 cd ..
41
42 ### Build prjxray
43
44 cd prjxray
45 git checkout 76401bd93e493fd5ff4c2af4751d12105b0f4f6d
46 git submodule update --init --recursive
47 mkdir build; cd build
48 cmake -DCMAKE_INSTALL_PREFIX=/usr/local/nextpnr-xilinx ..
49 make -j$(nproc)
50 make install
51 install -d -m 0755 /usr/local/nextpnr-xilinx/build/tools
52 install -m 0755 tools/{bitread,bittool,frame_address_decoder,gen_part_base_yaml,segmatch,xc7frames2bit,xc7patch} \
53 /usr/local/nextpnr-xilinx/build/tools
54 cd ..
55 cp -dpr utils /usr/local/nextpnr-xilinx
56 sed -i -e '/^# Vivado /,$d' /usr/local/nextpnr-xilinx/utils/environment.sh
57 python3 setup.py develop
58 cd ..
59
60 ## Steps to compile prjxray-db
61
62 ### Install prjxray-db
63
64 cd prjxray-db
65 git archive --format=tar --prefix=database/ \
66 0a0addedd73e7e4139d52a6d8db4258763e0f1f3 | \
67 tar -C /usr/local/nextpnr-xilinx -xf -
68 cd ..
69
70 ## Steps to compile nextpnr-xilinx
71
72 ### Necessary software to install
73
74 apt-get install -y libboost-thread-dev libboost-iostreams-dev \
75 libboost-program-options-dev libeigen3-dev libboost-python-dev \
76 libboost-filesystem-dev
77
78 ### Build nextpnr-xilinx from release 0.7.0 of openXC7
79
80 cd nextpnr-xilinx
81 git checkout 14c62813ba93258143c2551f4beb0b7e044c5912
82 git submodule init
83 git submodule update
84 cmake -DARCH=xilinx -DBUILD_GUI=OFF \
85 -DCMAKE_INSTALL_PREFIX=/usr/local/nextpnr-xilinx .
86 make -j$(nproc)
87 make install
88
89 # Generate database for fabric: XC7A100T
90 ln -s xc7a100tcsg324-1 xilinx/external/prjxray-db/artix7/xc7a100t
91 python3 xilinx/python/bbaexport.py --device xc7a100tcsg324-1 \
92 --bba xilinx/xc7a100t.bba
93 ./bbasm --l xilinx/xc7a100t.bba xilinx/xc7a100t.bin
94
95 # Generate database for fabric: XC7A200T
96 ln -s xc7a200tsbg484-1 xilinx/external/prjxray-db/artix7/xc7a200t
97 python3 xilinx/python/bbaexport.py --device xc7a200tsbg484-1 \
98 --bba xilinx/xc7a200t.bba
99 ./bbasm --l xilinx/xc7a200t.bba xilinx/xc7a200t.bin
100
101 install -d -m 0755 /usr/local/nextpnr-xilinx/share/xilinx
102 install -m 0755 xilinx/xc7a100t.bin /usr/local/nextpnr-xilinx/share/xilinx
103 install -m 0755 xilinx/xc7a200t.bin /usr/local/nextpnr-xilinx/share/xilinx
104
105 export XRAY_DIR=/usr/local/nextpnr-xilinx
106 cd ..
107
108 cd /home/$SUDO_USER/src/nextpnr-xilinx
109 chown -R $SUDO_USER .
110 chgrp -R $SUDO_USER .
111