Makefile 3.41 KB
Newer Older
1
include ../py/mkenv.mk
2

3
4
5
# qstr definitions (must come before including py.mk)
QSTR_DEFS = qstrdefsport.h

6
7
8
# include py core make definitions
include ../py/py.mk

9
10
11
12
13
14
15
CMSIS_DIR=cmsis
STMPERIPH_DIR=stmperiph
STMUSB_DIR=stmusb
STMUSBD_DIR=stmusbd
STMUSBH_DIR=stmusbh
FATFS_DIR=fatfs
CC3K_DIR=cc3k
16
DFU=../tools/dfu.py
Damien's avatar
Damien committed
17

18
CROSS_COMPILE = arm-none-eabi-
19

20
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
21
CFLAGS = -I. -I$(PY_SRC) -I$(CMSIS_DIR) -I$(STMPERIPH_DIR) -I$(STMUSB_DIR) -Wall -Werror -ansi -std=gnu99 $(CFLAGS_CORTEX_M4) $(COPT)
22
23
24
25
CFLAGS += -I$(STMUSBD_DIR)
CFLAGS += -I$(STMUSBH_DIR)
CFLAGS += -I$(FATFS_DIR)
#CFLAGS += -I$(CC3K_DIR)
mux's avatar
mux committed
26
27
28

#Debugging/Optimization
ifeq ($(DEBUG), 1)
29
30
CFLAGS += -g
COPT = -O0
mux's avatar
mux committed
31
else
32
COPT += -Os -DNDEBUG
mux's avatar
mux committed
33
34
endif

35
LDFLAGS = --nostdlib -T stm32f405.ld -Map=$(@:.elf=.map) --cref
36
37
38
39
LIBS =

# uncomment this if you want libgcc
#LIBS += $(shell $(CC) -print-libgcc-file-name)
Damien's avatar
Damien committed
40
41
42
43
44

SRC_C = \
	main.c \
	printf.c \
	system_stm32f4xx.c \
Damien's avatar
Damien committed
45
46
47
48
	stm32fxxx_it.c \
	string0.c \
	malloc0.c \
	systick.c  \
49
	pendsv.c \
50
	gccollect.c \
51
	lexerfatfs.c \
Damien George's avatar
Damien George committed
52
	import.c \
53
	pyexec.c \
54
	led.c \
55
	gpio.c \
56
	lcd.c \
57
	servo.c \
Damien's avatar
Damien committed
58
	flash.c \
59
	storage.c \
Damien George's avatar
Damien George committed
60
	accel.c \
61
	usart.c \
Damien's avatar
Damien committed
62
	usb.c \
63
	timer.c \
64
	audio.c \
65
	sdcard.c \
66
	i2c.c \
67
	usrsw.c \
mux's avatar
mux committed
68
	adc.c \
mux's avatar
mux committed
69
	rtc.c \
mux's avatar
mux committed
70
	file.c \
71
#	pybwlan.c \
Damien's avatar
Damien committed
72
73
74

SRC_S = \
	startup_stm32f40xx.s \
75
	gchelper.s \
Damien's avatar
Damien committed
76

77
78
SRC_STMPERIPH = $(addprefix $(STMPERIPH_DIR)/,\
	stm_misc.c \
Damien's avatar
Damien committed
79
	stm32f4xx_rcc.c \
80
	stm32f4xx_syscfg.c \
Damien's avatar
Damien committed
81
82
83
	stm32f4xx_flash.c \
	stm32f4xx_dma.c \
	stm32f4xx_gpio.c \
84
	stm32f4xx_exti.c \
85
	stm32f4xx_tim.c \
86
	stm32f4xx_sdio.c \
87
88
	stm32f4xx_pwr.c \
	stm32f4xx_rtc.c \
89
	stm32f4xx_usart.c \
90
	stm32f4xx_spi.c \
91
	stm32f4xx_dac.c \
Damien's avatar
Damien committed
92
	stm32f4xx_rng.c \
93
	stm32f4xx_i2c.c \
94
95
96
	stm32f4xx_adc.c \
	stm324x7i_eval.c \
	stm324x7i_eval_sdio_sd.c \
97
98
99
	)

