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, see <http://www.gnu.org/licenses/>. #
17 ############################################################################
19 # Define the name of our tools. Some distributions (e. g. Fedora) prefix
20 # the SDCC executables, change this accordingly!
23 # Small Device C Compiler: http://sdcc.sourceforge.net/
26 # 8051 assembler, part of the SDCC software package.
27 AS = $(PREFIX)-sdas8051
29 # SDCC produces quite messy Intel HEX files. This tool is be used to re-format
30 # those files. It is not required for the firmware download functionality in
31 # the OpenOCD driver, but the resulting file is smaller.
32 PACKIHX = $(PREFIX)-packihx
34 # GNU binutils size. Used to print the size of the IHX file generated by SDCC.
37 # Source and header directories.
43 # Starting address of __xdata variables. Since the OpenULINK firmware does not
44 # use any of the isochronous interrupts, we can use the isochronous buffer space
49 CFLAGS = --std-sdcc99 --opt-code-size --model-small
50 LDFLAGS = --code-loc 0x0000 --code-size $(CODE_SIZE) --xram-loc $(XRAM_LOC) \
51 --xram-size $(XRAM_SIZE) --iram-size 256 --model-small
53 # list of base object files
54 OBJECTS = main.rel usb.rel protocol.rel jtag.rel delay.rel USBJmpTb.rel
55 HEADERS = $(INCLUDE_DIR)/main.h \
56 $(INCLUDE_DIR)/usb.h \
57 $(INCLUDE_DIR)/protocol.h \
58 $(INCLUDE_DIR)/jtag.h \
59 $(INCLUDE_DIR)/delay.h \
60 $(INCLUDE_DIR)/reg_ezusb.h \
62 $(INCLUDE_DIR)/msgtypes.h
64 # Disable all built-in rules.
67 # Targets which are executed even when identically named file is present.
70 all: ulink_firmware.ihx
71 $(SIZE) ulink_firmware.ihx
73 ulink_firmware.ihx: $(OBJECTS)
74 $(CC) -mmcs51 $(LDFLAGS) -o $@ $^
76 # Rebuild every C module (there are only 5 of them) if any header changes.
77 %.rel: $(SRC_DIR)/%.c $(HEADERS)
78 $(CC) -c $(CFLAGS) -mmcs51 -I$(INCLUDE_DIR) -o $@ $<
80 %.rel: $(SRC_DIR)/%.a51
84 rm -f *.asm *.lst *.rel *.rst *.sym *.ihx *.lk *.map *.mem
86 hex: ulink_firmware.ihx
87 $(PACKIHX) ulink_firmware.ihx > ulink_firmware.hex