forked from svn2github/ixo-usb-jtag
-
Notifications
You must be signed in to change notification settings - Fork 30
/
Makefile
117 lines (90 loc) · 3.75 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#-----------------------------------------------------------------------------
# Makefile for usb_jtag FX2 firmware
#-----------------------------------------------------------------------------
# Copyright 2007 Kolja Waschk, ixo.de
# Copyright (C) 2017 Alexandru Gagniuc <mr.nuke.me@gmail.com>
#-----------------------------------------------------------------------------
# This code is part of usbjtag. usbjtag is free software; you can redistribute
# it and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the License,
# or (at your option) any later version. usbjtag is distributed in the hope
# that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. You should have received a
# copy of the GNU General Public License along with this program in the file
# COPYING; if not, write to the Free Software Foundation, Inc., 51 Franklin
# St, Fifth Floor, Boston, MA 02110-1301 USA
#-----------------------------------------------------------------------------
LIBDIR=fx2
LIB=libfx2.lib
SHELL := /bin/bash
# Specify a list of targets to build. Each target requires a hw_$target.c file
# to be present, and will produce a usbjtag-$target.hex output file.
TARGETS=basic dj_usb saxo_l xpcu_i xpcu_x nexys opsis nanodla
HEX_OUTPUTS=$(TARGETS:%=usbjtag-%.hex)
# Some distros add a prefix to sdcc binaries. For example, in fedora the
# binary is 'sdcc-sdcc'. Allow specifying this prefix via SDCC_PREFIX.
# Usage example: $ make SDCC_PREFIX=sdcc-
SDCC_PREFIX ?=
CC = $(SDCC_PREFIX)sdcc
AS = $(SDCC_PREFIX)sdas8051
AR = $(SDCC_PREFIX)sdar
PACKIHX=$(SDCC_PREFIX)packihx
CFLAGS+=-mmcs51 --no-xinit-opt -I${LIBDIR}
ASFLAGS+=-plosgff
LDFLAGS=--code-loc 0x0000 --code-size 0x1800
LDFLAGS+=--xram-loc 0x1800 --xram-size 0x0800
LDFLAGS+=-Wl '-b USBDESCSEG = 0xE100'
LDFLAGS+=-L ${LIBDIR}
%.rel : %.a51
$(AS) $(ASFLAGS) $<
%.rel : %.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
default: $(HEX_OUTPUTS)
dscr_%.a51: dscr.a51.in
export H="hw_$*~~~~~~~~~"; cat $^ | \
sed \
-e"s/\$$H0/$${H:0:1}/" \
-e"s/\$$H1/$${H:1:1}/" \
-e"s/\$$H2/$${H:2:1}/" \
-e"s/\$$H3/$${H:3:1}/" \
-e"s/\$$H4/$${H:4:1}/" \
-e"s/\$$H5/$${H:5:1}/" \
-e"s/\$$H6/$${H:6:1}/" \
-e"s/\$$H7/$${H:7:1}/" \
-e"s/\$$H8/$${H:8:1}/" \
-e"s/\$$H9/$${H:9:1}/" | \
sed \
-e"s/ .db '~, 0//" \
> $@
#%.iic : %.hex
# ./hex2bix -ir -f 0xC2 -m 0xF000 -c 0x1 -o $@ $<
%.bix: %.hex
objcopy -I ihex -O binary $< $@
temp-%.hex: vectors.rel usbjtag.rel dscr_%.rel eeprom.rel hw_%.rel startup.rel ${LIBDIR}/${LIB}
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+
usbjtag-%.hex: temp-%.hex
$(PACKIHX) $^ > $@
ls -al $@
${LIBDIR}/${LIB}:
make -C ${LIBDIR} CC=$(CC) AR=$(AR)
.PHONY: boot
boot: std.hex
-test -e /dev/usb_jtag && /sbin/fxload -D /dev/usb_jtag -I std.hex -t fx2
-test -e /dev/tracii_xl2 && /sbin/fxload -D /dev/tracii_xl2 -I std.hex -t fx2
-test -e /dev/xilinx_xpcu && /sbin/fxload -D /dev/xilinx_xpcu -I std.hex -t fx2
REF=/home/kawk/work/xilinx/xtern/xusbdfwu/xusbdfwu-1025.hex
.PHONY: ref
ref:
-test -e /dev/usb_jtag && /sbin/fxload -D /dev/usb_jtag -I ${REF} -t fx2
-test -e /dev/tracii_xl2 && /sbin/fxload -D /dev/tracii_xl2 -I ${REF} -t fx2
-test -e /dev/xilinx_xpcu && /sbin/fxload -D /dev/xilinx_xpcu -I ${REF} -t fx2
dscr_%.rel: dscr_%.a51
eeprom.rel: eeprom.c eeprom.h
usbjtag.rel: usbjtag.c hardware.h eeprom.h
hw_%.rel: hw_%.c hardware.h
.PHONY: clean distclean
clean:
make -C ${LIBDIR} clean
rm -f *.lst *.asm *.lib *.sym *.rel *.mem *.map *.rst *.lnk *.lk *.hex dscr_%.a51
distclean: clean