SRC_STMUSB = $(addprefix $(STMUSB_DIR)/,\
Damien's avatar
Damien committed
100
	usb_core.c \
101
	usb_bsp.c \
Damien's avatar
Damien committed
102
103
	usb_dcd.c \
	usb_dcd_int.c \
104
105
106
107
108
109
	usb_hcd.c \
	usb_hcd_int.c \
	)
#	usb_otg.c \

SRC_STMUSBD = $(addprefix $(STMUSBD_DIR)/,\
Damien's avatar
Damien committed
110
111
112
113
114
	usbd_core.c \
	usbd_ioreq.c \
	usbd_req.c \
	usbd_usr.c \
	usbd_desc.c \
115
	usbd_pyb_core.c \
116
	usbd_pyb_core2.c \
Damien's avatar
Damien committed
117
118
119
120
121
	usbd_cdc_vcp.c \
	usbd_msc_bot.c  \
	usbd_msc_data.c \
	usbd_msc_scsi.c \
	usbd_storage_msd.c \
122
	)
Damien's avatar
Damien committed
123

124
SRC_STMUSBH = $(addprefix $(STMUSBH_DIR)/,\
125
126
127
128
129
130
131
132
	usbh_core.c \
	usbh_hcs.c \
	usbh_stdreq.c \
	usbh_ioreq.c \
	usbh_usr.c \
	usbh_hid_core.c \
	usbh_hid_mouse.c \
	usbh_hid_keybd.c \
133
	)
134

135
136
137
138
139
140
SRC_FATFS = $(addprefix $(FATFS_DIR)/,\
	ff.c \
	diskio.c \
	)

SRC_CC3K = $(addprefix $(CC3K_DIR)/,\
141
142
143
144
145
146
147
148
149
150
	cc3000_common.c \
	evnt_handler.c \
	hci.c \
	netapp.c \
	nvmem.c \
	security.c \
	socket.c \
	wlan.c \
	ccspi.c \
	pybcc3k.c \
151
	)
152

153
154
155
156
157
OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o) $(SRC_S:.s=.o) $(SRC_STMPERIPH:.c=.o) $(SRC_STMUSB:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_STMUSBD:.c=.o))
#OBJ += $(addprefix $(BUILD)/, $(SRC_STMUSBH:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_FATFS:.c=.o))
#OBJ += $(addprefix $(BUILD)/, $(SRC_CC3K:.c=.o))
Damien's avatar
Damien committed
158

159
all: $(BUILD)/flash.dfu
Damien's avatar
Damien committed
160

161
$(BUILD)/flash.dfu: $(BUILD)/flash0.bin $(BUILD)/flash1.bin
Dave Hylands's avatar
Dave Hylands committed
162
163
	$(ECHO) "Create $@"
	$(Q)python $(DFU) -b 0x08000000:$(BUILD)/flash0.bin -b 0x08020000:$(BUILD)/flash1.bin $@
Damien's avatar
Damien committed
164

165
$(BUILD)/flash0.bin: $(BUILD)/flash.elf
Dave Hylands's avatar
Dave Hylands committed
166
	$(Q)$(OBJCOPY) -O binary -j .isr_vector $^ $@
167
168

$(BUILD)/flash1.bin: $(BUILD)/flash.elf
Dave Hylands's avatar
Dave Hylands committed
169
	$(Q)$(OBJCOPY) -O binary -j .text -j .data $^ $@
Damien's avatar
Damien committed
170
171

$(BUILD)/flash.elf: $(OBJ)
Dave Hylands's avatar
Dave Hylands committed
172
	$(ECHO) "LINK $@"
173
	$(Q)$(LD) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
Dave Hylands's avatar
Dave Hylands committed
174
	$(Q)$(SIZE) $@
Damien's avatar
Damien committed
175

176
include ../py/mkrules.mk