Update with all program install instructions
[libreriscv.git] / HDL_workflow / fpga-boot-loaders-progs.mdwn
1 # FPGA/Board Boot-Loaders-Programmers
2
3 Page: Work in Progress
4
5 Installation instructions for dfu-util, openFPGALoader, ujprog, fujprog, xc3sprog and ecpprog for boards ULX3S, ECP5 and OrangeCrab.
6
7 Use of the automated install scripts recommended
8
9 * Source code: <https://git.code.sf.net/p/dfu-util/dfu-util>
10 * Source code: <https://github.com/trabucayre/openFPGALoader.git>
11 * Source code: <https://github.com/f32c/tools.git>
12 * Source code: <https://github.com/kost/fujprog.git>
13 * Source code: <https://github.com/xtrx-sdr/xc3sprog/>
14 * Source code: <https://github.com/gregdavill/ecpprog/>
15 * Bugzilla page <https://bugs.libre-soc.org/show_bug.cgi?id=791>
16
17 # Setting up new debootstrap and chroot into it
18
19 Run the following if you wish to isolate the nextpnr-xilinx build
20 from other software (reproducible builds) or use the schroot
21 auto-preparation script here:
22 <https://git.libre-soc.org/?p=dev-env-setup.git;a=blob;f=mk-deb-chroot;hb=HEAD>
23
24 export MY_CHROOT=/stable-chroot
25 mkdir $MY_CHROOT
26 debootstrap buster $MY_CHROOT http://deb.debian.org/debian/
27 mount -t proc proc $MY_CHROOT/proc
28 mount -t sysfs sysfs $MY_CHROOT/sys
29 mount -t devpts devpts $MY_CHROOT/dev/pts/
30 chroot $MY_CHROOT /bin/bash
31
32 # Download neccessary softwares
33
34 apt-get install -y libcurl3-gnutls/buster git/buster
35
36 git clone https://git.code.sf.net/p/dfu-util/dfu-util
37 git clone https://github.com/trabucayre/openFPGALoader.git
38 git clone https://github.com/f32c/tools.git
39 git clone https://github.com/kost/fujprog.git
40 git clone https://github.com/xtrx-sdr/xc3sprog.git
41 git clone https://github.com/gregdavill/ecpprog.git
42
43 # Steps to compile dfu-util
44
45 ## Necessary software to install
46
47 apt-get install -y build-essential make autoconf libusb-dev \
48 libusb-1.0-0-dev pkg-config
49
50 ## Build dfu-util
51
52 cd dfu-util
53 git checkout v0.11
54 ./autogen.sh
55 ./configure --prefix=/usr/local/fpga-boot-load-prog
56 make -j$(nproc)
57 make install
58 cd ..
59
60 # Steps to compile openFPGALoader
61
62 ## Necessary software to install
63
64 apt-get install -y cmake libftdi1-2 libftdi1-dev libhidapi-hidraw0 \
65 libhidapi-dev libudev-dev zlib1g-dev
66
67 ## Build openFPGALoader
68
69 cd openFPGALoader
70 git checkout v0.8.0
71 mkdir build; cd build
72 cmake -DCMAKE_INSTALL_PREFIX=/usr/local/fpga-boot-load-prog ..
73 make -j$(nproc)
74 make install
75 cd ..
76 cp 99-openfpgaloader.rules /etc/udev/rules.d
77 cd ..
78
79 # Steps to compile ujprog
80
81 ## Build ujprog
82
83 cd tools
84 git checkout 0698352b0e912caa9b8371b8f692e19aac547a69
85 cd ujprog
86 cp Makefile.linux Makefile
87 sed -i -e 's@ -static@@g' \
88 -e 's@/usr/lib/${ARCHNAME}/libftdi.a@$(shell pkg-config --cflags --libs libftdi1)@g' \
89 -e 's@^USBLIB@#USBLIB@' Makefile
90 sed -i -e 's@usb_reset@ftdi_usb_reset@g' ujprog.c
91 make
92 install -m 4755 ujprog /usr/local/fpga-boot-load-prog/bin
93
94 cat > /etc/udev/rules.d/80-fpga-ulx3s.rules << EOF
95 # this is for usb-serial tty device
96 SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6015", \
97 MODE="664", GROUP="dialout"
98 # this is for ujprog libusb access
99 ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6015", \
100 GROUP="dialout", MODE="666"
101 EOF
102 cd ../..
103
104 # Steps to compile fujprog
105
106 ## Build fujprog
107
108 cd fujprog
109 git checkout v4.8
110 mkdir build; cd build
111 cmake -DCMAKE_INSTALL_PREFIX=/usr/local/fpga-boot-load-prog ..
112 make -j$(nproc)
113 make install
114 cd ../..
115
116 # Steps to compile xc3sprog
117
118 ## Build xc3sprog
119
120 cd xc3sprog
121 git checkout 99e7de20aa8323712e5f70ff74d2079d5fb45bc7
122 mkdir build; cd build
123 cmake -DCMAKE_INSTALL_PREFIX=/usr/local/fpga-boot-load-prog \
124 -DLIBFTDI_FOUND=YES -DLIBFTDI_INCLUDE_DIR="/usr/include/libftdi1" \
125 -DLIBFTDI_LIBRARIES="ftdi1" -DLIBUSB_FOUND=YES \
126 -DLIBUSB_INCLUDE_DIR="/usr/include" -DLIBUSB_LIBRARIES="usb" \
127 -DUSE_FTD2XX=OFF -DUSE_LIBUSB3380=OFF ..
128 make -j$(nproc)
129 make install
130 cd ../..
131
132 # Steps to compile ecpprog
133
134 ## Build ecpprog
135
136 cd ecpprog
137 git checkout 7212b56a9d2fc6de534e06636a1c6d8b0c6f80ab
138 cd ecpprog
139 make PREFIX=/usr/local/fpga-boot-load-prog
140 make PREFIX=/usr/local/fpga-boot-load-prog install
141 cd ../..
142
143 # Install udev rules for boards
144
145 cat > /etc/udev/rules.d/90-ecp5.rules << EOF
146 SUBSYSTEM=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6020", \
147 GROUP="users", MODE="0666"
148 EOF
149
150 cat > /etc/udev/rules.d/90-ftdi-orangecrab.rules << EOF
151 SUBSYSTEM=="usb", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="5af0", \
152 GROUP="users", MODE="0666"
153 EOF
154
155 cat > /etc/udev/rules.d/90-arty7-100t.rules << EOF
156 SUBSYSTEM=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010", \
157 GROUP="users", MODE="0666"
158 EOF
159
160 * Run finally this to update udev
161 * udevadm control --reload-rules && udevadm trigger
162 * usermod -a $USER -G plugdev
163