Makefile 3.98 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
8
TARGET=PYBOARD
Damien's avatar
Damien committed
9
10
11
12

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

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

SRC_S = \
	startup_stm32f40xx.s \
44
	gchelper.s \
Damien's avatar
Damien committed
45
46

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

SRC_FATFS = \
	ff.c \
	diskio.c \

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

132
133
134
135
136
#SRC_STM_OTG = \
#	usb_hcd.c \
#	usb_hcd_int.c \
#	usb_otg.c \

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

.PHONY: all clean