Makefile 3.5 KB
Newer Older
1
2
3
# define main target
all: all2

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

7
8
9
10
11
# include py core make definitions
include ../py/py.mk

# program for deletion
RM = /bin/rm
Dave Hylands's avatar
Dave Hylands committed
12
ECHO = @echo
13

14
CMSIS=cmsis
Damien's avatar
Damien committed
15
STMSRC=lib
16
#STMOTGSRC=lib-otg
Damien's avatar
Damien committed
17
FATFSSRC=fatfs
18
CC3KSRC=cc3k
19
DFU=../tools/dfu.py
mux's avatar
mux committed
20
OSC_VALUE=8000000
Damien's avatar
Damien committed
21
22
23
24

AS = arm-none-eabi-as
CC = arm-none-eabi-gcc
LD = arm-none-eabi-ld
25
26
27
OBJCOPY = arm-none-eabi-objcopy
SIZE = arm-none-eabi-size

mux's avatar
mux committed
28
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 -DSTM32F40_41xxx -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=$(OSC_VALUE)
29
CFLAGS = -I. -I$(PY_SRC) -I$(FATFSSRC) -I$(CMSIS) -I$(STMSRC) -Wall -ansi -std=gnu99 $(CFLAGS_CORTEX_M4)
30
#CFLAGS += -I$(STMOTGSRC) -DUSE_HOST_MODE -DUSE_OTG_MODE
mux's avatar
mux committed
31
32
33

#Debugging/Optimization
ifeq ($(DEBUG), 1)
mux's avatar
mux committed
34
CFLAGS += -O0 -ggdb
mux's avatar
mux committed
35
else
mux's avatar
mux committed
36
CFLAGS += -Os -DNDEBUG
mux's avatar
mux committed
37
38
endif

39
LDFLAGS = --nostdlib -T stm32f405.ld
40
LIBS = $(shell $(CC) -print-libgcc-file-name)
Damien's avatar
Damien committed
41
42
43
44
45

SRC_C = \
	main.c \
	printf.c \
	system_stm32f4xx.c \
Damien's avatar
Damien committed
46
47
48
49
	stm32fxxx_it.c \
	string0.c \
	malloc0.c \
	systick.c  \
50
	lexerfatfs.c \
51
	led.c \
52
	lcd.c \
53
	servo.c \
Damien's avatar
Damien committed
54
	flash.c \
55
	storage.c \
56
	mma.c \
57
	usart.c \
Damien's avatar
Damien committed
58
	usb.c \
59
	timer.c \
60
	audio.c \
Damien's avatar
Damien committed
61
	sdio.c \
62
	pybwlan.c \
63
	i2c.c \
64
	usrsw.c \
mux's avatar
mux committed
65
	adc.c \
Damien's avatar
Damien committed
66
67
68

SRC_S = \
	startup_stm32f40xx.s \
69
	gchelper.s \
Damien's avatar
Damien committed
70
71
72
73
74
75
76

SRC_FATFS = \
	ff.c \
	diskio.c \

SRC_STM = \
	stm32f4xx_rcc.c \
77
	stm32f4xx_syscfg.c \
Damien's avatar
Damien committed
78
	stm_misc.c \
Damien's avatar
Damien committed
79
80
81
	stm32f4xx_flash.c \
	stm32f4xx_dma.c \
	stm32f4xx_gpio.c \
82
	stm32f4xx_exti.c \
83
	stm32f4xx_tim.c \
84
	stm32f4xx_sdio.c \
85
86
	stm32f4xx_pwr.c \
	stm32f4xx_rtc.c \
87
	stm32f4xx_usart.c \
88
	stm32f4xx_spi.c \
89
	stm32f4xx_dac.c \
Damien's avatar
Damien committed
90
	stm32f4xx_rng.c \
91
	stm32f4xx_i2c.c \
Damien's avatar
Damien committed
92
93
94
95
96
97
98
99
100
	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 \
101
	usbd_pyb_core.c \
102
	usbd_pyb_core2.c \
Damien's avatar
Damien committed
103
104
105
106
107
	usbd_cdc_vcp.c \
	usbd_msc_bot.c  \
	usbd_msc_data.c \
	usbd_msc_scsi.c \
	usbd_storage_msd.c \
108
109
	stm324x7i_eval.c \
	stm324x7i_eval_sdio_sd.c \
mux's avatar
mux committed
110
	stm32f4xx_adc.c \
Damien's avatar
Damien committed
111

112
113
114
115
#SRC_STM_OTG = \
#	usb_hcd.c \
#	usb_hcd_int.c \
#	usb_otg.c \
116
117
118
119
120
121
122
123
#	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 \
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 \

137
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))
138
#OBJ += $(addprefix $(BUILD)/, $(SRC_STM_OTG:.c=.o))
Damien's avatar
Damien committed
139

140
all2: $(BUILD) $(BUILD)/flash.dfu
Damien's avatar
Damien committed
141

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

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

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

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

$(BUILD)/%.o: %.s
Dave Hylands's avatar
Dave Hylands committed
158
159
	$(ECHO) "AS $<"
	$(Q)$(AS) -o $@ $<
Damien's avatar
Damien committed
160

161
$(BUILD)/%.o: %.c $(QSTR_DEFS)
Dave Hylands's avatar
Dave Hylands committed
162
163
	$(ECHO) "CC $<"
	$(Q)$(CC) $(CFLAGS) -c -o $@ $<
Damien's avatar
Damien committed
164
165

$(BUILD)/%.o: $(FATFSSRC)/%.c
Dave Hylands's avatar
Dave Hylands committed
166
167
	$(ECHO) "CC $<"
	$(Q)$(CC) $(CFLAGS) -c -o $@ $<
Damien's avatar
Damien committed
168
169

$(BUILD)/%.o: $(STMSRC)/%.c
Dave Hylands's avatar
Dave Hylands committed
170
171
	$(ECHO) "CC $<"
	$(Q)$(CC) $(CFLAGS) -c -o $@ $<
Damien's avatar
Damien committed
172

173
#$(BUILD)/%.o: $(STMOTGSRC)/%.c
Dave Hylands's avatar
Dave Hylands committed
174
175
#	$(ECHO) "CC $<"
#	$(Q)$(CC) $(CFLAGS) -c -o $@ $<
176

177
$(BUILD)/%.o: $(CC3KSRC)/%.c
Dave Hylands's avatar
Dave Hylands committed
178
179
	$(ECHO) "CC $<"
	$(Q)$(CC) $(CFLAGS) -c -o $@ $<
180

Damien's avatar
Damien committed
181
clean:
182
	$(RM) -rf $(BUILD)
Damien's avatar
Damien committed
183

184
.PHONY: all all2 clean