fxload fx2lp dev board
[fx2fw-sdcc] / Makefile
1 #-----------------------------------------------------------------------------\r
2 # Makefile for usb_jtag FX2 firmware\r
3 #-----------------------------------------------------------------------------\r
4 # Copyright 2007 Kolja Waschk, ixo.de\r
5 #-----------------------------------------------------------------------------\r
6 # This code is part of usbjtag. usbjtag is free software; you can redistribute\r
7 # it and/or modify it under the terms of the GNU General Public License as\r
8 # published by the Free Software Foundation; either version 2 of the License,\r
9 # or (at your option) any later version. usbjtag is distributed in the hope\r
10 # that it will be useful, but WITHOUT ANY WARRANTY; without even the implied\r
11 # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
12 # GNU General Public License for more details.  You should have received a\r
13 # copy of the GNU General Public License along with this program in the file\r
14 # COPYING; if not, write to the Free Software Foundation, Inc., 51 Franklin\r
15 # St, Fifth Floor, Boston, MA  02110-1301  USA\r
16 #-----------------------------------------------------------------------------\r
17 \r
18 LIBDIR=fx2\r
19 LIB=libfx2.lib\r
20 \r
21 ifeq (${HARDWARE},)\r
22   HARDWARE=hw_basic\r
23   #HARDWARE=hw_saxo_l\r
24   #HARDWARE=hw_xpcu_i\r
25   #HARDWARE=hw_xpcu_x\r
26 endif\r
27 \r
28 CC=sdcc\r
29 CFLAGS+=-mmcs51 --no-xinit-opt -I${LIBDIR} -D${HARDWARE}\r
30 \r
31 CFLAGS+=--opt-code-size\r
32 \r
33 AS=sdas8051\r
34 ASFLAGS+=-plosgff\r
35 \r
36 LDFLAGS=--code-loc 0x0000 --code-size 0x1800\r
37 LDFLAGS+=--xram-loc 0x1800 --xram-size 0x0800\r
38 LDFLAGS+=-Wl '-b USBDESCSEG = 0xE100'\r
39 LDFLAGS+=-L ${LIBDIR}\r
40 \r
41 %.rel : %.a51\r
42         $(AS) $(ASFLAGS) $<\r
43 \r
44 %.rel : %.c\r
45         $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@\r
46 \r
47 default: usbjtag.hex\r
48 \r
49 #%.iic : %.hex\r
50 #       ./hex2bix -ir -f 0xC2 -m 0xF000 -c 0x1 -o $@ $<\r
51 %.bix: %.hex\r
52         objcopy -I ihex -O binary $< $@\r
53 \r
54 usbjtag.hex: vectors.rel usbjtag.rel dscr.rel eeprom.rel ${HARDWARE}.rel startup.rel ${LIBDIR}/${LIB}\r
55         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+\r
56         packihx $@ > .tmp.hex\r
57         rm $@\r
58         mv .tmp.hex $@\r
59         ls -al $@\r
60 \r
61 ${LIBDIR}/${LIB}:\r
62         make -C ${LIBDIR}\r
63 \r
64 .PHONY: boot\r
65 boot: usbjtag.hex\r
66 #       -test -e /dev/usb_jtag    && /sbin/fxload -D /dev/usb_jtag    -I usbjtag.hex -t fx2\r
67 #       -test -e /dev/tracii_xl2  && /sbin/fxload -D /dev/tracii_xl2  -I usbjtag.hex -t fx2\r
68 #       -test -e /dev/xilinx_xpcu && /sbin/fxload -D /dev/xilinx_xpcu -I usbjtag.hex -t fx2\r
69         /sbin/fxload -t fx2lp -I usbjtag.hex -v -D `lsusb -d 04b4:8613 | cut -d: -f1 | awk '{ print "/dev/bus/usb/" $$2 "/" $$4 }'`\r
70         \r
71 \r
72 REF=/home/kawk/work/xilinx/xtern/xusbdfwu/xusbdfwu-1025.hex\r
73 \r
74 .PHONY: ref\r
75 ref: \r
76         -test -e /dev/usb_jtag    && /sbin/fxload -D /dev/usb_jtag    -I ${REF} -t fx2\r
77         -test -e /dev/tracii_xl2  && /sbin/fxload -D /dev/tracii_xl2  -I ${REF} -t fx2\r
78         -test -e /dev/xilinx_xpcu && /sbin/fxload -D /dev/xilinx_xpcu -I ${REF} -t fx2\r
79 \r
80 dscr.rel: dscr.a51\r
81 eeprom.rel: eeprom.c eeprom.h\r
82 usbjtag.rel: usbjtag.c hardware.h eeprom.h\r
83 ${HARDWARE}.rel: ${HARDWARE}.c hardware.h\r
84 \r
85 .PHONY: clean distclean\r
86 \r
87 clean:\r
88         make -C ${LIBDIR} clean\r
89         rm -f *.lst *.asm *.lib *.sym *.rel *.mem *.map *.rst *.lnk *.hex *.ihx *.iic\r
90 \r
91 distclean: clean\r
92 \r
93 \r
94 \r