|
| 1 | +include ../py/mkenv.mk |
| 2 | + |
| 3 | +# qstr definitions (must come before including py.mk) |
| 4 | +QSTR_DEFS = qstrdefsport.h |
| 5 | + |
| 6 | +# include py core make definitions |
| 7 | +include ../py/py.mk |
| 8 | + |
| 9 | +CMSIS_DIR=cmsis |
| 10 | +HAL_DIR=hal |
| 11 | +#STMUSB_DIR=stmusb |
| 12 | +#STMUSBD_DIR=stmusbd |
| 13 | +#STMUSBH_DIR=stmusbh |
| 14 | +#FATFS_DIR=fatfs |
| 15 | +#CC3K_DIR=cc3k |
| 16 | +DFU=../tools/dfu.py |
| 17 | + |
| 18 | +CROSS_COMPILE = arm-none-eabi- |
| 19 | + |
| 20 | +INC = -I. |
| 21 | +INC += -I$(PY_SRC) |
| 22 | +INC += -I$(CMSIS_DIR)/inc |
| 23 | +INC += -I$(CMSIS_DIR)/devinc |
| 24 | +INC += -I$(HAL_DIR)/inc |
| 25 | +#INC += -I$(STMUSB_DIR) |
| 26 | +#INC += -I$(STMUSBD_DIR) |
| 27 | +#INC += -I$(STMUSBH_DIR) |
| 28 | +#INC += -I$(FATFS_DIR) |
| 29 | +#INC += -I$(CC3K_DIR) |
| 30 | + |
| 31 | +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 |
| 32 | +CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 $(CFLAGS_CORTEX_M4) $(COPT) |
| 33 | + |
| 34 | +BOARD = STM32F4DISC |
| 35 | +BOARD ?= PYBOARD4 |
| 36 | +ifeq ($(wildcard boards/$(BOARD)/.),) |
| 37 | +$(error Invalid BOARD specified) |
| 38 | +endif |
| 39 | +CFLAGS += -Iboards/$(BOARD) |
| 40 | + |
| 41 | +#Debugging/Optimization |
| 42 | +ifeq ($(DEBUG), 1) |
| 43 | +CFLAGS += -g -DPENDSV_DEBUG |
| 44 | +COPT = -O0 |
| 45 | +else |
| 46 | +COPT += -Os -DNDEBUG |
| 47 | +endif |
| 48 | + |
| 49 | +LDFLAGS = --nostdlib -T stm32f405.ld -Map=$(@:.elf=.map) --cref |
| 50 | +LIBS = |
| 51 | + |
| 52 | +# uncomment this if you want libgcc |
| 53 | +#LIBS += $(shell $(CC) -print-libgcc-file-name) |
| 54 | + |
| 55 | +SRC_C = \ |
| 56 | + main.c \ |
| 57 | + system_stm32f4xx.c \ |
| 58 | + |
| 59 | +# printf.c \ |
| 60 | +# math.c \ |
| 61 | +# stm32fxxx_it.c \ |
| 62 | +# string0.c \ |
| 63 | +# malloc0.c \ |
| 64 | +# systick.c \ |
| 65 | +# pendsv.c \ |
| 66 | +# gccollect.c \ |
| 67 | +# lexerfatfs.c \ |
| 68 | +# import.c \ |
| 69 | +# pyexec.c \ |
| 70 | +# led.c \ |
| 71 | +# gpio.c \ |
| 72 | +# lcd.c \ |
| 73 | +# servo.c \ |
| 74 | +# flash.c \ |
| 75 | +# storage.c \ |
| 76 | +# accel.c \ |
| 77 | +# usart.c \ |
| 78 | +# usb.c \ |
| 79 | +# timer.c \ |
| 80 | +# audio.c \ |
| 81 | +# sdcard.c \ |
| 82 | +# i2c.c \ |
| 83 | +# adc.c \ |
| 84 | +# rtc.c \ |
| 85 | +# file.c \ |
| 86 | +# pin.c \ |
| 87 | +# pin_named_pins.c \ |
| 88 | +# pin_map.c \ |
| 89 | +# exti.c \ |
| 90 | +# usrsw.c \ |
| 91 | +# pybmodule.c \ |
| 92 | +# pybwlan.c \ |
| 93 | +
|
| 94 | +SRC_S = \ |
| 95 | + startup_stm32f40xx.s \ |
| 96 | + |
| 97 | +# gchelper.s \ |
| 98 | +
|
| 99 | +SRC_HAL = $(addprefix $(HAL_DIR)/src/,\ |
| 100 | + stm32f4xx_hal.c \ |
| 101 | + stm32f4xx_hal_cortex.c \ |
| 102 | + ) |
| 103 | + |
| 104 | +SRC_STMPERIPH = $(addprefix $(STMPERIPH_DIR)/,\ |
| 105 | + stm_misc.c \ |
| 106 | + stm32f4xx_rcc.c \ |
| 107 | + stm32f4xx_syscfg.c \ |
| 108 | + stm32f4xx_flash.c \ |
| 109 | + stm32f4xx_dma.c \ |
| 110 | + stm32f4xx_gpio.c \ |
| 111 | + stm32f4xx_exti.c \ |
| 112 | + stm32f4xx_tim.c \ |
| 113 | + stm32f4xx_sdio.c \ |
| 114 | + stm32f4xx_pwr.c \ |
| 115 | + stm32f4xx_rtc.c \ |
| 116 | + stm32f4xx_usart.c \ |
| 117 | + stm32f4xx_spi.c \ |
| 118 | + stm32f4xx_dac.c \ |
| 119 | + stm32f4xx_rng.c \ |
| 120 | + stm32f4xx_i2c.c \ |
| 121 | + stm32f4xx_adc.c \ |
| 122 | + stm324x7i_eval.c \ |
| 123 | + stm324x7i_eval_sdio_sd.c \ |
| 124 | + ) |
| 125 | + |
| 126 | +SRC_STMUSB = $(addprefix $(STMUSB_DIR)/,\ |
| 127 | + usb_core.c \ |
| 128 | + usb_bsp.c \ |
| 129 | + usb_dcd.c \ |
| 130 | + usb_dcd_int.c \ |
| 131 | + usb_hcd.c \ |
| 132 | + usb_hcd_int.c \ |
| 133 | + ) |
| 134 | +# usb_otg.c \ |
| 135 | +
|
| 136 | +SRC_STMUSBD = $(addprefix $(STMUSBD_DIR)/,\ |
| 137 | + usbd_core.c \ |
| 138 | + usbd_ioreq.c \ |
| 139 | + usbd_req.c \ |
| 140 | + usbd_usr.c \ |
| 141 | + usbd_desc.c \ |
| 142 | + usbd_pyb_core.c \ |
| 143 | + usbd_pyb_core2.c \ |
| 144 | + usbd_cdc_vcp.c \ |
| 145 | + usbd_msc_bot.c \ |
| 146 | + usbd_msc_data.c \ |
| 147 | + usbd_msc_scsi.c \ |
| 148 | + usbd_storage_msd.c \ |
| 149 | + ) |
| 150 | + |
| 151 | +SRC_STMUSBH = $(addprefix $(STMUSBH_DIR)/,\ |
| 152 | + usbh_core.c \ |
| 153 | + usbh_hcs.c \ |
| 154 | + usbh_stdreq.c \ |
| 155 | + usbh_ioreq.c \ |
| 156 | + usbh_usr.c \ |
| 157 | + usbh_hid_core.c \ |
| 158 | + usbh_hid_mouse.c \ |
| 159 | + usbh_hid_keybd.c \ |
| 160 | + ) |
| 161 | + |
| 162 | +SRC_FATFS = $(addprefix $(FATFS_DIR)/,\ |
| 163 | + ff.c \ |
| 164 | + diskio.c \ |
| 165 | + ccsbcs.c \ |
| 166 | + ) |
| 167 | + |
| 168 | +SRC_CC3K = $(addprefix $(CC3K_DIR)/,\ |
| 169 | + cc3000_common.c \ |
| 170 | + evnt_handler.c \ |
| 171 | + hci.c \ |
| 172 | + netapp.c \ |
| 173 | + nvmem.c \ |
| 174 | + security.c \ |
| 175 | + socket.c \ |
| 176 | + wlan.c \ |
| 177 | + ccspi.c \ |
| 178 | + pybcc3k.c \ |
| 179 | + ) |
| 180 | + |
| 181 | +OBJ = |
| 182 | +#OBJ += $(PY_O) |
| 183 | +OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o)) |
| 184 | +OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o)) |
| 185 | +OBJ += $(addprefix $(BUILD)/, $(SRC_HAL:.c=.o)) |
| 186 | +#OBJ += $(addprefix $(BUILD)/, $(SRC_STMUSB:.c=.o)) |
| 187 | +#OBJ += $(addprefix $(BUILD)/, $(SRC_STMUSBD:.c=.o)) |
| 188 | +#OBJ += $(addprefix $(BUILD)/, $(SRC_STMUSBH:.c=.o)) |
| 189 | +#OBJ += $(addprefix $(BUILD)/, $(SRC_FATFS:.c=.o)) |
| 190 | +#OBJ += $(addprefix $(BUILD)/, $(SRC_CC3K:.c=.o)) |
| 191 | +#OBJ += $(BUILD)/pins_$(BOARD).o |
| 192 | + |
| 193 | +all: $(BUILD)/flash.dfu |
| 194 | + |
| 195 | +$(BUILD)/flash.dfu: $(BUILD)/flash0.bin $(BUILD)/flash1.bin |
| 196 | + $(ECHO) "Create $@" |
| 197 | + $(Q)python $(DFU) -b 0x08000000:$(BUILD)/flash0.bin -b 0x08020000:$(BUILD)/flash1.bin $@ |
| 198 | + |
| 199 | +$(BUILD)/flash0.bin: $(BUILD)/flash.elf |
| 200 | + $(Q)$(OBJCOPY) -O binary -j .isr_vector $^ $@ |
| 201 | + |
| 202 | +$(BUILD)/flash1.bin: $(BUILD)/flash.elf |
| 203 | + $(Q)$(OBJCOPY) -O binary -j .text -j .data $^ $@ |
| 204 | + |
| 205 | +$(BUILD)/flash.elf: $(OBJ) |
| 206 | + $(ECHO) "LINK $@" |
| 207 | + $(Q)$(LD) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) |
| 208 | + $(Q)$(SIZE) $@ |
| 209 | + |
| 210 | +MAKE_PINS = boards/make-pins.py |
| 211 | +BOARD_PINS = boards/$(BOARD)/pins.csv |
| 212 | +AF_FILE = boards/stm32f4xx-af.csv |
| 213 | +PREFIX_FILE = boards/stm32f4xx-prefix.c |
| 214 | +GEN_PINS_SRC = $(BUILD)/pins_$(BOARD).c |
| 215 | +GEN_PINS_HDR = $(BUILD)/pins.h |
| 216 | + |
| 217 | +# Making OBJ use an order-only depenedency on the generated pins.h file |
| 218 | +# has the side effect of making the pins.h file before we actually compile |
| 219 | +# any of the objects. The normal dependency generation will deal with the |
| 220 | +# case when pins.h is modified. But when it doesn't exist, we don't know |
| 221 | +# which source files might need it. |
| 222 | +#$(OBJ): | $(BUILD)/pins.h |
| 223 | + |
| 224 | +# Use a pattern rule here so that make will only call make-pins.py once to make |
| 225 | +# both pins_$(BOARD).c and pins.h |
| 226 | +$(BUILD)/%_$(BOARD).c $(BUILD)/%.h: boards/$(BOARD)/%.csv $(MAKE_PINS) $(AF_FILE) $(PREFIX_FILE) |
| 227 | + $(ECHO) "Create $@" |
| 228 | + $(Q)python $(MAKE_PINS) --board $(BOARD_PINS) --af $(AF_FILE) --prefix $(PREFIX_FILE) --hdr $(GEN_PINS_HDR) > $(GEN_PINS_SRC) |
| 229 | + |
| 230 | +$(BUILD)/pins_$(BOARD).o: $(BUILD)/pins_$(BOARD).c |
| 231 | + $(call compile_c) |
| 232 | + |
| 233 | +include ../py/mkrules.mk |
0 commit comments