First commit
[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
15 VPATH =
16 OBJS = main.o
17
18 ##########################################################################
19 # Debug settings
20 ##########################################################################
21
22 # Set DEBUGBUILD to 'TRUE' for full debugging (larger, slower binaries),
23 # or to 'FALSE' for release builds (smallest, fastest binaries)
24 DEBUGBUILD = FALSE
25
26 ##########################################################################
27 # IDE Flags (Keeps various IDEs happy)
28 ##########################################################################
29
30 OPTDEFINES = -D __NEWLIB__
31
32 ##########################################################################
33 # Project-specific files
34 ##########################################################################
35
36 VPATH += project
37 OBJS += commands.o
38
39 VPATH += project/commands
40 OBJS += cmd_chibi_addr.o cmd_chibi_tx.o
41 OBJS += cmd_i2ceeprom_read.o cmd_i2ceeprom_write.o cmd_lm75b_gettemp.o
42 OBJS += cmd_reset.o cmd_sd_dir.o cmd_sysinfo.o cmd_uart.o
43 OBJS += cmd_roundedcorner.o cmd_pwm.o
44
45 VPATH += project/commands/drawing
46 OBJS += cmd_backlight.o cmd_bmp.o cmd_button.o cmd_calibrate.o
47 OBJS += cmd_circle.o cmd_clear.o cmd_line.o cmd_orientation.o
48 OBJS += cmd_pixel.o cmd_progress.o cmd_rectangle.o cmd_text.o
49 OBJS += cmd_textw.o cmd_tsthreshhold.o cmd_tswait.o cmd_triangle.o
50
51 ##########################################################################
52 # Optional driver files
53 ##########################################################################
54
55 # Chibi Light-Weight Wireless Stack (AT86RF212)
56 VPATH += drivers/rf/chibi
57 OBJS += chb.o chb_buf.o chb_drvr.o chb_eeprom.o chb_spi.o
58
59 # 4K EEPROM
60 VPATH += drivers/storage/eeprom drivers/storage/eeprom/mcp24aa
61 OBJS += eeprom.o mcp24aa.o
62
63 # LM75B temperature sensor
64 VPATH += drivers/sensors/lm75b
65 OBJS += lm75b.o
66
67 # ISL12022M RTC
68 VPATH += drivers/rtc/isl12022m
69 OBJS += isl12022m.o
70
71 # TFT LCD support
72 VPATH += drivers/displays/tft drivers/displays/tft/hw
73 OBJS += drawing.o touchscreen.o colors.o theme.o bmp.o
74
75 # GUI Controls
76 VPATH += drivers/displays/tft/controls
77 OBJS += button.o hsbchart.o huechart.o label.o
78 OBJS += labelcentered.o progressbar.o
79
80 # Bitmap (non-AA) fonts
81 VPATH += drivers/displays/tft/fonts
82 OBJS += fonts.o
83 OBJS += dejavusans9.o dejavusansbold9.o dejavusanscondensed9.o
84 OBJS += dejavusansmono8.o dejavusansmonobold8.o
85 OBJS += verdana9.o verdana14.o verdanabold14.o
86
87 # Anti-aliased fonts
88 VPATH += drivers/displays/tft/aafonts/aa2 drivers/displays/tft/aafonts/aa4
89 OBJS += aafonts.o
90 OBJS += DejaVuSansCondensed14_AA2.o DejaVuSansCondensedBold14_AA2.o
91 OBJS += DejaVuSansMono10_AA2.o DejaVuSansMono13_AA2.o DejaVuSansMono14_AA2.o
92
93 # LCD Driver (Only one can be included at a time!)
94 # OBJS += hx8340b.o
95 OBJS += ILI9328.o
96 # OBJS += ILI9325.o
97 # OBJS += ssd1331.o
98 # OBJS += ssd1351.o
99 # OBJS += st7735.o
100 # OBJS += st7783.o
101
102 # Bitmap/Monochrome LCD support (ST7565, SSD1306, etc.)
103 VPATH += drivers/displays
104 VPATH += drivers/displays/bitmap/sharpmem
105 VPATH += drivers/displays/bitmap/st7565
106 VPATH += drivers/displays/bitmap/ssd1306
107 OBJS += smallfonts.o sharpmem.o st7565.o ssd1306.o
108
109 #Character Displays (VFD text displays, etc.)
110 VPATH += drivers/displays/character/samsung_20T202DA2JA
111 OBJS += samsung_20T202DA2JA.o
112
113 # ChaN FatFS and SD card support
114 VPATH += drivers/fatfs
115 OBJS += ff.o mmc.o
116
117 # Motors
118 VPATH += drivers/motor/stepper
119 OBJS += stepper.o
120
121 # RSA Encryption/Descryption
122 VPATH += drivers/rsa
123 OBJS += rsa.o
124
125 # DAC
126 VPATH += drivers/dac/mcp4725
127 OBJS += mcp4725.o
128
129 # RFID/NFC
130 VPATH += drivers/rf/pn532 drivers/rf/pn532/helpers
131 OBJS += pn532.o pn532_bus_i2c.o pn532_bus_uart.o
132 OBJS += pn532_mifare_classic.o pn532_mifare_ultralight.o
133
134 # TAOS Light Sensors
135 VPATH += drivers/sensors/tcs3414 drivers/sensors/tsl2561
136 OBJS += tcs3414.o tsl2561.o
137
138 # SPI Flash
139 VPATH += drivers/storage/spiflash/w25q16bv
140 OBJS += w25q16bv.o
141
142 # FM Radio
143 VPATH += drivers/audio/tea5767
144 OBJS += tea5767.o
145
146 ##########################################################################
147 # Library files
148 ##########################################################################
149
150 VPATH += core core/adc core/cmd core/cpu core/gpio core/i2c core/pmu
151 VPATH += core/ssp core/systick core/timer16 core/timer32 core/uart
152 VPATH += core/usbhid-rom core/wdt core/usbcdc core/pwm core/iap
153 VPATH += core/libc
154 OBJS += stdio.o string.o
155 OBJS += adc.o cpu.o cmd.o gpio.o i2c.o pmu.o ssp.o systick.o timer16.o
156 OBJS += timer32.o uart.o uart_buf.o usbconfig.o usbhid.o
157 OBJS += wdt.o cdcuser.o cdc_buf.o usbcore.o usbdesc.o usbhw.o usbuser.o
158 OBJS += sysinit.o pwm.o iap.o
159
160 ##########################################################################
161 # GNU GCC compiler prefix and location
162 ##########################################################################
163
164 CROSS_COMPILE = arm-none-eabi-
165 AS = $(CROSS_COMPILE)gcc
166 CC = $(CROSS_COMPILE)gcc
167 LD = $(CROSS_COMPILE)gcc
168 SIZE = $(CROSS_COMPILE)size
169 OBJCOPY = $(CROSS_COMPILE)objcopy
170 OBJDUMP = $(CROSS_COMPILE)objdump
171 OUTFILE = firmware
172 LPCRC = ./lpcrc
173
174 ##########################################################################
175 # GNU GCC compiler flags
176 ##########################################################################
177 ROOT_PATH = .
178 INCLUDE_PATHS = -I$(ROOT_PATH) -I$(ROOT_PATH)/project
179
180 ##########################################################################
181 # Startup files
182 ##########################################################################
183
184 LD_PATH = lpc1xxx
185 LD_SCRIPT = $(LD_PATH)/linkscript.ld
186 LD_TEMP = $(LD_PATH)/memory.ld
187
188 ifeq (LPC11xx,$(TARGET))
189 CORTEX_TYPE=m0
190 else
191 CORTEX_TYPE=m3
192 endif
193
194 CPU_TYPE = cortex-$(CORTEX_TYPE)
195 VPATH += lpc1xxx
196 OBJS += $(TARGET)_handlers.o LPC1xxx_startup.o
197
198 ##########################################################################
199 # Compiler settings, parameters and flags
200 ##########################################################################
201 ifeq (TRUE,$(DEBUGBUILD))
202 CFLAGS = -c -g -O0 $(INCLUDE_PATHS) -Wall -mthumb -ffunction-sections -fdata-sections -fmessage-length=0 -mcpu=$(CPU_TYPE) -DTARGET=$(TARGET) -fno-builtin $(OPTDEFINES)
203 ASFLAGS = -c -g -O0 $(INCLUDE_PATHS) -Wall -mthumb -ffunction-sections -fdata-sections -fmessage-length=0 -mcpu=$(CPU_TYPE) -D__ASSEMBLY__ -x assembler-with-cpp
204 else
205 CFLAGS = -c -g -Os $(INCLUDE_PATHS) -Wall -mthumb -ffunction-sections -fdata-sections -fmessage-length=0 -mcpu=$(CPU_TYPE) -DTARGET=$(TARGET) -fno-builtin $(OPTDEFINES)
206 ASFLAGS = -c -g -Os $(INCLUDE_PATHS) -Wall -mthumb -ffunction-sections -fdata-sections -fmessage-length=0 -mcpu=$(CPU_TYPE) -D__ASSEMBLY__ -x assembler-with-cpp
207 endif
208
209 LDFLAGS = -nostartfiles -mthumb -mcpu=$(CPU_TYPE) -Wl,--gc-sections
210 LDLIBS = -lm
211 OCFLAGS = --strip-unneeded
212
213 all: firmware
214
215 %.o : %.c
216 $(CC) $(CFLAGS) -o $@ $<
217
218 %.o : %.s
219 $(AS) $(ASFLAGS) -o $@ $<
220
221 firmware: $(OBJS) $(SYS_OBJS)
222 -@echo "MEMORY" > $(LD_TEMP)
223 -@echo "{" >> $(LD_TEMP)
224 -@echo " flash(rx): ORIGIN = 0x00000000, LENGTH = $(FLASH)" >> $(LD_TEMP)
225 -@echo " sram(rwx): ORIGIN = 0x10000000+$(SRAM_USB), LENGTH = $(SRAM)-$(SRAM_USB)" >> $(LD_TEMP)
226 -@echo "}" >> $(LD_TEMP)
227 -@echo "INCLUDE $(LD_SCRIPT)" >> $(LD_TEMP)
228 $(LD) $(LDFLAGS) -T $(LD_TEMP) -o $(OUTFILE).elf $(OBJS) $(LDLIBS)
229 -@echo ""
230 $(SIZE) $(OUTFILE).elf
231 -@echo ""
232 $(OBJCOPY) $(OCFLAGS) -O binary $(OUTFILE).elf $(OUTFILE).bin
233 $(OBJCOPY) $(OCFLAGS) -O binary $(OUTFILE).elf $(OUTFILE).bin
234 $(OBJCOPY) $(OCFLAGS) -O ihex $(OUTFILE).elf $(OUTFILE).hex
235 -@echo ""
236 $(LPCRC) firmware.bin
237
238 clean:
239 rm -f $(OBJS) $(LD_TEMP) $(OUTFILE).elf $(OUTFILE).bin $(OUTFILE).hex
This page took 0.054042 seconds and 5 git commands to generate.