Makefile 3.63 KB
Newer Older
Damien's avatar
Damien committed
1
2
STMSRC=lib
FATFSSRC=fatfs
3
CC3KSRC=cc3k
Damien's avatar
Damien committed
4
5
PYSRC=../py
BUILD=build
6
DFU=../tools/dfu.py
Damien's avatar
Damien committed
7
8
9
10

AS = arm-none-eabi-as
CC = arm-none-eabi-gcc
LD = arm-none-eabi-ld
11
CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mabi=aapcs-linux -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -fsingle-precision-constant -Wdouble-promotion -DSTM32F40XX -DHSE_VALUE=8000000
Damien's avatar
Damien committed
12
CFLAGS = -I. -I$(PYSRC) -I$(FATFSSRC) -I$(STMSRC) -Wall -ansi -std=gnu99 -Os -DNDEBUG $(CFLAGS_CORTEX_M4)
13
LDFLAGS = --nostdlib -T stm32f405.ld
Damien's avatar
Damien committed
14
15
16
17
18

SRC_C = \
	main.c \
	printf.c \
	system_stm32f4xx.c \
Damien's avatar
Damien committed
19
20
21
22
23
	stm32fxxx_it.c \
	string0.c \
	malloc0.c \
	systick.c  \
	lexerstm.c \
24
	led.c \
25
	lcd.c \
26
	servo.c \
Damien's avatar
Damien committed
27
	flash.c \
28
	storage.c \
29
	mma.c \
30
	usart.c \
Damien's avatar
Damien committed
31
	usb.c \
32
	timer.c \
33
	audio.c \
Damien's avatar
Damien committed
34
	sdio.c \
35
	pybwlan.c \
36
	i2c.c \
Damien's avatar
Damien committed
37
38
39

SRC_S = \
	startup_stm32f40xx.s \
40
	gchelper.s \
Damien's avatar
Damien committed
41
42

PY_O = \
43
	nlrthumb.o \
Damien's avatar
Damien committed
44
	gc.o \
45
	malloc.o \
Damien's avatar
Damien committed
46
	qstr.o \
47
	vstr.o \
48
	misc.o \
Damien's avatar
Damien committed
49
50
51
52
53
54
55
56
57
58
	lexer.o \
	parse.o \
	scope.o \
	compile.o \
	emitcommon.o \
	emitpass1.o \
	emitbc.o \
	asmthumb.o \
	emitnthumb.o \
	emitinlinethumb.o \
Damien's avatar
Damien committed
59
	runtime.o \
60
61
	map.o \
	obj.o \
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
	objbool.o \
	objboundmeth.o \
	objcell.o \
	objclass.o \
	objclosure.o \
	objcomplex.o \
	objdict.o \
	objexcept.o \
	objfloat.o \
	objfun.o \
	objgenerator.o \
	objinstance.o \
	objlist.o \
	objnone.o \
	objrange.o \
	objset.o \
	objstr.o \
	objtuple.o \
	objtype.o \
81
	builtin.o \
Damien's avatar
Damien committed
82
	vm.o \
83
	repl.o \
Damien's avatar
Damien committed
84
85
86
87
88
89
90

SRC_FATFS = \
	ff.c \
	diskio.c \

SRC_STM = \
	stm32f4xx_rcc.c \
91
	stm32f4xx_syscfg.c \
Damien's avatar
Damien committed
92
	stm_misc.c \
Damien's avatar
Damien committed
93
94
95
	stm32f4xx_flash.c \
	stm32f4xx_dma.c \
	stm32f4xx_gpio.c \
96
	stm32f4xx_exti.c \
97
	stm32f4xx_tim.c \
98
	stm32f4xx_sdio.c \
99
100
	stm32f4xx_pwr.c \
	stm32f4xx_rtc.c \
101
	stm32f4xx_usart.c \
102
	stm32f4xx_spi.c \
103
	stm32f4xx_dac.c \
Damien's avatar
Damien committed
104
	stm32f4xx_rng.c \
Damien's avatar
Damien committed
105
106
107
108
109
110
111
112
113
	usb_core.c \
	usb_dcd.c \
	usb_dcd_int.c \
	usb_bsp.c \
	usbd_core.c \
	usbd_ioreq.c \
	usbd_req.c \
	usbd_usr.c \
	usbd_desc.c \
