1 ############################################################################
2 # Copyright (C) 2011 by Martin Schmoelzer #
3 # <martin.schmoelzer@student.tuwien.ac.at> #
5 # This program is free software; you can redistribute it and/or modify #
6 # it under the terms of the GNU General Public License as published by #
7 # the Free Software Foundation; either version 2 of the License, or #
8 # (at your option) any later version. #
10 # This program is distributed in the hope that it will be useful, #
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
13 # GNU General Public License for more details. #
15 # You should have received a copy of the GNU General Public License #
16 # along with this program; if not, write to the #
17 # Free Software Foundation, Inc., #
18 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
19 ############################################################################
21 # Define the name of our tools. Some distributions (e. g. Fedora) prefix
22 # the SDCC executables, change this accordingly!
25 # Small Device C Compiler: http://sdcc.sourceforge.net/
28 # 8051 assembler, part of the SDCC software package.
29 AS = $(PREFIX)-sdas8051
31 # SDCC produces quite messy Intel HEX files. This tool is be used to re-format
32 # those files. It is not required for the firmware download functionality in
33 # the OpenOCD driver, but the resulting file is smaller.
34 PACKIHX = $(PREFIX)-packihx
36 # GNU binutils size. Used to print the size of the IHX file generated by SDCC.
39 # Source and header directories.
45 # Starting address of __xdata variables. Since the OpenULINK firmware does not
46 # use any of the isochronous interrupts, we can use the isochronous buffer space
51 CFLAGS = --std-sdcc99 --opt-code-size --model-small
52 LDFLAGS = --code-loc 0x0000 --code-size $(CODE_SIZE) --xram-loc $(XRAM_LOC) \
53 --xram-size $(XRAM_SIZE) --iram-size 256 --model-small
55 # list of base object files
56 OBJECTS = main.rel usb.rel protocol.rel jtag.rel delay.rel USBJmpTb.rel
57 HEADERS = $(INCLUDE_DIR)/main.h \
58 $(INCLUDE_DIR)/usb.h \
59 $(INCLUDE_DIR)/protocol.h \
60 $(INCLUDE_DIR)/jtag.h \
61 $(INCLUDE_DIR)/delay.h \
62 $(INCLUDE_DIR)/reg_ezusb.h \
64 $(INCLUDE_DIR)/msgtypes.h
66 # Disable all built-in rules.
69 # Targets which are executed even when identically named file is present.
72 all: ulink_firmware.ihx
73 $(SIZE) ulink_firmware.ihx
75 ulink_firmware.ihx: $(OBJECTS)
76 $(CC) -mmcs51 $(LDFLAGS) -o $@ $^
78 # Rebuild every C module (there are only 5 of them) if any header changes.
79 %.rel: $(SRC_DIR)/%.c $(HEADERS)
80 $(CC) -c $(CFLAGS) -mmcs51 -I$(INCLUDE_DIR) -o $@ $<
82 %.rel: $(SRC_DIR)/%.a51
86 rm -f *.asm *.lst *.rel *.rst *.sym *.ihx *.lnk *.map *.mem
88 hex: ulink_firmware.ihx
89 $(PACKIHX) ulink_firmware.ihx > ulink_firmware.hex