@@ -101,11 +101,9 @@ else
101101 # -finline-limit can shrink the image size.
102102 # -finline-limit=80 or so is similar to not having it on.
103103 # There is no simple default value, though.
104- ifeq ($(FLASH_IMPL),internal_flash.c)
105- ifeq ($(CHIP_FAMILY), samd21)
106- # ## TODO(dhalbert): disable for now; breaks things in 3.0.0 build(e.g. deinit checking is disabled)
107- # CFLAGS += -finline-limit=19
108- endif
104+ ifdef INTERNAL_FLASH_FILESYSTEM
105+ # # Not currently needed
106+ # # CFLAGS += -finline-limit=50
109107 endif
110108 CFLAGS += -flto
111109endif
@@ -151,18 +149,19 @@ CFLAGS += -DMICROPY_MODULE_FROZEN_MPY
151149CFLAGS += -Wno-error=lto-type-mismatch
152150endif
153151
154- # LIBM_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-file-name=libm.a)
155152LDFLAGS = $(CFLAGS ) -nostartfiles -fshort-enums -Wl,-nostdlib -Wl,-T,$(LD_FILE ) -Wl,-Map=$@ .map -Wl,-cref -Wl,-gc-sections -specs=nano.specs
156153LIBS := -lgcc -lc
157154
155+ # Use toolchain libm if we're not using our own.
156+ ifndef INTERNAL_LIBM
157+ LIBS += -lm
158+ endif
158159
159160ifeq ($(CHIP_FAMILY ) , samd21)
160161LDFLAGS += -mthumb -mcpu=cortex-m0plus -Lasf/thirdparty/CMSIS/Lib/GCC/
161- LIBS := -lm $(LIBS ) # -larm_cortexM0l_math
162162BOOTLOADER_SIZE := 0x2000
163163else ifeq ($(CHIP_FAMILY), samd51)
164164LDFLAGS += -mthumb -mcpu=cortex-m4
165- LIBS := -lm $(LIBS )
166165BOOTLOADER_SIZE := 0x4000
167166endif
168167
@@ -220,7 +219,6 @@ SRC_C = \
220219 tick.c \
221220 usb.c \
222221 usb_mass_storage.c \
223- $(FLASH_IMPL ) \
224222 bindings/samd/__init__.c \
225223 boards/$(BOARD ) /board.c \
226224 boards/$(BOARD ) /pins.c \
@@ -235,7 +233,17 @@ SRC_C = \
235233 lib/utils/sys_stdio_mphal.c \
236234 lib/libc/string0.c \
237235 lib/mp-readline/readline.c \
238- # freetouch/adafruit_ptc.c \
236+ # freetouch/adafruit_ptc.c
237+
238+ # Choose which flash filesystem impl to use.
239+ # (Right now INTERNAL_FLASH_FILESYSTEM and SPI_FLASH_FILESYSTEM are mutually exclusive.
240+ # But that might not be true in the future.)
241+ ifdef INTERNAL_FLASH_FILESYSTEM
242+ SRC_C += internal_flash.c
243+ endif
244+ ifdef SPI_FLASH_FILESYSTEM
245+ SRC_C += spi_flash.c
246+ endif
239247
240248SRC_COMMON_HAL = \
241249 board/__init__.c \
@@ -270,6 +278,30 @@ SRC_COMMON_HAL = \
270278 usb_hid/__init__.c \
271279 usb_hid/Device.c
272280
281+ ifdef INTERNAL_LIBM
282+ SRC_LIBM = $(addprefix lib/,\
283+ libm/math.c \
284+ libm/fmodf.c \
285+ libm/nearbyintf.c \
286+ libm/ef_sqrt.c \
287+ libm/kf_rem_pio2.c \
288+ libm/kf_sin.c \
289+ libm/kf_cos.c \
290+ libm/kf_tan.c \
291+ libm/ef_rem_pio2.c \
292+ libm/sf_sin.c \
293+ libm/sf_cos.c \
294+ libm/sf_tan.c \
295+ libm/sf_frexp.c \
296+ libm/sf_modf.c \
297+ libm/sf_ldexp.c \
298+ libm/asinfacosf.c \
299+ libm/atanf.c \
300+ libm/atan2f.c \
301+ )
302+ endif
303+
304+
273305# These don't have corresponding files in each port but are still located in
274306# shared-bindings to make it clear what the contents of the modules are.
275307SRC_BINDINGS_ENUMS = \
@@ -306,6 +338,9 @@ OBJ = $(PY_O) $(SUPERVISOR_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
306338OBJ += $(addprefix $(BUILD ) /, $(SRC_ASF:.c=.o ) )
307339OBJ += $(addprefix $(BUILD ) /, $(SRC_COMMON_HAL_EXPANDED:.c=.o ) )
308340OBJ += $(addprefix $(BUILD ) /, $(SRC_SHARED_MODULE_EXPANDED:.c=.o ) )
341+ ifdef INTERNAL_LIBM
342+ OBJ += $(addprefix $(BUILD ) /, $(SRC_LIBM:.c=.o ) )
343+ endif
309344
310345SRC_QSTR += $(SRC_C ) $(SRC_SUPERVISOR ) $(SRC_COMMON_HAL_EXPANDED ) $(SRC_SHARED_MODULE_EXPANDED ) $(STM_SRC_C )
311346
0 commit comments