114
	usbd_pyb_core.c \
115
	usbd_pyb_core2.c \
Damien's avatar
Damien committed
116
117
118
119
120
	usbd_cdc_vcp.c \
	usbd_msc_bot.c  \
	usbd_msc_data.c \
	usbd_msc_scsi.c \
	usbd_storage_msd.c \
121
122
	stm324x7i_eval.c \
	stm324x7i_eval_sdio_sd.c \
Damien's avatar
Damien committed
123

124
125
126
127
128
129
130
131
132
133
134
135
136
SRC_CC3K = \
	cc3000_common.c \
	evnt_handler.c \
	hci.c \
	netapp.c \
	nvmem.c \
	security.c \
	socket.c \
	wlan.c \
	ccspi.c \
	pybcc3k.c \

OBJ = $(addprefix $(BUILD)/, $(SRC_C:.c=.o) $(SRC_S:.s=.o) $(PY_O) $(SRC_FATFS:.c=.o) $(SRC_STM:.c=.o) $(SRC_CC3K:.c=.o))
Damien's avatar
Damien committed
137
138
139

all: $(BUILD) $(BUILD)/flash.dfu

140
$(BUILD)/flash.dfu: $(BUILD)/flash0.bin $(BUILD)/flash1.bin
141
	python2 $(DFU) -b 0x08000000:$(BUILD)/flash0.bin -b 0x08020000:$(BUILD)/flash1.bin $@
Damien's avatar
Damien committed
142

143
144
145
146
147
$(BUILD)/flash0.bin: $(BUILD)/flash.elf
	arm-none-eabi-objcopy -O binary -j .isr_vector $^ $@

$(BUILD)/flash1.bin: $(BUILD)/flash.elf
	arm-none-eabi-objcopy -O binary -j .text -j .data $^ $@
Damien's avatar
Damien committed
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167

$(BUILD)/flash.elf: $(OBJ)
	$(LD) $(LDFLAGS) -o $@ $(OBJ)
	arm-none-eabi-size $@

$(BUILD):
	mkdir $@

$(BUILD)/%.o: %.s
	$(AS) -o $@ $<

$(BUILD)/%.o: %.c
	$(CC) $(CFLAGS) -c -o $@ $<

$(BUILD)/%.o: $(FATFSSRC)/%.c
	$(CC) $(CFLAGS) -c -o $@ $<

$(BUILD)/%.o: $(STMSRC)/%.c
	$(CC) $(CFLAGS) -c -o $@ $<

168
169
170
$(BUILD)/%.o: $(CC3KSRC)/%.c
	$(CC) $(CFLAGS) -c -o $@ $<

171
$(BUILD)/%.o: $(PYSRC)/%.s
Damien's avatar
Damien committed
172
	$(AS) -o $@ $<
173

174
175
176
$(BUILD)/%.o: $(PYSRC)/%.S
	$(CC) $(CFLAGS) -c -o $@ $<

177
$(BUILD)/%.o: $(PYSRC)/%.c mpconfig.h
178
	$(CC) $(CFLAGS) -c -o $@ $<
Damien's avatar
Damien committed
179
180

$(BUILD)/emitnthumb.o: $(PYSRC)/emitnative.c $(PYSRC)/emit.h
181
	$(CC) $(CFLAGS) -DN_THUMB -c -o $@ $<
Damien's avatar
Damien committed
182

183
184
185
186
# optimising gc for speed; 5ms down to 4ms
$(BUILD)/gc.o: $(PYSRC)/gc.c
	$(CC) $(CFLAGS) -O3 -c -o $@ $<

Damien's avatar
Damien committed
187
188
# optimising vm for speed, adds only a small amount to code size but makes a huge difference to speed (20% faster)
$(BUILD)/vm.o: $(PYSRC)/vm.c
189
	$(CC) $(CFLAGS) -O3 -c -o $@ $<
Damien's avatar
Damien committed
190
191
192
193
194
195
196
197
198

$(BUILD)/parse.o: $(PYSRC)/grammar.h
$(BUILD)/compile.o: $(PYSRC)/grammar.h
$(BUILD)/emitbc.o: $(PYSRC)/emit.h

clean:
	/bin/rm -r $(BUILD)

.PHONY: all clean