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,32 @@ 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/interrupt_char.c \
155+ lib/utils/pyexec.c \
156+ lib/libc/string0.c \
157+ lib/mp-readline/readline.c \
158+ internal_flash.c \
159+
150160
151161DRIVERS_SRC_C += $(addprefix modules/,\
152162 machine/modmachine.c \
@@ -156,11 +166,9 @@ DRIVERS_SRC_C += $(addprefix modules/,\
156166 machine/adc.c \
157167 machine/pin.c \
158168 machine/timer.c \
159- machine/rtc.c \
160169 machine/pwm.c \
161170 machine/led.c \
162171 machine/temp.c \
163- uos/moduos.c \
164172 utime/modutime.c \
165173 pyb/modpyb.c \
166174 ubluepy/modubluepy.c \
@@ -179,18 +187,72 @@ DRIVERS_SRC_C += $(addprefix modules/,\
179187 random/modrandom.c \
180188 )
181189
182- SRC_C += \
183- device/$(MCU_VARIANT ) /system_$(MCU_SUB_VARIANT ) .c \
184- device/$(MCU_VARIANT ) /startup_$(MCU_SUB_VARIANT ) .c \
190+
191+ SRC_COMMON_HAL += \
192+ board/__init__.c \
193+ digitalio/__init__.c \
194+ digitalio/DigitalInOut.c \
195+ microcontroller/__init__.c \
196+ microcontroller/Pin.c \
197+ microcontroller/Processor.c \
198+ os/__init__.c \
199+ time/__init__.c \
200+ analogio/__init__.c \
201+ analogio/AnalogIn.c \
202+ analogio/AnalogOut.c \
203+ busio/__init__.c\
204+ busio/I2C.c \
205+ busio/SPI.c \
206+ pulseio/__init__.c \
207+ pulseio/PulseIn.c \
208+ pulseio/PulseOut.c \
209+ pulseio/PWMOut.c \
210+ storage/__init__.c \
211+
212+ # These don't have corresponding files in each port but are still located in
213+ # shared-bindings to make it clear what the contents of the modules are.
214+ SRC_BINDINGS_ENUMS = \
215+ digitalio/Direction.c \
216+ digitalio/DriveMode.c \
217+ digitalio/Pull.c \
218+ help.c \
219+ math/__init__.c \
220+ supervisor/__init__.c \
221+ util.c
222+
223+ SRC_COMMON_HAL_EXPANDED = $(addprefix shared-bindings/, $(SRC_COMMON_HAL ) ) \
224+ $(addprefix shared-bindings/, $(SRC_BINDINGS_ENUMS ) ) \
225+ $(addprefix common-hal/, $(SRC_COMMON_HAL ) )
226+
227+ SRC_SHARED_MODULE = \
228+ os/__init__.c \
229+ random/__init__.c \
230+ storage/__init__.c \
231+
232+ # bitbangio/__init__.c \
233+ bitbangio/I2C.c \
234+ bitbangio/OneWire.c \
235+ bitbangio/SPI.c \
236+ busio/OneWire.c \
237+ gamepad/__init__.c \
238+ gamepad/GamePad.c \
239+ struct/__init__.c \
240+ uheap/__init__.c \
241+ ustack/__init__.c
242+
243+ # SRC_SHARED_MODULE_EXPANDED = $(addprefix shared-bindings/, $(SRC_SHARED_MODULE)) \
244+ $(addprefix shared-module/, $(SRC_SHARED_MODULE))
245+
246+ SRC_SHARED_MODULE_EXPANDED = $(addprefix shared-module/, $(SRC_SHARED_MODULE ) )
185247
186248FROZEN_MPY_PY_FILES := $(shell find -L $(FROZEN_MPY_DIR ) -type f -name '* .py')
187249FROZEN_MPY_MPY_FILES := $(addprefix $(BUILD ) /,$(FROZEN_MPY_PY_FILES:.py=.mpy ) )
188250
189- OBJ += $(PY_O ) $(addprefix $(BUILD ) /, $(SRC_C:.c=.o ) )
190- OBJ += $(addprefix $(BUILD ) /, $(SRC_LIB:.c=.o ) )
251+ OBJ += $(PY_O ) $(SUPERVISOR_O ) $(addprefix $(BUILD ) /, $(SRC_C:.c=.o ) )
191252OBJ += $(addprefix $(BUILD ) /, $(SRC_HAL:.c=.o ) )
192253OBJ += $(addprefix $(BUILD ) /, $(DRIVERS_SRC_C:.c=.o ) )
193- OBJ += $(BUILD ) /pins_gen.o
254+ OBJ += $(addprefix $(BUILD ) /, $(SRC_COMMON_HAL_EXPANDED:.c=.o ) )
255+ OBJ += $(addprefix $(BUILD ) /, $(SRC_SHARED_MODULE_EXPANDED:.c=.o ) )
194256
195257$(BUILD ) /$(FATFS_DIR ) /ff.o : COPT += -Os
196258$(filter $(PY_BUILD ) /../extmod/vfs_fat_% .o, $(PY_O ) ) : COPT += -Os
@@ -241,11 +303,11 @@ endif
241303
242304$(BUILD ) /$(OUTPUT_FILENAME ) .elf : $(OBJ )
243305 $(ECHO ) " LINK $@ "
244- $(Q )$(CC ) $(LDFLAGS ) -o $@ $(OBJ ) $(LIBS )
306+ $(Q )$(CC ) $(LDFLAGS ) -o $@ $(OBJ ) -Wl,--start-group $(LIBS ) -Wl,--end-group
245307 $(Q )$(SIZE ) $@
246308
247309# List of sources for qstr extraction
248- SRC_QSTR += $(SRC_C ) $(SRC_MOD ) $(SRC_LIB ) $(DRIVERS_SRC_C )
310+ SRC_QSTR += $(SRC_C ) $(SRC_SUPERVISOR ) $(SRC_MOD ) $(DRIVERS_SRC_C ) $( SRC_COMMON_HAL_EXPANDED ) $( SRC_SHARED_MODULE_EXPANDED )
249311
250312# Append any auto-generated sources that are needed by sources listed in
251313# SRC_QSTR
@@ -256,16 +318,16 @@ SRC_QSTR_AUTO_DEPS +=
256318# any of the objects. The normal dependency generation will deal with the
257319# case when pins.h is modified. But when it doesn't exist, we don't know
258320# which source files might need it.
259- $(OBJ ) : | $(HEADER_BUILD ) /pins.h
321+ # $(OBJ): | $(HEADER_BUILD)/pins.h
260322
261323# Use a pattern rule here so that make will only call make-pins.py once to make
262324# 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 )
325+ # $(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)
326+ # $(ECHO) "Create $@"
327+ # $(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)
266328
267- $(BUILD ) /pins_gen.o : $(BUILD ) /pins_gen.c
268- $(call compile_c)
329+ # $(BUILD)/pins_gen.o: $(BUILD)/pins_gen.c
330+ # $(call compile_c)
269331
270332MAKE_PINS = boards/make-pins.py
271333BOARD_PINS = boards/$(BOARD ) /pins.csv
@@ -290,4 +352,4 @@ CFLAGS += -DMICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool
290352CFLAGS += -DMICROPY_MODULE_FROZEN_MPY
291353endif
292354
293- include ../.. /py/mkrules.mk
355+ include $( TOP ) /py/mkrules.mk
0 commit comments