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

AS = arm-none-eabi-as
CC = arm-none-eabi-gcc
LD = arm-none-eabi-ld
12
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
13
CFLAGS = -I. -I$(PYSRC) -I$(FATFSSRC) -I$(STMSRC) -Wall -ansi -std=gnu99 -Os -DNDEBUG $(CFLAGS_CORTEX_M4)
14
#CFLAGS += -I$(STMOTGSRC) -DUSE_HOST_MODE -DUSE_OTG_MODE
15
LDFLAGS = --nostdlib -T stm32f405.ld
Damien's avatar
Damien committed
16
17
18
19
20

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

SRC_S = \
	startup_stm32f40xx.s \
42
	gchelper.s \
Damien's avatar
Damien committed
43
44

PY_O = \
45
	nlrthumb.o \
Damien's avatar
Damien committed
46
	gc.o \
47
	malloc.o \
Damien's avatar
Damien committed
48
	qstr.o \
49
	vstr.o \
50
	unicode.o \
Damien's avatar
Damien committed
51
52
53
54
55
56
57
58
59
60
	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
61
	runtime.o \
62
63
	map.o \
	obj.o \
64
65
66
67
68
69
70
71
72
73
74
75
	objbool.o \
	objboundmeth.o \
	objcell.o \
	objclass.o \
	objclosure.o \
	objcomplex.o \
	objdict.o \
	objexcept.o \
	objfloat.o \
	objfun.o \
	objgenerator.o \
	objinstance.o \
76
	objint.o \
77
	objlist.o \
78
	objmodule.o \
79
80
81
	objnone.o \
	objrange.o \
	objset.o \
82
	objslice.o \
83
84
85
	objstr.o \
	objtuple.o \
	objtype.o \
86
	builtin.o \
87
	builtinimport.o \
Damien's avatar
Damien committed
88
	vm.o \
89
	repl.o \
Damien's avatar
Damien committed
90
91
92
93
94
95
96

SRC_FATFS = \
	ff.c \
	diskio.c \

SRC_STM = \
	stm32f4xx_rcc.c \
97
	stm32f4xx_syscfg.c \
Damien's avatar
Damien committed
98
	stm_misc.c \
Damien's avatar
Damien committed
99
100
101
	stm32f4xx_flash.c \
	stm32f4xx_dma.c \
	stm32f4xx_gpio.c \
102
	stm32f4xx_exti.c \
103
	stm32f4xx_tim.c \
104
	stm32f4xx_sdio.c \
105
106
	stm32f4xx_pwr.c \
	stm32f4xx_rtc.c \
107
	stm32f4xx_usart.c \
108
	stm32f4xx_spi.c \
109
	stm32f4xx_dac.c \
Damien's avatar
Damien committed
110
	stm32f4xx_rng.c \
Damien's avatar
Damien committed
111
112
113
114
115
116
117
118
119
	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 \
120
	usbd_pyb_core.c \
121
	usbd_pyb_core2.c \
Damien's avatar
Damien committed
122
123
124
125
126
	usbd_cdc_vcp.c \
	usbd_msc_bot.c  \
	usbd_msc_data.c \
	usbd_msc_scsi.c \
	usbd_storage_msd.c \
127
128
	stm324x7i_eval.c \
	stm324x7i_eval_sdio_sd.c \
Damien's avatar
Damien committed
129

130
131
132
133
134
#SRC_STM_OTG = \
#	usb_hcd.c \
#	usb_hcd_int.c \
#	usb_otg.c \

135
136
137
138
139
140
141
142
143
144
145
146
147
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))
148
#OBJ += $(addprefix $(BUILD)/, $(SRC_STM_OTG:.c=.o))
Damien's avatar
Damien committed
149
150
151

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

152
$(BUILD)/flash.dfu: $(BUILD)/flash0.bin $(BUILD)/flash1.bin
153
	python $(DFU) -b 0x08000000:$(BUILD)/flash0.bin -b 0x08020000:$(BUILD)/flash1.bin $@
Damien's avatar
Damien committed
154

155
156
157
158
159
$(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
160
161
162
163
164
165

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

$(BUILD):
166
	mkdir -p $@
Damien's avatar
Damien committed
167
168
169
170
171
172
173
174
175
176
177
178
179

$(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 $@ $<

180
181
182
#$(BUILD)/%.o: $(STMOTGSRC)/%.c
#	$(CC) $(CFLAGS) -c -o $@ $<

183
184
185
$(BUILD)/%.o: $(CC3KSRC)/%.c
	$(CC) $(CFLAGS) -c -o $@ $<

186
$(BUILD)/%.o: $(PYSRC)/%.s
Damien's avatar
Damien committed
187
	$(AS) -o $@ $<
188

189
190
191
$(BUILD)/%.o: $(PYSRC)/%.S
	$(CC) $(CFLAGS) -c -o $@ $<

192
$(BUILD)/%.o: $(PYSRC)/%.c mpconfigport.h
193
	$(CC) $(CFLAGS) -c -o $@ $<
Damien's avatar
Damien committed
194
195

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

198
199
200
201
# optimising gc for speed; 5ms down to 4ms
$(BUILD)/gc.o: $(PYSRC)/gc.c
	$(CC) $(CFLAGS) -O3 -c -o $@ $<

Damien's avatar
Damien committed
202
203
# 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
204
	$(CC) $(CFLAGS) -O3 -c -o $@ $<
Damien's avatar
Damien committed
205
206
207
208
209
210

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

clean:
211
	/bin/rm -rf $(BUILD)
Damien's avatar
Damien committed
212
213

.PHONY: all clean