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