Makefile 2.95 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
CMSIS=cmsis
Damien's avatar
Damien committed
10
STMSRC=lib
11
#STMOTGSRC=usbhost
Damien's avatar
Damien committed
12
FATFSSRC=fatfs
13
CC3KSRC=cc3k
14
DFU=../tools/dfu.py
Damien's avatar
Damien committed
15

16
CROSS_COMPILE = arm-none-eabi-
17

18
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
19
CFLAGS = -I. -I$(PY_SRC) -I$(FATFSSRC) -I$(CMSIS) -I$(STMSRC) -Wall -ansi -std=gnu99 $(CFLAGS_CORTEX_M4)
20
#CFLAGS += -I$(STMOTGSRC) -DUSE_HOST_MODE #-DUSE_OTG_MODE
mux's avatar
mux committed
21
22
23

#Debugging/Optimization
ifeq ($(DEBUG), 1)
mux's avatar
mux committed
24
CFLAGS += -O0 -ggdb
mux's avatar
mux committed
25
else
mux's avatar
mux committed
26
CFLAGS += -Os -DNDEBUG
mux's avatar
mux committed
27
28
endif

29
LDFLAGS = --nostdlib -T stm32f405.ld
30
31
32
33
LIBS =

# uncomment this if you want libgcc
#LIBS += $(shell $(CC) -print-libgcc-file-name)
Damien's avatar
Damien committed
34
35
36
37
38

SRC_C = \
	main.c \
	printf.c \
	system_stm32f4xx.c \
Damien's avatar
Damien committed
39
40
41
42
	stm32fxxx_it.c \
	string0.c \
	malloc0.c \
	systick.c  \
43
	lexerfatfs.c \
44
	led.c \
45
	lcd.c \
46
	servo.c \
Damien's avatar
Damien committed
47
	flash.c \
48
	storage.c \
49
	mma.c \
50
	usart.c \
Damien's avatar
Damien committed
51
	usb.c \
52
	timer.c \
53
	audio.c \
Damien's avatar
Damien committed
54
	sdio.c \
55
	i2c.c \
56
	usrsw.c \
mux's avatar
mux committed
57
	adc.c \
mux's avatar
mux committed
58
	rtc.c \
mux's avatar
mux committed
59
	file.c \
60
#	pybwlan.c \
Damien's avatar
Damien committed
61
62
63

SRC_S = \
	startup_stm32f40xx.s \
64
	gchelper.s \
Damien's avatar
Damien committed
65

66
SRC_FATFS = $(addprefix $(FATFSSRC)/,\
Damien's avatar
Damien committed
67
68
	ff.c \
	diskio.c \
69
	)
Damien's avatar
Damien committed
70

71
SRC_STM = $(addprefix $(STMSRC)/,\
Damien's avatar
Damien committed
72
	stm32f4xx_rcc.c \
73
	stm32f4xx_syscfg.c \
Damien's avatar
Damien committed
74
	stm_misc.c \
Damien's avatar
Damien committed
75
76
77
	stm32f4xx_flash.c \
	stm32f4xx_dma.c \
	stm32f4xx_gpio.c \
78
	stm32f4xx_exti.c \
79
	stm32f4xx_tim.c \
80
	stm32f4xx_sdio.c \
81
82
	stm32f4xx_pwr.c \
	stm32f4xx_rtc.c \
83
	stm32f4xx_usart.c \
84
	stm32f4xx_spi.c \
85
	stm32f4xx_dac.c \
Damien's avatar
Damien committed
86
	stm32f4xx_rng.c \
87
	stm32f4xx_i2c.c \
88
89
90
	stm32f4xx_adc.c \
	stm324x7i_eval.c \
	stm324x7i_eval_sdio_sd.c \
Damien's avatar
Damien committed
91
	usb_core.c \
92
	usb_bsp.c \
Damien's avatar
Damien committed
93
94
95
96
97
98
99
	usb_dcd.c \
	usb_dcd_int.c \
	usbd_core.c \
	usbd_ioreq.c \
	usbd_req.c \
	usbd_usr.c \
	usbd_desc.c \
100
	usbd_pyb_core.c \
101
	usbd_pyb_core2.c \
Damien's avatar
Damien committed
102
103
104
105
106
	usbd_cdc_vcp.c \
	usbd_msc_bot.c  \
	usbd_msc_data.c \
	usbd_msc_scsi.c \
	usbd_storage_msd.c \
107
	)
Damien's avatar
Damien committed
108

109
#SRC_STM_OTG = $(addprefix $(STMSRC)/,\
110
111
112
113
114
115
116
117
118
119
	usb_hcd.c \
	usb_hcd_int.c \
	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 \
120
#	usb_otg.c \
121
	)
122

123
SRC_CC3K = $(addprefix $(CC3KSRC)/,\
124
125
126
127
128
129
130
131
132
133
	cc3000_common.c \
	evnt_handler.c \
	hci.c \
	netapp.c \
	nvmem.c \
	security.c \
	socket.c \
	wlan.c \
	ccspi.c \
	pybcc3k.c \
134
	)
135

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

139
all: $(BUILD) $(BUILD)/flash.dfu
Damien's avatar
Damien committed
140

141
$(BUILD)/flash.dfu: $(BUILD)/flash0.bin $(BUILD)/flash1.bin
Dave Hylands's avatar
Dave Hylands committed
142
143
	$(ECHO) "Create $@"
	$(Q)python $(DFU) -b 0x08000000:$(BUILD)/flash0.bin -b 0x08020000:$(BUILD)/flash1.bin $@
Damien's avatar
Damien committed
144

145
$(BUILD)/flash0.bin: $(BUILD)/flash.elf
Dave Hylands's avatar
Dave Hylands committed
146
	$(Q)$(OBJCOPY) -O binary -j .isr_vector $^ $@
147
148

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

$(BUILD)/flash.elf: $(OBJ)
Dave Hylands's avatar
Dave Hylands committed
152
	$(ECHO) "LINK $@"
153
	$(Q)$(LD) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
Dave Hylands's avatar
Dave Hylands committed
154
	$(Q)$(SIZE) $@
Damien's avatar
Damien committed
155

156
include ../py/mkrules.mk
Damien's avatar
Damien committed
157