Makefile 3.04 KB
Newer Older
1
2
3
4
5
6
7
8
# define main target
all: all2

# include py core make definitions
include ../py/py.mk

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

Damien's avatar
Damien committed
11
STMSRC=lib
12
#STMOTGSRC=lib-otg
Damien's avatar
Damien committed
13
FATFSSRC=fatfs
14
CC3KSRC=cc3k
15
DFU=../tools/dfu.py
16
TARGET=PYBOARD
Damien's avatar
Damien committed
17
18
19
20

AS = arm-none-eabi-as
CC = arm-none-eabi-gcc
LD = arm-none-eabi-ld
21
22
23
OBJCOPY = arm-none-eabi-objcopy
SIZE = arm-none-eabi-size

24
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
25
CFLAGS = -I. -I$(PY_SRC) -I$(FATFSSRC) -I$(STMSRC) -Wall -ansi -std=gnu99 -Os -DNDEBUG $(CFLAGS_CORTEX_M4) -D$(TARGET)
26
#CFLAGS += -I$(STMOTGSRC) -DUSE_HOST_MODE -DUSE_OTG_MODE
27
LDFLAGS = --nostdlib -T stm32f405.ld
Damien's avatar
Damien committed
28
29
30
31
32

SRC_C = \
	main.c \
	printf.c \
	system_stm32f4xx.c \
Damien's avatar
Damien committed
33
34
35
36
	stm32fxxx_it.c \
	string0.c \
	malloc0.c \
	systick.c  \
37
	lexerfatfs.c \
38
	led.c \
39
	lcd.c \
40
	servo.c \
Damien's avatar
Damien committed
41
	flash.c \
42
	storage.c \
43
	mma.c \
44
	usart.c \
Damien's avatar
Damien committed
45
	usb.c \
46
	timer.c \
47
	audio.c \
Damien's avatar
Damien committed
48
	sdio.c \
49
	pybwlan.c \
50
	i2c.c \
51
	usrsw.c \
Damien's avatar
Damien committed
52
53
54

SRC_S = \
	startup_stm32f40xx.s \
55
	gchelper.s \
Damien's avatar
Damien committed
56
57
58
59
60
61
62

SRC_FATFS = \
	ff.c \
	diskio.c \

SRC_STM = \
	stm32f4xx_rcc.c \
63
	stm32f4xx_syscfg.c \
Damien's avatar
Damien committed
64
	stm_misc.c \
Damien's avatar
Damien committed
65
66
67
	stm32f4xx_flash.c \
	stm32f4xx_dma.c \
	stm32f4xx_gpio.c \
68
	stm32f4xx_exti.c \
69
	stm32f4xx_tim.c \
70
	stm32f4xx_sdio.c \
71
72
	stm32f4xx_pwr.c \
	stm32f4xx_rtc.c \
73
	stm32f4xx_usart.c \
74
	stm32f4xx_spi.c \
75
	stm32f4xx_dac.c \
Damien's avatar
Damien committed
76
	stm32f4xx_rng.c \
Damien's avatar
Damien committed
77
78
79
80
81
82
83
84
85
	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 \
86
	usbd_pyb_core.c \
87
	usbd_pyb_core2.c \
Damien's avatar
Damien committed
88
89
90
91
92
	usbd_cdc_vcp.c \
	usbd_msc_bot.c  \
	usbd_msc_data.c \
	usbd_msc_scsi.c \
	usbd_storage_msd.c \
93
94
	stm324x7i_eval.c \
	stm324x7i_eval_sdio_sd.c \
Damien's avatar
Damien committed
95

96
97
98
99
100
#SRC_STM_OTG = \
#	usb_hcd.c \
#	usb_hcd_int.c \
#	usb_otg.c \

101
102
103
104
105
106
107
108
109
110
111
112
SRC_CC3K = \
	cc3000_common.c \
	evnt_handler.c \
	hci.c \
	netapp.c \
	nvmem.c \
	security.c \
	socket.c \
	wlan.c \
	ccspi.c \
	pybcc3k.c \

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

116
all2: $(BUILD) $(BUILD)/flash.dfu
Damien's avatar
Damien committed
117

118
$(BUILD)/flash.dfu: $(BUILD)/flash0.bin $(BUILD)/flash1.bin
Dave Hylands's avatar
Dave Hylands committed
119
120
	$(ECHO) "Create $@"
	$(Q)python $(DFU) -b 0x08000000:$(BUILD)/flash0.bin -b 0x08020000:$(BUILD)/flash1.bin $@
Damien's avatar
Damien committed
121

122
$(BUILD)/flash0.bin: $(BUILD)/flash.elf
Dave Hylands's avatar
Dave Hylands committed
123
	$(Q)$(OBJCOPY) -O binary -j .isr_vector $^ $@
124
125

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

$(BUILD)/flash.elf: $(OBJ)
Dave Hylands's avatar
Dave Hylands committed
129
130
131
	$(ECHO) "LINK $@"
	$(Q)$(LD) $(LDFLAGS) -o $@ $(OBJ)
	$(Q)$(SIZE) $@
Damien's avatar
Damien committed
132
133

$(BUILD)/%.o: %.s
Dave Hylands's avatar
Dave Hylands committed
134
135
	$(ECHO) "AS $<"
	$(Q)$(AS) -o $@ $<
Damien's avatar
Damien committed
136
137

$(BUILD)/%.o: %.c
Dave Hylands's avatar
Dave Hylands committed
138
139
	$(ECHO) "CC $<"
	$(Q)$(CC) $(CFLAGS) -c -o $@ $<
Damien's avatar
Damien committed
140
141

$(BUILD)/%.o: $(FATFSSRC)/%.c
Dave Hylands's avatar
Dave Hylands committed
142
143
	$(ECHO) "CC $<"
	$(Q)$(CC) $(CFLAGS) -c -o $@ $<
Damien's avatar
Damien committed
144
145

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

149
#$(BUILD)/%.o: $(STMOTGSRC)/%.c
Dave Hylands's avatar
Dave Hylands committed
150
151
#	$(ECHO) "CC $<"
#	$(Q)$(CC) $(CFLAGS) -c -o $@ $<
152

153
$(BUILD)/%.o: $(CC3KSRC)/%.c
Dave Hylands's avatar
Dave Hylands committed
154
155
	$(ECHO) "CC $<"
	$(Q)$(CC) $(CFLAGS) -c -o $@ $<
156

Damien's avatar
Damien committed
157
clean:
158
	$(RM) -rf $(BUILD)
Damien's avatar
Damien committed
159

160
.PHONY: all all2 clean