Compilerswitch für Firmware, die nur den Dataflash per USB rausreicht (zum
[hackover2013-badge-firmware.git] / Makefile
1 ##########################################################################
2 # User configuration and firmware specific object files
3 ##########################################################################
4
5 # The target, flash and ram of the LPC1xxx microprocessor.
6 # Use for the target the value: LPC11xx, LPC13xx or LPC17xx
7 TARGET = LPC13xx
8 FLASH = 32K
9 SRAM = 8K
10
11 # For USB HID support the LPC134x reserves 384 bytes from the sram,
12 # if you don't want to use the USB features, just use 0 here.
13 SRAM_USB = 384
14 #SRAM_USB = 0
15
16 ##########################################################################
17 # Debug settings
18 ##########################################################################
19
20 # Set DEBUGBUILD to 'TRUE' for full debugging (larger, slower binaries),
21 # or to 'FALSE' for release builds (smallest, fastest binaries)
22 DEBUGBUILD = FALSE
23
24 ##########################################################################
25 # IDE Flags (Keeps various IDEs happy)
26 ##########################################################################
27
28 #OPTDEFINES = -D __NEWLIB__ -DR0KET
29 #OPTDEFINES = -D __NEWLIB__ -DHOB_REV2 -DUSBONLY
30 OPTDEFINES = -D __NEWLIB__ -DHOB_REV2
31 ##########################################################################
32 # Project-specific files
33 ##########################################################################
34
35 SRCS = \
36 badge/fahrplan.c \
37 badge/init.c \
38 badge/main.c \
39 badge/jumpnrun/collision.c \
40 badge/jumpnrun/enemies.c \
41 badge/jumpnrun/game_state.c \
42 badge/jumpnrun/items.c \
43 badge/jumpnrun/jumpnrun.c \
44 badge/jumpnrun/level_load.c \
45 badge/jumpnrun/player.c \
46 badge/jumpnrun/render.c \
47 badge/jumpnrun/shots.c \
48 badge/jumpnrun/starter.c \
49 badge/jumpnrun/stats.c \
50 badge/jumpnrun/tiles.c \
51 badge/ui/browser.c \
52 badge/ui/display.c \
53 badge/ui/event.c \
54 badge/ui/font.c \
55 badge/ui/menu.c \
56 badge/ui/sprite.c \
57 badge/ui/vanity.c
58
59 SRCS += \
60 dataflash/iobase.c \
61 dataflash/diskio.c \
62 dataflash/at45db041d.c
63
64 SRCS += \
65 funk/nrf24l01p.c
66
67 SRCS += \
68 project/commands.c
69
70 SRCS += \
71 project/commands/cmd_chibi_addr.c \
72 project/commands/cmd_chibi_tx.c \
73 project/commands/cmd_i2ceeprom_read.c \
74 project/commands/cmd_i2ceeprom_write.c \
75 project/commands/cmd_lm75b_gettemp.c \
76 project/commands/cmd_reset.c \
77 project/commands/cmd_sd_dir.c \
78 project/commands/cmd_sysinfo.c \
79 project/commands/cmd_uart.c \
80 project/commands/cmd_pwm.c
81
82 SRCS += \
83 project/commands/drawing/cmd_backlight.c \
84 project/commands/drawing/cmd_bmp.c \
85 project/commands/drawing/cmd_button.c \
86 project/commands/drawing/cmd_calibrate.c \
87 project/commands/drawing/cmd_circle.c \
88 project/commands/drawing/cmd_clear.c \
89 project/commands/drawing/cmd_line.c \
90 project/commands/drawing/cmd_orientation.c \
91 project/commands/drawing/cmd_pixel.c \
92 project/commands/drawing/cmd_progress.c \
93 project/commands/drawing/cmd_rectangle.c \
94 project/commands/drawing/cmd_roundedcorner.c \
95 project/commands/drawing/cmd_text.c \
96 project/commands/drawing/cmd_textw.c \
97 project/commands/drawing/cmd_tsthreshhold.c \
98 project/commands/drawing/cmd_tswait.c \
99 project/commands/drawing/cmd_triangle.c
100
101 ##########################################################################
102 # Optional driver files
103 ##########################################################################
104
105 # Chibi Light-Weight Wireless Stack (AT86RF212)
106 SRCS += \
107 drivers/rf/chibi/chb.c \
108 drivers/rf/chibi/chb_buf.c \
109 drivers/rf/chibi/chb_drvr.c \
110 drivers/rf/chibi/chb_eeprom.c \
111 drivers/rf/chibi/chb_spi.c
112
113 # 4K EEPROM
114 SRCS += \
115 drivers/storage/eeprom/eeprom.c \
116 drivers/storage/eeprom/mcp24aa/mcp24aa.c
117
118 # LM75B temperature sensor
119 SRCS += \
120 drivers/sensors/lm75b/lm75b.c
121
122 # ISL12022M RTC
123 SRCS += \
124 drivers/rtc/isl12022m/isl12022m.c
125
126 # TFT LCD support
127 SRCS += \
128 drivers/displays/tft/drawing.c \
129 drivers/displays/tft/touchscreen.c \
130 drivers/displays/tft/colors.c \
131 drivers/displays/tft/theme.c \
132 drivers/displays/tft/bmp.c
133
134 # GUI Controls
135 SRCS += \
136 drivers/displays/tft/controls/button.c \
137 drivers/displays/tft/controls/hsbchart.c \
138 drivers/displays/tft/controls/huechart.c \
139 drivers/displays/tft/controls/label.c \
140 drivers/displays/tft/controls/labelcentered.c \
141 drivers/displays/tft/controls/progressbar.c
142
143 # Bitmap (non-AA) fonts
144 SRCS += \
145 drivers/displays/tft/fonts.c \
146 drivers/displays/tft/fonts/dejavusans9.c \
147 drivers/displays/tft/fonts/dejavusansbold9.c \
148 drivers/displays/tft/fonts/dejavusanscondensed9.c \
149 drivers/displays/tft/fonts/dejavusansmono8.c \
150 drivers/displays/tft/fonts/dejavusansmonobold8.c \
151 drivers/displays/tft/fonts/verdana9.c \
152 drivers/displays/tft/fonts/verdana14.c \
153 drivers/displays/tft/fonts/verdanabold14.c
154
155 # Anti-aliased fonts
156 SRCS += \
157 drivers/displays/tft/aafonts.c \
158 drivers/displays/tft/aafonts/aa2/DejaVuSansCondensed14_AA2.c \
159 drivers/displays/tft/aafonts/aa2/DejaVuSansCondensedBold14_AA2.c \
160 drivers/displays/tft/aafonts/aa2/DejaVuSansMono10_AA2.c \
161 drivers/displays/tft/aafonts/aa2/DejaVuSansMono13_AA2.c \
162 drivers/displays/tft/aafonts/aa2/DejaVuSansMono14_AA2.c
163
164 # LCD Driver (Only one can be included at a time!)
165 # SRCS += drivers/displays/tft/hw/hx8340b.c
166 # SRCS += drivers/displays/tft/hw/hx8347d.c
167 # SRCS += drivers/displays/tft/hw/ILI9328.c
168 # SRCS += drivers/displays/tft/hw/ILI9325.c
169 # SRCS += drivers/displays/tft/hw/ssd1331.c
170 # SRCS += drivers/displays/tft/hw/ssd1351.c
171 # SRCS += drivers/displays/tft/hw/st7735.c
172 # SRCS += drivers/displays/tft/hw/st7783.c
173
174 # Bitmap/Monochrome LCD support (ST7565, SSD1306, etc.)
175 SRCS += \
176 drivers/displays/smallfonts.c \
177 drivers/displays/bitmap/sharpmem/sharpmem.c \
178 drivers/displays/bitmap/st7565/st7565.c \
179 drivers/displays/bitmap/ssd1306/ssd1306.c
180
181 #Character Displays (VFD text displays, etc.)
182 SRCS += \
183 drivers/displays/character/samsung_20T202DA2JA/samsung_20T202DA2JA.c
184
185 # ChaN FatFS and SD card support
186 SRCS += \
187 drivers/fatfs/ff.c
188 # drivers/fatfs/mmc.c
189
190 # Motors
191 SRCS += \
192 drivers/motor/stepper/stepper.c
193
194 # RSA Encryption/Descryption
195 SRCS += \
196 drivers/rsa/rsa.c
197
198 # DAC
199 SRCS += \
200 drivers/dac/mcp4725/mcp4725.c \
201 drivers/dac/mcp4901/mcp4901.c
202
203 # RFID/NFC
204 SRCS += \
205 drivers/rf/pn532/pn532.c \
206 drivers/rf/pn532/pn532_bus_i2c.c \
207 drivers/rf/pn532/pn532_bus_uart.c \
208 drivers/rf/pn532/helpers/pn532_mifare_classic.c \
209 drivers/rf/pn532/helpers/pn532_mifare_ultralight.c
210
211 # TAOS Light Sensors
212 SRCS += \
213 drivers/sensors/tcs3414/tcs3414.c \
214 drivers/sensors/tsl2561/tsl2561.c
215
216 # SPI Flash
217 SRCS += \
218 drivers/storage/spiflash/w25q16bv/w25q16bv.c
219
220 # FM Radio
221 SRCS += \
222 drivers/audio/tea5767/tea5767.c
223
224 # IN219 Current Sensor
225 SRCS += \
226 drivers/sensors/ina219/ina219.c
227
228 # MPL115A2 Barometric Pressure Sensor
229 SRCS += \
230 drivers/sensors/mpl115a2/mpl115a2.c
231
232 # ADS1015 12-bit ADC
233 SRCS += \
234 drivers/adc/ads1015/ads1015.c
235
236 ##########################################################################
237 # Library files
238 ##########################################################################
239
240 SRCS += \
241 core/adc/adc.c \
242 core/cmd/cmd.c \
243 core/cpu/cpu.c \
244 core/gpio/gpio.c \
245 core/iap/iap.c \
246 core/libc/stdio.c \
247 core/libc/string.c \
248 core/pmu/pmu.c \
249 core/pwm/pwm.c \
250 core/ssp/ssp.c \
251 core/systick/systick.c \
252 core/timer16/timer16.c \
253 core/timer32/timer32.c \
254 core/usbcdc/cdc_buf.c \
255 core/usbcdc/cdcuser.c \
256 core/usbcdc/usbcore.c \
257 core/usbcdc/usbdesc.c \
258 core/usbcdc/usbhw.c \
259 core/usbcdc/usbuser.c \
260 core/usbhid-rom/usbconfig.c \
261 core/usbhid-rom/usbhid.c \
262 core/usbhid-rom/usbmsc.c \
263 core/wdt/wdt.c
264
265 # core/i2c/i2c.c
266 # core/uart/uart_buf.c
267 # core/uart/uart.c
268
269 ##########################################################################
270 # GNU GCC compiler prefix and location
271 ##########################################################################
272
273 CROSS_COMPILE = arm-none-eabi-
274 AS = $(CROSS_COMPILE)gcc
275 CC = $(CROSS_COMPILE)gcc
276 LD = $(CROSS_COMPILE)gcc
277 SIZE = $(CROSS_COMPILE)size
278 OBJCOPY = $(CROSS_COMPILE)objcopy
279 OBJDUMP = $(CROSS_COMPILE)objdump
280 OUTFILE = firmware
281
282 CC_FOR_BUILD = gcc
283 LPCRC = ./lpcrc
284
285 ##########################################################################
286 # GNU GCC compiler flags
287 ##########################################################################
288 ROOT_PATH = .
289 INCLUDE_PATHS = -I$(ROOT_PATH) -I$(ROOT_PATH)/project
290
291 ##########################################################################
292 # Startup files
293 ##########################################################################
294
295 LD_PATH = lpc1xxx
296 LD_SCRIPT = $(LD_PATH)/linkscript.ld
297 LD_TEMP = $(LD_PATH)/memory.ld
298
299 ifeq (LPC11xx,$(TARGET))
300 CORTEX_TYPE=m0
301 else
302 CORTEX_TYPE=m3
303 endif
304
305 CPU_TYPE = cortex-$(CORTEX_TYPE)
306
307 SRCS += \
308 lpc1xxx/$(TARGET)_handlers.c \
309 lpc1xxx/LPC1xxx_startup.c
310
311 OBJS = $(SRCS:%.c=%.o)
312 DEPS = $(SRCS:%.c=%.dep)
313
314 ##########################################################################
315 # Compiler settings, parameters and flags
316 ##########################################################################
317 ifeq (TRUE,$(DEBUGBUILD))
318 CFLAGS = -c -g -O0 $(INCLUDE_PATHS) -Wall -mthumb -ffunction-sections -fdata-sections -fmessage-length=0 -mcpu=$(CPU_TYPE) -DTARGET=$(TARGET) -fno-builtin $(OPTDEFINES) -std=c99
319 ASFLAGS = -c -g -O0 $(INCLUDE_PATHS) -Wall -mthumb -ffunction-sections -fdata-sections -fmessage-length=0 -mcpu=$(CPU_TYPE) -D__ASSEMBLY__ -x assembler-with-cpp
320 else
321 CFLAGS = -c -g -Os $(INCLUDE_PATHS) -Wall -mthumb -ffunction-sections -fdata-sections -fmessage-length=0 -mcpu=$(CPU_TYPE) -DTARGET=$(TARGET) -fno-builtin $(OPTDEFINES) -std=c99
322 ASFLAGS = -c -g -Os $(INCLUDE_PATHS) -Wall -mthumb -ffunction-sections -fdata-sections -fmessage-length=0 -mcpu=$(CPU_TYPE) -D__ASSEMBLY__ -x assembler-with-cpp
323 endif
324
325 LDFLAGS = -nostartfiles -mthumb -mcpu=$(CPU_TYPE) -Wl,--gc-sections
326 LDLIBS = -lm
327 OCFLAGS = --strip-unneeded
328
329 all: dep size $(OUTFILE).bin $(OUTFILE).hex
330
331 dep: $(DEPS)
332
333 $(DEPS) : %.dep : %.c
334 $(CC) $(CPPFLAGS) $(CFLAGS) -MM $< -MT $@ -MT $(@:%.dep=%.o) -MF $@
335
336 sinclude $(DEPS)
337
338 $(LD_TEMP):
339 -@echo "MEMORY" > $(LD_TEMP)
340 -@echo "{" >> $(LD_TEMP)
341 -@echo " flash(rx): ORIGIN = 0x00000000, LENGTH = $(FLASH)" >> $(LD_TEMP)
342 -@echo " sram(rwx): ORIGIN = 0x10000000+$(SRAM_USB), LENGTH = $(SRAM)-$(SRAM_USB)" >> $(LD_TEMP)
343 -@echo "}" >> $(LD_TEMP)
344 -@echo "INCLUDE $(LD_SCRIPT)" >> $(LD_TEMP)
345
346 $(OUTFILE).elf: $(OBJS) $(LD_TEMP)
347 $(LD) $(LDFLAGS) -T $(LD_TEMP) -o $(OUTFILE).elf $(OBJS) $(LDLIBS)
348
349 $(OUTFILE).bin: $(OUTFILE).elf $(LPCRC)
350 $(OBJCOPY) $(OCFLAGS) -O binary $(OUTFILE).elf $(OUTFILE).bin
351 $(LPCRC) $(OUTFILE).bin
352
353 $(OUTFILE).hex: $(OUTFILE).elf
354 $(OBJCOPY) $(OCFLAGS) -O ihex $(OUTFILE).elf $(OUTFILE).hex
355
356 size: $(OUTFILE).elf
357 $(SIZE) $(OUTFILE).elf
358
359 clean:
360 rm -f $(OBJS) $(LD_TEMP) $(OUTFILE).elf $(OUTFILE).bin $(OUTFILE).hex
361
362 distclean: clean
363 rm -f $(DEPS) $(LPCRC)
364
365 .PHONY: all dep size clean distclean
366
367 CFLAGS_FOR_BUILD = -Wall -Wextra -std=c99 -O0 -g
368
369 LPCRC_SRCS = tools/lpcrc/lpcrc.c
370 LPCRC_OBJS = $(LPCRC_SRCS:%.c=%.o)
371 LPCRC_DEPS = $(LPCRC_SRCS:%.c=%.dep)
372
373 $(LPCRC_DEPS) : %.dep : %.c
374 $(CC_FOR_BUILD) $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) -MM $< -MT $@ -MT $(@:%.dep=%.o) -MF $@
375
376 $(LPCRC_OBJS): %.o : %.c
377 $(CC_FOR_BUILD) $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) -o $@ -c $<
378
379 $(LPCRC): $(LPCRC_OBJS)
380 $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ $+ $(LDLIBS_FOR_BUILD)
This page took 0.055142 seconds and 5 git commands to generate.