1 # SPDX-License-Identifier: GPL-2.0-or-later
4 # Copyright (C) 2011 by Martin Schmoelzer
5 # <martin.schmoelzer@student.tuwien.ac.at>
8 # Define the name of our tools. Some distributions (e. g. Fedora) prefix
9 # the SDCC executables, change this accordingly!
12 # Small Device C Compiler: http://sdcc.sourceforge.net/
15 # 8051 assembler, part of the SDCC software package.
16 AS
= $(PREFIX
)-sdas8051
18 # SDCC produces quite messy Intel HEX files. This tool is be used to re-format
19 # those files. It is not required for the firmware download functionality in
20 # the OpenOCD driver, but the resulting file is smaller.
21 PACKIHX
= $(PREFIX
)-packihx
23 # GNU binutils size. Used to print the size of the IHX file generated by SDCC.
26 # Source and header directories.
32 # Starting address of __xdata variables. Since the OpenULINK firmware does not
33 # use any of the isochronous interrupts, we can use the isochronous buffer space
38 CFLAGS
= --std-sdcc99
--opt-code-size
--model-small
39 LDFLAGS
= --code-loc
0x0000 --code-size
$(CODE_SIZE
) --xram-loc
$(XRAM_LOC
) \
40 --xram-size
$(XRAM_SIZE
) --iram-size
256 --model-small
42 # list of base object files
43 OBJECTS
= main.rel usb.rel protocol.rel jtag.rel delay.rel USBJmpTb.rel
44 HEADERS
= $(INCLUDE_DIR
)/main.h \
45 $(INCLUDE_DIR
)/usb.h \
46 $(INCLUDE_DIR
)/protocol.h \
47 $(INCLUDE_DIR
)/jtag.h \
48 $(INCLUDE_DIR
)/delay.h \
49 $(INCLUDE_DIR
)/reg_ezusb.h \
51 $(INCLUDE_DIR
)/msgtypes.h
53 # Disable all built-in rules.
56 # Targets which are executed even when identically named file is present.
59 all: ulink_firmware.ihx
60 $(SIZE
) ulink_firmware.ihx
62 ulink_firmware.ihx
: $(OBJECTS
)
63 $(CC
) -mmcs51
$(LDFLAGS
) -o
$@
$^
65 # Rebuild every C module (there are only 5 of them) if any header changes.
66 %.rel
: $(SRC_DIR
)/%.c
$(HEADERS
)
67 $(CC
) -c
$(CFLAGS
) -mmcs51
-I
$(INCLUDE_DIR
) -o
$@
$<
69 %.rel
: $(SRC_DIR
)/%.a51
73 rm -f
*.asm
*.lst
*.rel
*.rst
*.sym
*.ihx
*.lk
*.map
*.mem
75 hex
: ulink_firmware.ihx
76 $(PACKIHX
) ulink_firmware.ihx
> ulink_firmware.hex