version 4.1.0 from http://fpga4u.epfl.ch/wiki/FX2
[fx2fw-sdcc] / Makefile
1 #-----------------------------------------------------------------------------\r
2 \r
3 # Makefile for usb_jtag FX2 firmware\r
4 \r
5 #-----------------------------------------------------------------------------\r
6 \r
7 # Copyright 2007 Kolja Waschk, ixo.de\r
8 \r
9 #-----------------------------------------------------------------------------\r
10 \r
11 # This code is part of usbjtag. usbjtag is free software; you can redistribute\r
12 \r
13 # it and/or modify it under the terms of the GNU General Public License as\r
14 \r
15 # published by the Free Software Foundation; either version 2 of the License,\r
16 \r
17 # or (at your option) any later version. usbjtag is distributed in the hope\r
18 \r
19 # that it will be useful, but WITHOUT ANY WARRANTY; without even the implied\r
20 \r
21 # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
22 \r
23 # GNU General Public License for more details.  You should have received a\r
24 \r
25 # copy of the GNU General Public License along with this program in the file\r
26 \r
27 # COPYING; if not, write to the Free Software Foundation, Inc., 51 Franklin\r
28 \r
29 # St, Fifth Floor, Boston, MA  02110-1301  USA\r
30 \r
31 #-----------------------------------------------------------------------------\r
32 \r
33 \r
34 \r
35 LIBDIR=fx2\r
36 \r
37 LIB=libfx2.lib\r
38 \r
39 \r
40 \r
41 ifeq (${HARDWARE},)\r
42 \r
43   HARDWARE=hw_basic\r
44 \r
45   #HARDWARE=hw_xpcu_i\r
46 \r
47   #HARDWARE=hw_xpcu_x\r
48 \r
49 endif\r
50 \r
51 \r
52 \r
53 CC=sdcc\r
54 \r
55 CFLAGS+=-mmcs51 --no-xinit-opt -I${LIBDIR} -D${HARDWARE}\r
56 \r
57 CFLAGS+=--opt-code-size\r
58 \r
59 \r
60 \r
61 AS=asx8051\r
62 \r
63 ASFLAGS+=-plosgff\r
64 \r
65 \r
66 \r
67 LDFLAGS=--code-loc 0x0000 --code-size 0x1800\r
68 \r
69 LDFLAGS+=--xram-loc 0x1800 --xram-size 0x0800\r
70 \r
71 LDFLAGS+=-Wl '-b USBDESCSEG = 0xE100'\r
72 \r
73 LDFLAGS+=-L ${LIBDIR}\r
74 \r
75 \r
76 \r
77 %.rel : %.a51\r
78 \r
79         $(AS) $(ASFLAGS) $<\r
80 \r
81 \r
82 \r
83 %.rel : %.c\r
84 \r
85         $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@\r
86 \r
87 \r
88 \r
89 %.iic : %.hex\r
90 \r
91         ./hex2bix -ir -f 0xC2 -m 0xF000 -c 0x1 -o $@ $<\r
92 \r
93 \r
94 \r
95 default: usbjtag.iic\r
96 \r
97 \r
98 \r
99 usbjtag.hex: vectors.rel usbjtag.rel dscr.rel eeprom.rel ${HARDWARE}.rel startup.rel ${LIBDIR}/${LIB}\r
100 \r
101         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+\r
102 \r
103         packihx $@ > .tmp.hex\r
104 \r
105         rm $@\r
106 \r
107         mv .tmp.hex $@\r
108 \r
109 \r
110 \r
111 ${LIBDIR}/${LIB}:\r
112 \r
113         make -C ${LIBDIR}\r
114 \r
115 \r
116 \r
117 .PHONY: boot\r
118 \r
119 boot: usbjtag.hex\r
120 \r
121         -test -e /dev/usb_jtag    && /sbin/fxload -D /dev/usb_jtag    -I usbjtag.hex -t fx2\r
122 \r
123         -test -e /dev/tracii_xl2  && /sbin/fxload -D /dev/tracii_xl2  -I usbjtag.hex -t fx2\r
124 \r
125         -test -e /dev/xilinx_xpcu && /sbin/fxload -D /dev/xilinx_xpcu -I usbjtag.hex -t fx2\r
126 \r
127 \r
128 \r
129 REF=/home/kawk/work/xilinx/xtern/xusbdfwu/xusbdfwu-1025.hex\r
130 \r
131 \r
132 \r
133 .PHONY: ref\r
134 \r
135 ref: \r
136 \r
137         -test -e /dev/usb_jtag    && /sbin/fxload -D /dev/usb_jtag    -I ${REF} -t fx2\r
138 \r
139         -test -e /dev/tracii_xl2  && /sbin/fxload -D /dev/tracii_xl2  -I ${REF} -t fx2\r
140 \r
141         -test -e /dev/xilinx_xpcu && /sbin/fxload -D /dev/xilinx_xpcu -I ${REF} -t fx2\r
142 \r
143 \r
144 \r
145 dscr.rel: dscr.a51\r
146 \r
147 eeprom.rel: eeprom.c eeprom.h\r
148 \r
149 usbjtag.rel: usbjtag.c hardware.h eeprom.h\r
150 \r
151 ${HARDWARE}.rel: ${HARDWARE}.c hardware.h\r
152 \r
153 \r
154 \r
155 .PHONY: clean distclean\r
156 \r
157 \r
158 \r
159 clean:\r
160 \r
161         make -C ${LIBDIR} clean\r
162 \r
163         rm -f *.lst *.asm *.lib *.sym *.rel *.mem *.map *.rst *.lnk *.hex *.ihx *.iic\r
164 \r
165 \r
166 \r
167 distclean: clean\r
168 \r
169 \r
170 \r
171 \r
172 \r
173 \r
174 \r