1 |
f57b548d
|
(no author)
|
# Hey Emacs, this is a -*- makefile -*-
|
2 |
|
|
#
|
3 |
a5a204c6
|
(no author)
|
# WinARM makefile for the FreeRTOS-demo on LPC2138
|
4 |
|
|
# based in information from the FreeRTOS LPC2106 example
|
5 |
|
|
#
|
6 |
f57b548d
|
(no author)
|
# by Martin Thomas, Kaiserslautern, Germany
|
7 |
|
|
# <eversmith@heizung-thomas.de>
|
8 |
|
|
#
|
9 |
|
|
# based on the WinAVR makefile written by Eric B. Weddington, J?rg Wunsch, et al.
|
10 |
|
|
# Released to the Public Domain
|
11 |
|
|
# Please read the make user manual!
|
12 |
|
|
#
|
13 |
|
|
#
|
14 |
|
|
# On command line:
|
15 |
|
|
#
|
16 |
|
|
# make all = Make software.
|
17 |
|
|
#
|
18 |
|
|
# make clean = Clean out built project files.
|
19 |
|
|
#
|
20 |
a5a204c6
|
(no author)
|
# make program = Download the hex file to the device
|
21 |
f57b548d
|
(no author)
|
#
|
22 |
|
|
# (TODO: make filename.s = Just compile filename.c into the assembler code only)
|
23 |
|
|
#
|
24 |
|
|
# To rebuild project do "make clean" then "make all".
|
25 |
|
|
#
|
26 |
|
|
# Changelog:
|
27 |
|
|
# - 17. Feb. 2005 - added thumb-interwork support (mth)
|
28 |
|
|
# - 28. Apr. 2005 - added C++ support (mth)
|
29 |
|
|
# - 29. Arp. 2005 - changed handling for lst-Filename (mth)
|
30 |
a5a204c6
|
(no author)
|
# - 1. Nov. 2005 - exception-vector placement options (mth)
|
31 |
|
|
# - 15. Nov. 2005 - added library-search-path (EXTRA_LIB...) (mth)
|
32 |
|
|
# - 2. Dec. 2005 - fixed ihex and binary file extensions (mth)
|
33 |
|
|
# - 22. Feb. 2006 - added AT91LIBNOWARN setting (mth)
|
34 |
|
|
# - 19. Apr. 2006 - option FLASH_TOOL (default lpc21isp); variable IMGEXT (mth)
|
35 |
|
|
# - 19. Mai. 2006 - USE_THUMB_MODE switch, ROM_RUN->RUN_FROM_ROM RAM_RUN->RUN_FROM_RAM
|
36 |
f57b548d
|
(no author)
|
|
37 |
4dc2cb5b
|
laforge
|
LIBRFID_DIR:=../../librfid/
|
38 |
f57b548d
|
(no author)
|
|
39 |
0c1766f4
|
(no author)
|
FLASH_TOOL = AT91FLASH
|
40 |
a5a204c6
|
(no author)
|
#FLASH_TOOL = UVISION
|
41 |
|
|
#FLASH_TOOL = OPENOCD
|
42 |
f57b548d
|
(no author)
|
|
43 |
|
|
# MCU name and submodel
|
44 |
a5a204c6
|
(no author)
|
MCU = arm7tdmi
|
45 |
e50e2f8c
|
Harald Welte
|
SUBMDL = AT91SAM7S64
|
46 |
|
|
#SUBMDL = AT91SAM7S128
|
47 |
f57b548d
|
(no author)
|
|
48 |
a5a204c6
|
(no author)
|
USE_THUMB_MODE = NO
|
49 |
|
|
#USE_THUMB_MODE = YES
|
50 |
f57b548d
|
(no author)
|
|
51 |
|
|
## Create ROM-Image (final)
|
52 |
5a8cd9fe
|
Harald Welte
|
RUN_MODE:=RUN_FROM_ROM
|
53 |
a5a204c6
|
(no author)
|
## Create RAM-Image (debugging) - not used in this example
|
54 |
|
|
#RUN_MODE=RUN_FROM_RAM
|
55 |
f57b548d
|
(no author)
|
|
56 |
b0317c72
|
(no author)
|
## We want to produce a full-flash image, but including DFU
|
57 |
a97e460b
|
laforge
|
IMGTYPE=-sam7dfu-app
|
58 |
b0317c72
|
(no author)
|
|
59 |
f57b548d
|
(no author)
|
# with / at end
|
60 |
9164ed93
|
(no author)
|
PATH_TO_LINKSCRIPTS=link/
|
61 |
f57b548d
|
(no author)
|
|
62 |
a5a204c6
|
(no author)
|
#### not used in this example:
|
63 |
|
|
## Exception-Vector placement only supported for "ROM_RUN"
|
64 |
|
|
## (placement settings ignored when using "RAM_RUN")
|
65 |
|
|
## - Exception vectors in ROM:
|
66 |
|
|
#VECTOR_LOCATION=VECTORS_IN_ROM
|
67 |
|
|
## - Exception vectors in RAM:
|
68 |
|
|
#VECTOR_LOCATION=VECTORS_IN_RAM
|
69 |
f57b548d
|
(no author)
|
|
70 |
|
|
# Target file name (without extension).
|
71 |
b8b8c2f6
|
(no author)
|
TARGET:=main_reqa
|
72 |
f57b548d
|
(no author)
|
|
73 |
e50e2f8c
|
Harald Welte
|
USBSTRINGS=src/picc/usb_strings_app.h src/pcd/usb_strings_app.h src/simtrace/usb_strings_app.h
|
74 |
89c40594
|
laforge
|
|
75 |
f57b548d
|
(no author)
|
# List C source files here. (C dependencies are automatically generated.)
|
76 |
|
|
# use file-extension c for "c-only"-files
|
77 |
a5a204c6
|
(no author)
|
SRC =
|
78 |
f57b548d
|
(no author)
|
|
79 |
|
|
# List C source files here which must be compiled in ARM-Mode.
|
80 |
|
|
# use file-extension c for "c-only"-files
|
81 |
520784c7
|
(no author)
|
|
82 |
|
|
# First, build library ...
|
83 |
2a2d6309
|
(no author)
|
SRCARM = lib/lib_AT91SAM7.c
|
84 |
|
|
ifdef DEBUG
|
85 |
|
|
SRCARM += lib/vsprintf.c lib/ctype.c lib/string.c
|
86 |
|
|
endif
|
87 |
f57b548d
|
(no author)
|
|
88 |
520784c7
|
(no author)
|
# then, OS ...
|
89 |
|
|
SRCARM += src/os/pcd_enumerate.c src/os/fifo.c src/os/dbgu.c \
|
90 |
|
|
src/os/led.c src/os/req_ctx.c src/os/trigger.c \
|
91 |
|
|
src/os/main.c src/os/syscalls.c src/os/usb_handler.c \
|
92 |
a97e460b
|
laforge
|
src/os/usb_benchmark.c src/os/tc_cdiv.c src/os/pit.c \
|
93 |
778802a3
|
laforge
|
src/os/pwm.c src/os/pio_irq.c src/os/usbcmd_generic.c \
|
94 |
f21e08aa
|
meri
|
src/os/wdt.c src/os/blinkcode.c src/os/system_irq.c \
|
95 |
|
|
src/os/flash.c
|
96 |
520784c7
|
(no author)
|
|
97 |
7b041f45
|
(no author)
|
ifeq ($(BOARD), PCD)
|
98 |
520784c7
|
(no author)
|
# PCD support code
|
99 |
28eb4a57
|
laforge
|
SRCARM += src/pcd/rc632.c src/pcd/rc632_highlevel.c
|
100 |
520784c7
|
(no author)
|
# finally, the actual main application
|
101 |
|
|
SRCARM += src/pcd/$(TARGET).c
|
102 |
7b041f45
|
(no author)
|
endif
|
103 |
|
|
|
104 |
|
|
ifeq ($(BOARD), PICC)
|
105 |
520784c7
|
(no author)
|
# PICC support code
|
106 |
29d8974f
|
(no author)
|
SRCARM += src/picc/tc_fdt.c src/picc/ssc_picc.c src/picc/adc.c \
|
107 |
|
|
src/picc/decoder.c src/picc/decoder_miller.c \
|
108 |
bfff30bf
|
laforge
|
src/picc/load_modulation.c src/picc/tc_cdiv_sync.c \
|
109 |
6c6b1878
|
laforge
|
src/picc/decoder_nrzl.c src/picc/da.c src/picc/pll.c \
|
110 |
514b0f72
|
laforge
|
src/picc/openpicc.c
|
111 |
520784c7
|
(no author)
|
# finally, the actual main application
|
112 |
|
|
SRCARM += src/picc/$(TARGET).c
|
113 |
|
|
endif
|
114 |
|
|
|
115 |
e50e2f8c
|
Harald Welte
|
ifeq ($(BOARD), SIMTRACE)
|
116 |
9f120cdf
|
Harald Welte
|
SUBMDL = AT91SAM7S128
|
117 |
ff741ee3
|
Harald Welte
|
TARGET := main_simtrace
|
118 |
cda126a7
|
Harald Welte
|
SRCARM += src/simtrace/iso7816_uart.c src/simtrace/tc_etu.c \
|
119 |
bb28e090
|
Harald Welte
|
src/simtrace/sim_switch.c src/simtrace/spi_flash.c \
|
120 |
|
|
src/simtrace/prod_info.c
|
121 |
e50e2f8c
|
Harald Welte
|
SRCARM += src/simtrace/$(TARGET).c
|
122 |
|
|
endif
|
123 |
|
|
|
124 |
9d0d7022
|
(no author)
|
|
125 |
f57b548d
|
(no author)
|
# List C++ source files here.
|
126 |
|
|
# use file-extension cpp for C++-files (use extension .cpp)
|
127 |
|
|
CPPSRC =
|
128 |
|
|
|
129 |
|
|
# List C++ source files here which must be compiled in ARM-Mode.
|
130 |
|
|
# use file-extension cpp for C++-files (use extension .cpp)
|
131 |
|
|
#CPPSRCARM = $(TARGET).cpp
|
132 |
|
|
CPPSRCARM =
|
133 |
|
|
|
134 |
|
|
# List Assembler source files here.
|
135 |
|
|
# Make them always end in a capital .S. Files ending in a lowercase .s
|
136 |
|
|
# will not be considered source files but generated files (assembler
|
137 |
|
|
# output from the compiler), and will be deleted upon "make clean"!
|
138 |
|
|
# Even though the DOS/Win* filesystem matches both .s and .S the same,
|
139 |
|
|
# it will preserve the spelling of the filenames, and gcc itself does
|
140 |
|
|
# care about how the name is spelled on its command-line.
|
141 |
|
|
ASRC =
|
142 |
|
|
|
143 |
2a2d6309
|
(no author)
|
ASRCLIB = lib/changebit.S lib/clearbit.S lib/setbit.S lib/testchangebit.S \
|
144 |
|
|
lib/testclearbit.S lib/testsetbit.S
|
145 |
|
|
ifdef DEBUG
|
146 |
a875f28d
|
(no author)
|
#ASRCLIB += lib/memcpy.S lib/memset.S lib/lib1funcs.S lib/div64.S
|
147 |
|
|
ASRCLIB += lib/lib1funcs.S lib/div64.S
|
148 |
2a2d6309
|
(no author)
|
endif
|
149 |
caf50003
|
(no author)
|
|
150 |
f57b548d
|
(no author)
|
# List Assembler source files here which must be assembled in ARM-Mode..
|
151 |
a97e460b
|
laforge
|
ASRCARM = src/start/Cstartup_app.S $(ASRCLIB)
|
152 |
a5a204c6
|
(no author)
|
|
153 |
|
|
## Output format. (can be ihex or binary)
|
154 |
|
|
## (binary i.e. for openocd and SAM-BA, hex i.e. for lpc21isp and uVision)
|
155 |
|
|
#FORMAT = ihex
|
156 |
|
|
FORMAT = binary
|
157 |
f57b548d
|
(no author)
|
|
158 |
|
|
# Optimization level, can be [0, 1, 2, 3, s].
|
159 |
|
|
# 0 = turn off optimization. s = optimize for size.
|
160 |
|
|
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
161 |
514b0f72
|
laforge
|
OPT = 2
|
162 |
f57b548d
|
(no author)
|
#OPT = 0
|
163 |
|
|
|
164 |
|
|
# Debugging format.
|
165 |
|
|
# Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
|
166 |
|
|
# AVR (extended) COFF requires stabs, plus an avr-objcopy run.
|
167 |
2a2d6309
|
(no author)
|
#DEBUGF = stabs
|
168 |
|
|
DEBUGF = dwarf-2
|
169 |
f57b548d
|
(no author)
|
|
170 |
|
|
# List any extra directories to look for include files here.
|
171 |
|
|
# Each directory must be seperated by a space.
|
172 |
a5a204c6
|
(no author)
|
#### FreeRTOS
|
173 |
1d505fbf
|
laforge
|
EXTRAINCDIRS = $(LIBRFID_DIR)/include/
|
174 |
a5a204c6
|
(no author)
|
|
175 |
|
|
# List any extra directories to look for library files here.
|
176 |
|
|
# Each directory must be seperated by a space.
|
177 |
|
|
#EXTRA_LIBDIRS = ../arm7_efsl_0_2_4
|
178 |
1d505fbf
|
laforge
|
EXTRA_LIBDIRS = $(LIBRFID_DIR)/src/.libs/
|
179 |
a5a204c6
|
(no author)
|
|
180 |
|
|
## Using the Atmel AT91_lib produces warning with
|
181 |
|
|
## the default warning-levels.
|
182 |
|
|
## yes - disable these warnings; no - keep default settings
|
183 |
|
|
AT91LIBNOWARN = yes
|
184 |
|
|
#AT91LIBNOWARN = no
|
185 |
f57b548d
|
(no author)
|
|
186 |
|
|
# Compiler flag to set the C Standard level.
|
187 |
|
|
# c89 - "ANSI" C
|
188 |
|
|
# gnu89 - c89 plus GCC extensions
|
189 |
|
|
# c99 - ISO C99 standard (not yet fully implemented)
|
190 |
|
|
# gnu99 - c99 plus GCC extensions
|
191 |
|
|
CSTANDARD = -std=gnu99
|
192 |
|
|
|
193 |
|
|
# Place -D or -U options for C here
|
194 |
2a2d6309
|
(no author)
|
CDEFS = -D$(RUN_MODE) -D__MS_types__ -D__LIBRFID__
|
195 |
|
|
|
196 |
|
|
ifdef DEBUG
|
197 |
81416e6a
|
(no author)
|
CDEFS += -DDEBUG
|
198 |
2a2d6309
|
(no author)
|
endif
|
199 |
|
|
|
200 |
9d0d7022
|
(no author)
|
ifdef OLIMEX
|
201 |
|
|
CDEFS += -DOLIMEX
|
202 |
|
|
endif
|
203 |
f57b548d
|
(no author)
|
|
204 |
7b041f45
|
(no author)
|
ifeq ($(BOARD),PICC)
|
205 |
|
|
CDEFS += -DPICC
|
206 |
5872753e
|
laforge
|
CINCS = -Isrc/picc
|
207 |
7b041f45
|
(no author)
|
endif
|
208 |
|
|
|
209 |
|
|
ifeq ($(BOARD),PCD)
|
210 |
|
|
CDEFS += -DPCD
|
211 |
5872753e
|
laforge
|
CINCS = -Isrc/pcd
|
212 |
7b041f45
|
(no author)
|
endif
|
213 |
|
|
|
214 |
e50e2f8c
|
Harald Welte
|
ifeq ($(BOARD),SIMTRACE)
|
215 |
|
|
CDEFS += -DSIMTRACE
|
216 |
|
|
CINCS = -Isrc/simtrace
|
217 |
|
|
endif
|
218 |
|
|
|
219 |
|
|
|
220 |
f57b548d
|
(no author)
|
# Place -I options here
|
221 |
5872753e
|
laforge
|
CINCS += -Iinclude -Isrc
|
222 |
f57b548d
|
(no author)
|
|
223 |
|
|
# Place -D or -U options for ASM here
|
224 |
a5a204c6
|
(no author)
|
ADEFS = -D$(RUN_MODE)
|
225 |
|
|
|
226 |
|
|
ifdef VECTOR_LOCATION
|
227 |
|
|
CDEFS += -D$(VECTOR_LOCATION)
|
228 |
|
|
ADEFS += -D$(VECTOR_LOCATION)
|
229 |
|
|
endif
|
230 |
|
|
|
231 |
9164ed93
|
(no author)
|
CDEFS += -D__$(SUBMDL)__
|
232 |
|
|
ADEFS += -D__$(SUBMDL)__
|
233 |
f57b548d
|
(no author)
|
|
234 |
|
|
|
235 |
|
|
# Compiler flags.
|
236 |
|
|
# -g*: generate debugging information
|
237 |
|
|
# -O*: optimization level
|
238 |
|
|
# -f...: tuning, see GCC manual and avr-libc documentation
|
239 |
|
|
# -Wall...: warning level
|
240 |
|
|
# -Wa,...: tell GCC to pass this to the assembler.
|
241 |
|
|
# -adhlns...: create assembler listing
|
242 |
|
|
#
|
243 |
|
|
# Flags for C and C++ (arm-elf-gcc/arm-elf-g++)
|
244 |
2a2d6309
|
(no author)
|
CFLAGS = -g$(DEBUGF)
|
245 |
f57b548d
|
(no author)
|
CFLAGS += $(CDEFS) $(CINCS)
|
246 |
|
|
CFLAGS += -O$(OPT)
|
247 |
a5a204c6
|
(no author)
|
CFLAGS += -Wall -Wextra -Wcast-align -Wimplicit -Wunused
|
248 |
f57b548d
|
(no author)
|
CFLAGS += -Wpointer-arith -Wswitch
|
249 |
a5a204c6
|
(no author)
|
CFLAGS += -Wredundant-decls -Wreturn-type -Wshadow
|
250 |
|
|
CFLAGS += -Wbad-function-cast -Wsign-compare -Waggregate-return
|
251 |
f57b548d
|
(no author)
|
CFLAGS += -Wa,-adhlns=$(subst $(suffix $<),.lst,$<)
|
252 |
|
|
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
253 |
dda0896d
|
Harald Welte
|
CFLAGS += -ffunction-sections -fdata-sections
|
254 |
f57b548d
|
(no author)
|
|
255 |
|
|
# flags only for C
|
256 |
|
|
CONLYFLAGS += -Wnested-externs
|
257 |
|
|
CONLYFLAGS += $(CSTANDARD)
|
258 |
|
|
|
259 |
a5a204c6
|
(no author)
|
ifneq ($(AT91LIBNOWARN),yes)
|
260 |
|
|
#AT91-lib warnings with:
|
261 |
|
|
CFLAGS += -Wcast-qual
|
262 |
|
|
CONLYFLAGS += -Wmissing-prototypes
|
263 |
|
|
CONLYFLAGS += -Wstrict-prototypes
|
264 |
|
|
CONLYFLAGS += -Wmissing-declarations
|
265 |
|
|
endif
|
266 |
f57b548d
|
(no author)
|
|
267 |
|
|
# flags only for C++ (arm-elf-g++)
|
268 |
|
|
# CPPFLAGS = -fno-rtti -fno-exceptions
|
269 |
|
|
CPPFLAGS =
|
270 |
|
|
|
271 |
|
|
# Assembler flags.
|
272 |
a5a204c6
|
(no author)
|
# -Wa,...: tell GCC to pass this to the assembler.
|
273 |
|
|
# -ahlns: create listing
|
274 |
2a2d6309
|
(no author)
|
# -g$(DEBUGF): have the assembler create line number information
|
275 |
|
|
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:.S=.lst),--g$(DEBUGF) -Iinclude/ -D__ASSEMBLY__
|
276 |
a5a204c6
|
(no author)
|
|
277 |
f57b548d
|
(no author)
|
|
278 |
|
|
#Additional libraries.
|
279 |
|
|
|
280 |
a5a204c6
|
(no author)
|
# Extra libraries
|
281 |
|
|
# Each library-name must be seperated by a space.
|
282 |
|
|
# To add libxyz.a, libabc.a and libefsl.a:
|
283 |
|
|
# EXTRA_LIBS = xyz abc efsl
|
284 |
|
|
#EXTRA_LIBS = efsl
|
285 |
f411c7b5
|
laforge
|
ifeq ($(TARGET),main_librfid)
|
286 |
28eb4a57
|
laforge
|
EXTRA_LIBS = rfid
|
287 |
f411c7b5
|
laforge
|
endif
|
288 |
a5a204c6
|
(no author)
|
|
289 |
0b016392
|
meri
|
ifeq ($(TARGET),main_reqa)
|
290 |
|
|
EXTRA_LIBS = rfid
|
291 |
|
|
endif
|
292 |
|
|
|
293 |
6f440df0
|
meri
|
ifeq ($(TARGET),main_presence)
|
294 |
|
|
EXTRA_LIBS = rfid
|
295 |
|
|
endif
|
296 |
|
|
|
297 |
c68c113e
|
laforge
|
ifeq ($(TARGET),main_mifare)
|
298 |
|
|
EXTRA_LIBS = rfid
|
299 |
|
|
endif
|
300 |
|
|
|
301 |
f57b548d
|
(no author)
|
#Support for newlibc-lpc (file: libnewlibc-lpc.a)
|
302 |
|
|
#NEWLIBLPC = -lnewlib-lpc
|
303 |
|
|
|
304 |
2a2d6309
|
(no author)
|
MATH_LIB = #-lm
|
305 |
f57b548d
|
(no author)
|
|
306 |
|
|
# CPLUSPLUS_LIB = -lstdc++
|
307 |
|
|
|
308 |
a5a204c6
|
(no author)
|
|
309 |
f57b548d
|
(no author)
|
# Linker flags.
|
310 |
|
|
# -Wl,...: tell GCC to pass this to linker.
|
311 |
|
|
# -Map: create map file
|
312 |
|
|
# --cref: add cross reference to map file
|
313 |
|
|
LDFLAGS = -nostartfiles -Wl,-Map=$(TARGET).map,--cref
|
314 |
|
|
LDFLAGS += $(NEWLIBLPC) $(MATH_LIB)
|
315 |
|
|
LDFLAGS += -lc -lgcc
|
316 |
|
|
LDFLAGS += $(CPLUSPLUS_LIB)
|
317 |
a5a204c6
|
(no author)
|
LDFLAGS += $(patsubst %,-L%,$(EXTRA_LIBDIRS))
|
318 |
|
|
LDFLAGS += $(patsubst %,-l%,$(EXTRA_LIBS))
|
319 |
dda0896d
|
Harald Welte
|
LDFLAGS += -Wl,--gc-sections -Wl,--entry=_startup
|
320 |
f57b548d
|
(no author)
|
|
321 |
a5a204c6
|
(no author)
|
# Set Linker-Script Depending On Selected Memory and Controller
|
322 |
|
|
ifeq ($(RUN_MODE),RUN_FROM_RAM)
|
323 |
5a8cd9fe
|
Harald Welte
|
LDFLAGS +=-T$(PATH_TO_LINKSCRIPTS)$(SUBMDL)-RAM$(IMGTYPE).ld
|
324 |
f57b548d
|
(no author)
|
else
|
325 |
b0317c72
|
(no author)
|
LDFLAGS +=-T$(PATH_TO_LINKSCRIPTS)$(SUBMDL)-ROM$(IMGTYPE).ld
|
326 |
f57b548d
|
(no author)
|
endif
|
327 |
|
|
|
328 |
|
|
|
329 |
|
|
# ---------------------------------------------------------------------------
|
330 |
|
|
# Flash-Programming support using lpc21isp by Martin Maurer
|
331 |
a5a204c6
|
(no author)
|
# only for Philips LPC and Analog ADuC ARMs
|
332 |
|
|
#
|
333 |
f57b548d
|
(no author)
|
# Settings and variables:
|
334 |
|
|
#LPC21ISP = lpc21isp
|
335 |
a5a204c6
|
(no author)
|
LPC21ISP = lpc21isp
|
336 |
f57b548d
|
(no author)
|
LPC21ISP_PORT = com1
|
337 |
a5a204c6
|
(no author)
|
LPC21ISP_BAUD = 38400
|
338 |
|
|
LPC21ISP_XTAL = 12000
|
339 |
f57b548d
|
(no author)
|
LPC21ISP_FLASHFILE = $(TARGET).hex
|
340 |
|
|
# verbose output:
|
341 |
a5a204c6
|
(no author)
|
#LPC21ISP_DEBUG = -debug
|
342 |
f57b548d
|
(no author)
|
# enter bootloader via RS232 DTR/RTS (only if hardware supports this
|
343 |
|
|
# feature - see Philips AppNote):
|
344 |
|
|
LPC21ISP_CONTROL = -control
|
345 |
|
|
# ---------------------------------------------------------------------------
|
346 |
|
|
|
347 |
a5a204c6
|
(no author)
|
|
348 |
f57b548d
|
(no author)
|
# Define directories, if needed.
|
349 |
|
|
## DIRARM = c:/WinARM/
|
350 |
|
|
## DIRARMBIN = $(DIRAVR)/bin/
|
351 |
|
|
## DIRAVRUTILS = $(DIRAVR)/utils/bin/
|
352 |
|
|
|
353 |
|
|
# Define programs and commands.
|
354 |
|
|
SHELL = sh
|
355 |
dc2983d9
|
Denis 'GNUtoo' Carikli
|
CROSS_COMPILE ?= arm-elf-
|
356 |
|
|
CC = $(CROSS_COMPILE)gcc
|
357 |
|
|
CPP = $(CROSS_COMPILE)g++
|
358 |
|
|
OBJCOPY = $(CROSS_COMPILE)objcopy
|
359 |
|
|
OBJDUMP = $(CROSS_COMPILE)objdump
|
360 |
|
|
SIZE = $(CROSS_COMPILE)size
|
361 |
|
|
NM = $(CROSS_COMPILE)nm
|
362 |
f57b548d
|
(no author)
|
REMOVE = rm -f
|
363 |
|
|
COPY = cp
|
364 |
|
|
|
365 |
|
|
# Define Messages
|
366 |
|
|
# English
|
367 |
|
|
MSG_ERRORS_NONE = Errors: none
|
368 |
a5a204c6
|
(no author)
|
MSG_BEGIN = "-------- begin (mode: $(RUN_MODE)) --------"
|
369 |
f57b548d
|
(no author)
|
MSG_END = -------- end --------
|
370 |
|
|
MSG_SIZE_BEFORE = Size before:
|
371 |
|
|
MSG_SIZE_AFTER = Size after:
|
372 |
|
|
MSG_FLASH = Creating load file for Flash:
|
373 |
|
|
MSG_EXTENDED_LISTING = Creating Extended Listing:
|
374 |
|
|
MSG_SYMBOL_TABLE = Creating Symbol Table:
|
375 |
|
|
MSG_LINKING = Linking:
|
376 |
|
|
MSG_COMPILING = Compiling C:
|
377 |
|
|
MSG_COMPILING_ARM = "Compiling C (ARM-only):"
|
378 |
|
|
MSG_COMPILINGCPP = Compiling C++:
|
379 |
|
|
MSG_COMPILINGCPP_ARM = "Compiling C++ (ARM-only):"
|
380 |
|
|
MSG_ASSEMBLING = Assembling:
|
381 |
|
|
MSG_ASSEMBLING_ARM = "Assembling (ARM-only):"
|
382 |
|
|
MSG_CLEANING = Cleaning project:
|
383 |
a5a204c6
|
(no author)
|
MSG_FORMATERROR = Can not handle output-format
|
384 |
f57b548d
|
(no author)
|
MSG_LPC21_RESETREMINDER = You may have to bring the target in bootloader-mode now.
|
385 |
|
|
|
386 |
|
|
# Define all object files.
|
387 |
|
|
COBJ = $(SRC:.c=.o)
|
388 |
|
|
AOBJ = $(ASRC:.S=.o)
|
389 |
|
|
COBJARM = $(SRCARM:.c=.o)
|
390 |
|
|
AOBJARM = $(ASRCARM:.S=.o)
|
391 |
|
|
CPPOBJ = $(CPPSRC:.cpp=.o)
|
392 |
|
|
CPPOBJARM = $(CPPSRCARM:.cpp=.o)
|
393 |
|
|
|
394 |
|
|
# Define all listing files.
|
395 |
|
|
LST = $(ASRC:.S=.lst) $(ASRCARM:.S=.lst) $(SRC:.c=.lst) $(SRCARM:.c=.lst)
|
396 |
|
|
LST += $(CPPSRC:.cpp=.lst) $(CPPSRCARM:.cpp=.lst)
|
397 |
|
|
|
398 |
|
|
# Compiler flags to generate dependency files.
|
399 |
|
|
### GENDEPFLAGS = -Wp,-M,-MP,-MT,$(*F).o,-MF,.dep/$(@F).d
|
400 |
|
|
GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
|
401 |
|
|
|
402 |
|
|
# Combine all necessary flags and optional flags.
|
403 |
|
|
# Add target processor to flags.
|
404 |
a5a204c6
|
(no author)
|
ALL_CFLAGS = -mcpu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
|
405 |
|
|
ALL_ASFLAGS = -mcpu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
|
406 |
f57b548d
|
(no author)
|
|
407 |
|
|
|
408 |
|
|
# Default target.
|
409 |
|
|
all: begin gccversion sizebefore build sizeafter finished end
|
410 |
|
|
|
411 |
a5a204c6
|
(no author)
|
ifeq ($(FORMAT),ihex)
|
412 |
f57b548d
|
(no author)
|
build: elf hex lss sym
|
413 |
a5a204c6
|
(no author)
|
hex: $(TARGET).hex
|
414 |
|
|
IMGEXT=hex
|
415 |
|
|
else
|
416 |
|
|
ifeq ($(FORMAT),binary)
|
417 |
|
|
build: elf bin lss sym
|
418 |
|
|
bin: $(TARGET).bin
|
419 |
|
|
IMGEXT=bin
|
420 |
|
|
else
|
421 |
|
|
$(error "$(MSG_FORMATERROR) $(FORMAT)")
|
422 |
|
|
endif
|
423 |
|
|
endif
|
424 |
f57b548d
|
(no author)
|
|
425 |
|
|
elf: $(TARGET).elf
|
426 |
|
|
lss: $(TARGET).lss
|
427 |
|
|
sym: $(TARGET).sym
|
428 |
|
|
|
429 |
|
|
# Eye candy.
|
430 |
|
|
begin:
|
431 |
|
|
@echo
|
432 |
|
|
@echo $(MSG_BEGIN)
|
433 |
|
|
|
434 |
|
|
finished:
|
435 |
|
|
@echo $(MSG_ERRORS_NONE)
|
436 |
|
|
|
437 |
|
|
end:
|
438 |
|
|
@echo $(MSG_END)
|
439 |
|
|
@echo
|
440 |
|
|
|
441 |
|
|
|
442 |
|
|
# Display size of file.
|
443 |
|
|
HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
|
444 |
|
|
ELFSIZE = $(SIZE) -A $(TARGET).elf
|
445 |
|
|
sizebefore:
|
446 |
|
|
@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
|
447 |
|
|
|
448 |
|
|
sizeafter:
|
449 |
|
|
@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
|
450 |
|
|
|
451 |
|
|
|
452 |
|
|
# Display compiler version information.
|
453 |
|
|
gccversion :
|
454 |
|
|
@$(CC) --version
|
455 |
|
|
|
456 |
|
|
|
457 |
|
|
# Program the device.
|
458 |
0c1766f4
|
(no author)
|
# Program the device by using our relais card robot over USB
|
459 |
|
|
ifeq ($(FLASH_TOOL),AT91FLASH)
|
460 |
|
|
program: $(TARGET).$(IMGEXT)
|
461 |
|
|
ls -l $(TARGET).$(IMGEXT)
|
462 |
|
|
at91flash $(TARGET).$(IMGEXT)
|
463 |
|
|
else
|
464 |
a5a204c6
|
(no author)
|
ifeq ($(FLASH_TOOL),UVISION)
|
465 |
|
|
# Program the device with Keil's uVision (needs configured uVision-Workspace).
|
466 |
|
|
program: $(TARGET).$(IMGEXT)
|
467 |
|
|
@echo
|
468 |
|
|
@echo "Programming with uVision"
|
469 |
|
|
C:\Keil\uv3\Uv3.exe -f uvisionflash.Uv2 -ouvisionflash.txt
|
470 |
|
|
else
|
471 |
|
|
ifeq ($(FLASH_TOOL),OPENOCD)
|
472 |
|
|
# Program the device with Dominic Rath's OPENOCD in "batch-mode", needs cfg and "reset-script".
|
473 |
|
|
program: $(TARGET).$(IMGEXT)
|
474 |
f57b548d
|
(no author)
|
@echo
|
475 |
a5a204c6
|
(no author)
|
@echo "Programming with OPENOCD"
|
476 |
|
|
C:\WinARM\utils\openocd\openocd_svn59\openocd.exe -f oocd_sam7_flash.cfg
|
477 |
f57b548d
|
(no author)
|
else
|
478 |
|
|
# Program the device. - lpc21isp will not work for SAM7
|
479 |
a5a204c6
|
(no author)
|
program: $(TARGET).$(IMGEXT)
|
480 |
f57b548d
|
(no author)
|
@echo
|
481 |
|
|
@echo $(MSG_LPC21_RESETREMINDER)
|
482 |
a5a204c6
|
(no author)
|
$(LPC21ISP) $(LPC21ISP_OPTIONS) $(LPC21ISP_DEBUG) $(LPC21ISP_FLASHFILE) $(LPC21ISP_PORT) $(LPC21ISP_BAUD) $(LPC21ISP_XTAL)
|
483 |
|
|
endif
|
484 |
f57b548d
|
(no author)
|
endif
|
485 |
0c1766f4
|
(no author)
|
endif
|
486 |
f57b548d
|
(no author)
|
|
487 |
|
|
|
488 |
a5a204c6
|
(no author)
|
# Create final output file (.hex) from ELF output file.
|
489 |
f57b548d
|
(no author)
|
%.hex: %.elf
|
490 |
|
|
@echo
|
491 |
|
|
@echo $(MSG_FLASH) $@
|
492 |
|
|
$(OBJCOPY) -O $(FORMAT) $< $@
|
493 |
a5a204c6
|
(no author)
|
|
494 |
|
|
# Create final output file (.bin) from ELF output file.
|
495 |
|
|
%.bin: %.elf
|
496 |
|
|
@echo
|
497 |
|
|
@echo $(MSG_FLASH) $@
|
498 |
|
|
$(OBJCOPY) -O $(FORMAT) $< $@
|
499 |
f57b548d
|
(no author)
|
|
500 |
|
|
|
501 |
|
|
# Create extended listing file from ELF output file.
|
502 |
|
|
# testing: option -C
|
503 |
|
|
%.lss: %.elf
|
504 |
|
|
@echo
|
505 |
|
|
@echo $(MSG_EXTENDED_LISTING) $@
|
506 |
|
|
$(OBJDUMP) -h -S -C $< > $@
|
507 |
|
|
|
508 |
|
|
|
509 |
|
|
# Create a symbol table from ELF output file.
|
510 |
|
|
%.sym: %.elf
|
511 |
|
|
@echo
|
512 |
|
|
@echo $(MSG_SYMBOL_TABLE) $@
|
513 |
|
|
$(NM) -n $< > $@
|
514 |
|
|
|
515 |
|
|
|
516 |
|
|
# Link: create ELF output file from object files.
|
517 |
|
|
.SECONDARY : $(TARGET).elf
|
518 |
|
|
.PRECIOUS : $(AOBJARM) $(AOBJ) $(COBJARM) $(COBJ) $(CPPOBJ) $(CPPOBJARM)
|
519 |
|
|
%.elf: $(AOBJARM) $(AOBJ) $(COBJARM) $(COBJ) $(CPPOBJ) $(CPPOBJARM)
|
520 |
|
|
@echo
|
521 |
|
|
@echo $(MSG_LINKING) $@
|
522 |
a5a204c6
|
(no author)
|
$(CC) $(ALL_CFLAGS) $(AOBJARM) $(AOBJ) $(COBJARM) $(COBJ) $(CPPOBJ) $(CPPOBJARM) --output $@ $(LDFLAGS)
|
523 |
f57b548d
|
(no author)
|
|
524 |
|
|
# Compile: create object files from C source files. ARM/Thumb
|
525 |
|
|
$(COBJ) : %.o : %.c
|
526 |
|
|
@echo
|
527 |
|
|
@echo $(MSG_COMPILING) $<
|
528 |
a5a204c6
|
(no author)
|
$(CC) -c $(ALL_CFLAGS) $(CONLYFLAGS) $< -o $@
|
529 |
f57b548d
|
(no author)
|
|
530 |
|
|
# Compile: create object files from C source files. ARM-only
|
531 |
89c40594
|
laforge
|
$(COBJARM) : %.o : %.c include/compile.h $(USBSTRINGS)
|
532 |
f57b548d
|
(no author)
|
@echo
|
533 |
|
|
@echo $(MSG_COMPILING_ARM) $<
|
534 |
|
|
$(CC) -c $(ALL_CFLAGS) $(CONLYFLAGS) $< -o $@
|
535 |
|
|
|
536 |
|
|
# Compile: create object files from C++ source files. ARM/Thumb
|
537 |
|
|
$(CPPOBJ) : %.o : %.cpp
|
538 |
|
|
@echo
|
539 |
|
|
@echo $(MSG_COMPILINGCPP) $<
|
540 |
a5a204c6
|
(no author)
|
$(CPP) -c $(ALL_CFLAGS) $(CPPFLAGS) $< -o $@
|
541 |
f57b548d
|
(no author)
|
|
542 |
|
|
# Compile: create object files from C++ source files. ARM-only
|
543 |
|
|
$(CPPOBJARM) : %.o : %.cpp
|
544 |
|
|
@echo
|
545 |
|
|
@echo $(MSG_COMPILINGCPP_ARM) $<
|
546 |
|
|
$(CPP) -c $(ALL_CFLAGS) $(CPPFLAGS) $< -o $@
|
547 |
|
|
|
548 |
|
|
|
549 |
|
|
# Compile: create assembler files from C source files. ARM/Thumb
|
550 |
|
|
## does not work - TODO - hints welcome
|
551 |
|
|
##$(COBJ) : %.s : %.c
|
552 |
|
|
## $(CC) $(THUMB) -S $(ALL_CFLAGS) $< -o $@
|
553 |
|
|
|
554 |
|
|
|
555 |
|
|
# Assemble: create object files from assembler source files. ARM/Thumb
|
556 |
706ffa9f
|
laforge
|
$(AOBJ) : %.o : %.S
|
557 |
f57b548d
|
(no author)
|
@echo
|
558 |
|
|
@echo $(MSG_ASSEMBLING) $<
|
559 |
a5a204c6
|
(no author)
|
$(CC) -c $(ALL_ASFLAGS) $< -o $@
|
560 |
f57b548d
|
(no author)
|
|
561 |
|
|
|
562 |
|
|
# Assemble: create object files from assembler source files. ARM-only
|
563 |
|
|
$(AOBJARM) : %.o : %.S
|
564 |
|
|
@echo
|
565 |
|
|
@echo $(MSG_ASSEMBLING_ARM) $<
|
566 |
|
|
$(CC) -c $(ALL_ASFLAGS) $< -o $@
|
567 |
|
|
|
568 |
|
|
|
569 |
|
|
# Target: clean project.
|
570 |
|
|
clean: begin clean_list finished end
|
571 |
|
|
|
572 |
|
|
|
573 |
|
|
clean_list :
|
574 |
|
|
@echo
|
575 |
|
|
@echo $(MSG_CLEANING)
|
576 |
|
|
$(REMOVE) $(TARGET).hex
|
577 |
a5a204c6
|
(no author)
|
$(REMOVE) $(TARGET).bin
|
578 |
f57b548d
|
(no author)
|
$(REMOVE) $(TARGET).obj
|
579 |
|
|
$(REMOVE) $(TARGET).elf
|
580 |
|
|
$(REMOVE) $(TARGET).map
|
581 |
|
|
$(REMOVE) $(TARGET).obj
|
582 |
|
|
$(REMOVE) $(TARGET).a90
|
583 |
|
|
$(REMOVE) $(TARGET).sym
|
584 |
|
|
$(REMOVE) $(TARGET).lnk
|
585 |
|
|
$(REMOVE) $(TARGET).lss
|
586 |
|
|
$(REMOVE) $(COBJ)
|
587 |
|
|
$(REMOVE) $(CPPOBJ)
|
588 |
|
|
$(REMOVE) $(AOBJ)
|
589 |
|
|
$(REMOVE) $(COBJARM)
|
590 |
|
|
$(REMOVE) $(CPPOBJARM)
|
591 |
|
|
$(REMOVE) $(AOBJARM)
|
592 |
|
|
$(REMOVE) $(LST)
|
593 |
|
|
$(REMOVE) $(SRC:.c=.s)
|
594 |
|
|
$(REMOVE) $(SRC:.c=.d)
|
595 |
|
|
$(REMOVE) $(SRCARM:.c=.s)
|
596 |
|
|
$(REMOVE) $(SRCARM:.c=.d)
|
597 |
|
|
$(REMOVE) $(CPPSRC:.cpp=.s)
|
598 |
|
|
$(REMOVE) $(CPPSRC:.cpp=.d)
|
599 |
|
|
$(REMOVE) $(CPPSRCARM:.cpp=.s)
|
600 |
|
|
$(REMOVE) $(CPPSRCARM:.cpp=.d)
|
601 |
|
|
$(REMOVE) .dep/*
|
602 |
514b0f72
|
laforge
|
$(REMOVE) include/compile.h
|
603 |
5872753e
|
laforge
|
$(REMOVE) src/picc/usb_strings_app.h
|
604 |
41423de5
|
laforge
|
$(REMOVE) scripts/usbstring
|
605 |
f57b548d
|
(no author)
|
|
606 |
569d11d8
|
laforge
|
.PHONY: include/compile.h
|
607 |
|
|
include/compile.h:
|
608 |
|
|
scripts/mkcompile_h > $@
|
609 |
f57b548d
|
(no author)
|
|
610 |
89c40594
|
laforge
|
$(USBSTRINGS): %.h : %.txt ./scripts/usbstring
|
611 |
5872753e
|
laforge
|
cat $< | ./scripts/usbstring > $@
|
612 |
|
|
|
613 |
41423de5
|
laforge
|
scripts/usbstring: scripts/usbstring.c
|
614 |
|
|
gcc $^ -o $@
|
615 |
|
|
|
616 |
f57b548d
|
(no author)
|
# Include the dependency files.
|
617 |
|
|
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
|
618 |
|
|
|
619 |
|
|
|
620 |
|
|
# Listing of phony targets.
|
621 |
|
|
.PHONY : all begin finish end sizebefore sizeafter gccversion \
|
622 |
a5a204c6
|
(no author)
|
build elf hex bin lss sym clean clean_list program
|