Add nextpnr-xilinx installation script
[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 #!!! buster backports is needed for cmake
8 cat << EOF > /etc/apt/sources.list.d/buster_backports.list
9 deb http://deb.debian.org/debian buster-backports main
10 EOF
11
12 # oooo annoying, pin preferences for buster-backports
13 cat << EOF > /etc/apt/preferences.d/99buster-backports
14 Package: *
15 Pin: release a=buster-backports
16 Pin-Priority: 900
17 EOF
18
19 # upgrade to buster-backports
20 apt-get update -y
21 apt-get upgrade -y
22
23 # change into $SUDO_USER home directory
24 cd /home/$SUDO_USER
25 mkdir -p src/nextpnr-xilinx
26 cd src/nextpnr-xilinx
27
28 apt-get install -y --allow-downgrades libcurl3-gnutls/buster git/buster git-man/buster
29
30 git clone https://github.com/YosysHQ/yosys.git
31 git clone https://github.com/YosysHQ/abc.git
32 git clone https://github.com/f4pga/prjxray.git
33 git clone https://github.com/SymbiFlow/prjxray-db.git
34 git clone https://github.com/gatecat/nextpnr-xilinx.git
35
36 ## Steps to compile Yosys
37
38 ### Necessary software to install
39
40 apt-get install -y build-essential make g++ cmake bison flex python3 \
41 clang libreadline-dev gawk tcl-dev libffi-dev pkg-config zlib1g-dev \
42 libboost-system-dev libboost-python-dev libboost-filesystem-dev
43
44 ### Build Yosys
45
46 cd abc
47 git checkout 00b674d5b3ccefc7f2abcbf5b650fc14298ac549
48 cd ../yosys
49 git checkout 6318db6152d053244adb316fda6e01a32a4f3c72
50 ln -s ../abc .
51 make -j $(nproc) PREFIX=/usr/local/nextpnr-xilinx
52 make PREFIX=/usr/local/nextpnr-xilinx install
53 export PATH=/usr/local/nextpnr-xilinx/bin:$PATH
54 cd ..
55
56 ## Steps to compile prjxray
57
58 ### Necessary software to install
59
60 apt-get install -y python3-pip
61
62 ### Build prjxray
63
64 cd prjxray
65 git checkout 18b92012afe2b03f3f975a78c4372c74b60dca0c
66 git submodule update --init --recursive
67 mkdir build; cd build
68 cmake -DCMAKE_INSTALL_PREFIX=/usr/local/nextpnr-xilinx ..
69 make -j$(nproc)
70 make install
71 install -d -m 0755 /usr/local/nextpnr-xilinx/build/tools
72 install -m 0755 tools/{bitread,bittool,frame_address_decoder,gen_part_base_yaml,segmatch,xc7frames2bit,xc7patch} \
73 /usr/local/nextpnr-xilinx/build/tools
74 cd ..
75 cp -dpr utils /usr/local/nextpnr-xilinx
76 sed -i -e '/^# Vivado /,$d' /usr/local/nextpnr-xilinx/utils/environment.sh
77 pip3 install .
78 cd ..
79
80 ## Steps to compile prjxray-db
81
82 ### Install prjxray-db
83
84 cd prjxray-db
85 git archive --format=tar --prefix=database/ \
86 0a0addedd73e7e4139d52a6d8db4258763e0f1f3 | \
87 tar -C /usr/local/nextpnr-xilinx -xf -
88 cd ..
89
90 ## Steps to compile nextpnr-xilinx
91
92 ### Necessary software to install
93
94 apt-get install -y libboost-thread-dev libboost-iostreams-dev \
95 libboost-program-options-dev libeigen3-dev
96
97 ### Build nextpnr-xilinx
98
99 cd nextpnr-xilinx
100 git checkout 565588a69ea95a52f7c7592f4ed81d9bef6cfb60
101 git submodule init
102 git submodule update
103 cmake -DARCH=xilinx -DBUILD_GUI=OFF \
104 -DCMAKE_INSTALL_PREFIX=/usr/local/nextpnr-xilinx .
105 make -j$(nproc)
106 make install
107 ln -s xc7a100tcsg324-1 xilinx/external/prjxray-db/artix7/xc7a100t
108 python3 xilinx/python/bbaexport.py --device xc7a100tcsg324-1 \
109 --bba xilinx/xc7a100t.bba
110 ./bbasm --l xilinx/xc7a100t.bba xilinx/xc7a100t.bin
111 install -d -m 0755 /usr/local/nextpnr-xilinx/share/xilinx
112 install -m 0755 xilinx/xc7a100t.bin /usr/local/nextpnr-xilinx/share/xilinx
113 export XRAY_DIR=/usr/local/nextpnr-xilinx
114 cd ..
115
116 cd /home/$SUDO_USER/src/nextpnr-xilinx
117 chown -R $SUDO_USER .
118 chgrp -R $SUDO_USER .
119