11# Select the board to build for: if not given on the command line,
2- # then default to pca10040 .
3- BOARD ?= pca10040
2+ # then default to feather52 .
3+ BOARD ?= feather52
44ifeq ($(wildcard boards/$(BOARD ) /.) ,)
55$(error Invalid BOARD specified)
66endif
@@ -11,33 +11,38 @@ SD_LOWER = $(shell echo $(SD) | tr '[:upper:]' '[:lower:]')
1111
1212# TODO: Verify that it is a valid target.
1313
14-
1514ifeq ($(SD ) , )
1615 # If the build directory is not given, make it reflect the board name.
1716 BUILD ?= build-$(BOARD)
1817 include ../../py/mkenv.mk
1918 include boards/$(BOARD)/mpconfigboard.mk
19+ -include mpconfigport.mk
20+
21+ INC += -Idrivers/bluetooth/s132_$(MCU_VARIANT ) _$(SOFTDEV_VERSION ) /s132_$(MCU_VARIANT ) _$(SOFTDEV_VERSION ) _API/include
22+ INC += -Idrivers/bluetooth/s132_$(MCU_VARIANT ) _$(SOFTDEV_VERSION ) /s132_$(MCU_VARIANT ) _$(SOFTDEV_VERSION ) _API/include/$(MCU_VARIANT )
23+
2024else
2125 # If the build directory is not given, make it reflect the board name.
2226 BUILD ?= build-$(BOARD)-$(SD_LOWER)
2327 include ../../py/mkenv.mk
2428 include boards/$(BOARD)/mpconfigboard_$(SD_LOWER).mk
29+ -include mpconfigport.mk
2530
2631 include drivers/bluetooth/bluetooth_common.mk
2732endif
2833
34+
2935# qstr definitions (must come before including py.mk)
30- QSTR_DEFS = qstrdefsport.h $( BUILD ) /pins_qstr.h
36+ QSTR_DEFS = qstrdefsport.h
3137
3238FROZEN_MPY_DIR = freeze
3339
3440# include py core make definitions
3541include ../../py/py.mk
3642
43+ include $(TOP ) /supervisor/supervisor.mk
3744
3845FATFS_DIR = lib/oofatfs
39- MPY_CROSS = ../../mpy-cross/mpy-cross
40- MPY_TOOL = ../../tools/mpy-tool.py
4146
4247CROSS_COMPILE = arm-none-eabi-
4348
@@ -105,22 +110,12 @@ LIBS += -L $(dir $(LIBC_FILE_NAME)) -lc
105110LIBS += -L $(dir $(LIBGCC_FILE_NAME ) ) -lgcc
106111endif
107112
108- SRC_LIB = $(addprefix lib/,\
109- libc/string0.c \
110- mp-readline/readline.c \
111- utils/pyexec.c \
112- timeutils/timeutils.c \
113- oofatfs/ff.c \
114- oofatfs/option/unicode.c \
115- )
116-
117113SRC_HAL = $(addprefix hal/,\
118114 hal_uart.c \
119115 hal_uarte.c \
120116 hal_spi.c \
121117 hal_spie.c \
122118 hal_time.c \
123- hal_rtc.c \
124119 hal_timer.c \
125120 hal_twi.c \
126121 hal_adc.c \
@@ -136,17 +131,31 @@ SRC_HAL += $(addprefix hal/,\
136131 )
137132endif
138133
134+
139135SRC_C += \
140- main.c \
141136 mphalport.c \
142137 help.c \
143- gccollect.c \
144138 pin_named_pins.c \
145139 fatfs_port.c \
140+ fifo.c \
146141 drivers/softpwm.c \
147142 drivers/ticker.c \
148143 drivers/bluetooth/ble_drv.c \
149144 drivers/bluetooth/ble_uart.c \
145+ boards/$(BOARD ) /board.c \
146+ boards/$(BOARD ) /pins.c \
147+ device/$(MCU_VARIANT ) /system_$(MCU_SUB_VARIANT ) .c \
148+ device/$(MCU_VARIANT ) /startup_$(MCU_SUB_VARIANT ) .c \
149+ lib/oofatfs/ff.c \
150+ lib/oofatfs/option/ccsbcs.c \
151+ lib/timeutils/timeutils.c \
152+ lib/utils/buffer_helper.c \
153+ lib/utils/context_manager_helpers.c \
154+ lib/utils/pyexec.c \
155+ lib/libc/string0.c \
156+ lib/mp-readline/readline.c \
157+ internal_flash.c \
158+
150159
151160DRIVERS_SRC_C += $(addprefix modules/,\
152161 machine/modmachine.c \
@@ -156,11 +165,9 @@ DRIVERS_SRC_C += $(addprefix modules/,\
156165 machine/adc.c \
157166 machine/pin.c \
158167 machine/timer.c \
159- machine/rtc.c \
160168 machine/pwm.c \
161169 machine/led.c \
162170 machine/temp.c \
163- uos/moduos.c \
164171 utime/modutime.c \
165172 pyb/modpyb.c \
166173 ubluepy/modubluepy.c \
@@ -179,18 +186,72 @@ DRIVERS_SRC_C += $(addprefix modules/,\
179186 random/modrandom.c \
180187 )
181188
182- SRC_C += \
183- device/$(MCU_VARIANT ) /system_$(MCU_SUB_VARIANT ) .c \
184- device/$(MCU_VARIANT ) /startup_$(MCU_SUB_VARIANT ) .c \
189+
190+ SRC_COMMON_HAL += \
191+ board/__init__.c \
192+ digitalio/__init__.c \
193+ digitalio/DigitalInOut.c \
194+ microcontroller/__init__.c \
195+ microcontroller/Pin.c \
196+ microcontroller/Processor.c \
197+ os/__init__.c \
198+ time/__init__.c \
199+ analogio/__init__.c \
200+ analogio/AnalogIn.c \
201+ analogio/AnalogOut.c \
202+ busio/__init__.c\
203+ busio/I2C.c \
204+ busio/SPI.c \
205+ pulseio/__init__.c \
206+ pulseio/PulseIn.c \
207+ pulseio/PulseOut.c \
208+ pulseio/PWMOut.c \
209+ storage/__init__.c \
210+
211+ # These don't have corresponding files in each port but are still located in
212+ # shared-bindings to make it clear what the contents of the modules are.
213+ SRC_BINDINGS_ENUMS = \
214+ digitalio/Direction.c \
215+ digitalio/DriveMode.c \
216+ digitalio/Pull.c \
217+ help.c \
218+ math/__init__.c \
219+ supervisor/__init__.c \
220+ util.c
221+
222+ SRC_COMMON_HAL_EXPANDED = $(addprefix shared-bindings/, $(SRC_COMMON_HAL ) ) \
223+ $(addprefix shared-bindings/, $(SRC_BINDINGS_ENUMS ) ) \
224+ $(addprefix common-hal/, $(SRC_COMMON_HAL ) )
225+
226+ SRC_SHARED_MODULE = \
227+ os/__init__.c \
228+ random/__init__.c \
229+ storage/__init__.c \
230+
231+ # bitbangio/__init__.c \
232+ bitbangio/I2C.c \
233+ bitbangio/OneWire.c \
234+ bitbangio/SPI.c \
235+ busio/OneWire.c \
236+ gamepad/__init__.c \
237+ gamepad/GamePad.c \
238+ struct/__init__.c \
239+ uheap/__init__.c \
240+ ustack/__init__.c
241+
242+ # SRC_SHARED_MODULE_EXPANDED = $(addprefix shared-bindings/, $(SRC_SHARED_MODULE)) \
243+ $(addprefix shared-module/, $(SRC_SHARED_MODULE))
244+
245+ SRC_SHARED_MODULE_EXPANDED = $(addprefix shared-module/, $(SRC_SHARED_MODULE ) )
185246
186247FROZEN_MPY_PY_FILES := $(shell find -L $(FROZEN_MPY_DIR ) -type f -name '* .py')
187248FROZEN_MPY_MPY_FILES := $(addprefix $(BUILD ) /,$(FROZEN_MPY_PY_FILES:.py=.mpy ) )
188249
189- OBJ += $(PY_O ) $(addprefix $(BUILD ) /, $(SRC_C:.c=.o ) )
190- OBJ += $(addprefix $(BUILD ) /, $(SRC_LIB:.c=.o ) )
250+ OBJ += $(PY_O ) $(SUPERVISOR_O ) $(addprefix $(BUILD ) /, $(SRC_C:.c=.o ) )
191251OBJ += $(addprefix $(BUILD ) /, $(SRC_HAL:.c=.o ) )
192252OBJ += $(addprefix $(BUILD ) /, $(DRIVERS_SRC_C:.c=.o ) )
193- OBJ += $(BUILD ) /pins_gen.o
253+ OBJ += $(addprefix $(BUILD ) /, $(SRC_COMMON_HAL_EXPANDED:.c=.o ) )
254+ OBJ += $(addprefix $(BUILD ) /, $(SRC_SHARED_MODULE_EXPANDED:.c=.o ) )
194255
195256$(BUILD ) /$(FATFS_DIR ) /ff.o : COPT += -Os
196257$(filter $(PY_BUILD ) /../extmod/vfs_fat_% .o, $(PY_O ) ) : COPT += -Os
@@ -241,11 +302,11 @@ endif
241302
242303$(BUILD ) /$(OUTPUT_FILENAME ) .elf : $(OBJ )
243304 $(ECHO ) " LINK $@ "
244- $(Q )$(CC ) $(LDFLAGS ) -o $@ $(OBJ ) $(LIBS )
305+ $(Q )$(CC ) $(LDFLAGS ) -o $@ $(OBJ ) -Wl,--start-group $(LIBS ) -Wl,--end-group
245306 $(Q )$(SIZE ) $@
246307
247308# List of sources for qstr extraction
248- SRC_QSTR += $(SRC_C ) $(SRC_MOD ) $(SRC_LIB ) $(DRIVERS_SRC_C )
309+ SRC_QSTR += $(SRC_C ) $(SRC_SUPERVISOR ) $(SRC_MOD ) $(DRIVERS_SRC_C ) $( SRC_COMMON_HAL_EXPANDED ) $( SRC_SHARED_MODULE_EXPANDED )
249310
250311# Append any auto-generated sources that are needed by sources listed in
251312# SRC_QSTR
@@ -256,16 +317,16 @@ SRC_QSTR_AUTO_DEPS +=
256317# any of the objects. The normal dependency generation will deal with the
257318# case when pins.h is modified. But when it doesn't exist, we don't know
258319# which source files might need it.
259- $(OBJ ) : | $(HEADER_BUILD ) /pins.h
320+ # $(OBJ): | $(HEADER_BUILD)/pins.h
260321
261322# Use a pattern rule here so that make will only call make-pins.py once to make
262323# both pins_$(BOARD).c and pins.h
263- $(BUILD ) /% _$(BOARD ) .c $(HEADER_BUILD ) /% .h $(HEADER_BUILD ) /% _af_const.h $(BUILD ) /% _qstr.h : boards/$(BOARD ) /% .csv $(MAKE_PINS ) $(AF_FILE ) $(PREFIX_FILE ) | $(HEADER_BUILD )
264- $(ECHO ) " Create $@ "
265- $(Q )$(PYTHON ) $(MAKE_PINS ) --board $(BOARD_PINS ) --af $(AF_FILE ) --prefix $(PREFIX_FILE ) --hdr $(GEN_PINS_HDR ) --qstr $(GEN_PINS_QSTR ) --af-const $(GEN_PINS_AF_CONST ) --af-py $(GEN_PINS_AF_PY ) > $(GEN_PINS_SRC )
324+ # $(BUILD)/%_$(BOARD).c $(HEADER_BUILD)/%.h $(HEADER_BUILD)/%_af_const.h $(BUILD)/%_qstr.h: boards/$(BOARD)/%.csv $(MAKE_PINS) $(AF_FILE) $(PREFIX_FILE) | $(HEADER_BUILD)
325+ # $(ECHO) "Create $@"
326+ # $(Q)$(PYTHON) $(MAKE_PINS) --board $(BOARD_PINS) --af $(AF_FILE) --prefix $(PREFIX_FILE) --hdr $(GEN_PINS_HDR) --qstr $(GEN_PINS_QSTR) --af-const $(GEN_PINS_AF_CONST) --af-py $(GEN_PINS_AF_PY) > $(GEN_PINS_SRC)
266327
267- $(BUILD ) /pins_gen.o : $(BUILD ) /pins_gen.c
268- $(call compile_c)
328+ # $(BUILD)/pins_gen.o: $(BUILD)/pins_gen.c
329+ # $(call compile_c)
269330
270331MAKE_PINS = boards/make-pins.py
271332BOARD_PINS = boards/$(BOARD ) /pins.csv
@@ -290,4 +351,4 @@ CFLAGS += -DMICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool
290351CFLAGS += -DMICROPY_MODULE_FROZEN_MPY
291352endif
292353
293- include ../.. /py/mkrules.mk
354+ include $( TOP ) /py/mkrules.mk
0 commit comments