diff options
| author | Dan Halbert <halbert@halwitz.org> | 2017-10-15 14:02:42 -0400 |
|---|---|---|
| committer | Scott Shawcroft <scott@tannewt.org> | 2017-10-16 12:20:33 -0700 |
| commit | dbd3f1516854f8609fe886d83b556b73684fdc6a (patch) | |
| tree | c16dd7b18414ece9961e2ed9c91f075e006a93cd /atmel-samd | |
| parent | 8f3be0a0371d5e73930a155298804c61fd0ad902 (diff) | |
1. Use lib/libm for small (non-Express builds) to gain back a lot of flash space.
2. Add flag INTERNAL_LIBM to mpconfigboard.mk files to signal using lib/libm.
3. Fix floating-point warnings in lib/libm
4. Turn off -finline-limit, no longer needed due to 1.
5. Add explicit flags for SPI_FLASH_FILESYSTEM and INTERNAL_FLASH_FILESYSTEM
to mpconfigboard.mk files, so they don't need to know the name of the .c file
that implements those. Makefile takes care of checking the flags and including
the right files.
Diffstat (limited to 'atmel-samd')
| -rw-r--r-- | atmel-samd/Makefile | 50 | ||||
| -rw-r--r-- | atmel-samd/boards/arduino_zero/mpconfigboard.mk | 3 | ||||
| -rw-r--r-- | atmel-samd/boards/circuitplayground_express/mpconfigboard.mk | 2 | ||||
| -rw-r--r-- | atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk | 3 | ||||
| -rw-r--r-- | atmel-samd/boards/feather_m0_basic/mpconfigboard.mk | 3 | ||||
| -rw-r--r-- | atmel-samd/boards/feather_m0_express/mpconfigboard.mk | 2 | ||||
| -rw-r--r-- | atmel-samd/boards/gemma_m0/mpconfigboard.mk | 3 | ||||
| -rw-r--r-- | atmel-samd/boards/metro_m0_express/mpconfigboard.mk | 2 | ||||
| -rw-r--r-- | atmel-samd/boards/trinket_m0/mpconfigboard.mk | 3 | ||||
| -rw-r--r-- | atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.mk | 2 | ||||
| -rw-r--r-- | atmel-samd/mpconfigport.h | 2 |
11 files changed, 62 insertions, 13 deletions
diff --git a/atmel-samd/Makefile b/atmel-samd/Makefile index 3bbe91ea9..4a45106db 100644 --- a/atmel-samd/Makefile +++ b/atmel-samd/Makefile @@ -135,11 +135,12 @@ ifeq ($(DEBUG), 1) # -DMICROPY_DEBUG_MODULES may also be added to an -flto build, if you wish. CFLAGS += -Os -ggdb -DNDEBUG -DENABLE_MICRO_TRACE_BUFFER -DMICROPY_DEBUG_MODULES else -# GCC_INLINE_LIMIT specifies -finline-limit, which can shrink the image size. +# -finline-limit can shrink the image size. # -finline-limit=80 or so is similar to not having it on. # There is no simple default value, though. -ifeq ($(FLASH_IMPL),internal_flash.c) -GCC_INLINE_LIMIT = -finline-limit=19 +ifdef INTERNAL_FLASH_FILESYSTEM + ## Not currently needed + ## CFLAGS += -finline-limit=50 endif CFLAGS += -Os -DNDEBUG -flto $(GCC_INLINE_LIMIT) endif @@ -161,10 +162,14 @@ CFLAGS += -DMICROPY_MODULE_FROZEN_MPY CFLAGS += -Wno-error=lto-type-mismatch endif -#LIBM_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-file-name=libm.a) LDFLAGS = $(CFLAGS) -nostartfiles -fshort-enums -mthumb -mcpu=cortex-m0plus -Lasf/thirdparty/CMSIS/Lib/GCC/ -Wl,-nostdlib -Wl,-T,$(LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nano.specs LIBS = -larm_cortexM0l_math -lm -lgcc -lc +# Use toolchain libm if we're not using our own. +ifndef INTERNAL_LIBM +LIBS += -lm +endif + SRC_ASF = $(addprefix asf/sam0/,\ drivers/adc/adc_sam_d_r/adc.c \ drivers/dac/dac_sam_d_c/dac.c \ @@ -237,6 +242,16 @@ SRC_C = \ lib/libc/string0.c \ lib/mp-readline/readline.c +# Choose which flash filesystem impl to use. +# (Right now INTERNAL_FLASH_FILESYSTEM and SPI_FLASH_FILESYSTEM are mutually exclusive. +# But that might not be true in the future.) +ifdef INTERNAL_FLASH_FILESYSTEM +SRC_C += internal_flash.c +endif +ifdef SPI_FLASH_FILESYSTEM +SRC_C += spi_flash.c +endif + SRC_COMMON_HAL = \ analogio/__init__.c \ analogio/AnalogIn.c \ @@ -270,6 +285,30 @@ SRC_COMMON_HAL = \ usb_hid/__init__.c \ usb_hid/Device.c +ifdef INTERNAL_LIBM +SRC_LIBM = $(addprefix lib/,\ + libm/math.c \ + libm/fmodf.c \ + libm/nearbyintf.c \ + libm/ef_sqrt.c \ + libm/kf_rem_pio2.c \ + libm/kf_sin.c \ + libm/kf_cos.c \ + libm/kf_tan.c \ + libm/ef_rem_pio2.c \ + libm/sf_sin.c \ + libm/sf_cos.c \ + libm/sf_tan.c \ + libm/sf_frexp.c \ + libm/sf_modf.c \ + libm/sf_ldexp.c \ + libm/asinfacosf.c \ + libm/atanf.c \ + libm/atan2f.c \ + ) +endif + + # These don't have corresponding files in each port but are still located in # shared-bindings to make it clear what the contents of the modules are. SRC_BINDINGS_ENUMS = \ @@ -304,6 +343,9 @@ OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o)) OBJ += $(addprefix $(BUILD)/, $(SRC_ASF:.c=.o)) OBJ += $(addprefix $(BUILD)/, $(SRC_COMMON_HAL_EXPANDED:.c=.o)) OBJ += $(addprefix $(BUILD)/, $(SRC_SHARED_MODULE_EXPANDED:.c=.o)) +ifdef INTERNAL_LIBM +OBJ += $(addprefix $(BUILD)/, $(SRC_LIBM:.c=.o)) +endif SRC_QSTR += $(SRC_C) $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED) $(STM_SRC_C) diff --git a/atmel-samd/boards/arduino_zero/mpconfigboard.mk b/atmel-samd/boards/arduino_zero/mpconfigboard.mk index 9ea93525d..085619800 100644 --- a/atmel-samd/boards/arduino_zero/mpconfigboard.mk +++ b/atmel-samd/boards/arduino_zero/mpconfigboard.mk @@ -2,6 +2,7 @@ LD_FILE = boards/samd21x18-bootloader.ld USB_VID = 0x2341 USB_PID = 0x824D -FLASH_IMPL = internal_flash.c +INTERNAL_FLASH_FILESYSTEM = 1 +INTERNAL_LIBM = 1 CHIP_VARIANT = SAMD21G18A diff --git a/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk b/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk index e8195c90d..9a6157ee7 100644 --- a/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk +++ b/atmel-samd/boards/circuitplayground_express/mpconfigboard.mk @@ -2,7 +2,7 @@ LD_FILE = boards/samd21x18-bootloader-external-flash-crystalless.ld USB_VID = 0x239A USB_PID = 0x8019 -FLASH_IMPL = spi_flash.c +SPI_FLASH_FILESYSTEM = 1 CHIP_VARIANT = SAMD21G18A diff --git a/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk b/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk index 755157cb7..e77a546a9 100644 --- a/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk +++ b/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk @@ -2,6 +2,7 @@ LD_FILE = boards/samd21x18-bootloader.ld USB_VID = 0x239A USB_PID = 0x8015 -FLASH_IMPL = internal_flash.c +INTERNAL_FLASH_FILESYSTEM = 1 +INTERNAL_LIBM = 1 CHIP_VARIANT = SAMD21G18A diff --git a/atmel-samd/boards/feather_m0_basic/mpconfigboard.mk b/atmel-samd/boards/feather_m0_basic/mpconfigboard.mk index c6c64f4a2..247348c97 100644 --- a/atmel-samd/boards/feather_m0_basic/mpconfigboard.mk +++ b/atmel-samd/boards/feather_m0_basic/mpconfigboard.mk @@ -2,7 +2,8 @@ LD_FILE = boards/samd21x18-bootloader.ld USB_VID = 0x239A USB_PID = 0x8015 -FLASH_IMPL = internal_flash.c +INTERNAL_FLASH_FILESYSTEM = 1 +INTERNAL_LIBM = 1 CHIP_VARIANT = SAMD21G18A diff --git a/atmel-samd/boards/feather_m0_express/mpconfigboard.mk b/atmel-samd/boards/feather_m0_express/mpconfigboard.mk index bf8bd54f2..a855521eb 100644 --- a/atmel-samd/boards/feather_m0_express/mpconfigboard.mk +++ b/atmel-samd/boards/feather_m0_express/mpconfigboard.mk @@ -2,6 +2,6 @@ LD_FILE = boards/samd21x18-bootloader-external-flash.ld USB_VID = 0x239A USB_PID = 0x801b -FLASH_IMPL = spi_flash.c +SPI_FLASH_FILESYTEM = 1 CHIP_VARIANT = SAMD21G18A diff --git a/atmel-samd/boards/gemma_m0/mpconfigboard.mk b/atmel-samd/boards/gemma_m0/mpconfigboard.mk index 87a5e93c1..f3a308e48 100644 --- a/atmel-samd/boards/gemma_m0/mpconfigboard.mk +++ b/atmel-samd/boards/gemma_m0/mpconfigboard.mk @@ -2,6 +2,7 @@ LD_FILE = boards/samd21x18-bootloader.ld USB_VID = 0x239A USB_PID = 0x801D -FLASH_IMPL = internal_flash.c +INTERNAL_FLASH_FILESYSTEM = 1 +INTERNAL_LIBM = 1 CHIP_VARIANT = SAMD21E18A diff --git a/atmel-samd/boards/metro_m0_express/mpconfigboard.mk b/atmel-samd/boards/metro_m0_express/mpconfigboard.mk index 436e56a60..c3720a244 100644 --- a/atmel-samd/boards/metro_m0_express/mpconfigboard.mk +++ b/atmel-samd/boards/metro_m0_express/mpconfigboard.mk @@ -2,6 +2,6 @@ LD_FILE = boards/samd21x18-bootloader-external-flash.ld USB_VID = 0x239A USB_PID = 0x8014 -FLASH_IMPL = spi_flash.c +SPI_FLASH_FILESYSTEM = 1 CHIP_VARIANT = SAMD21G18A diff --git a/atmel-samd/boards/trinket_m0/mpconfigboard.mk b/atmel-samd/boards/trinket_m0/mpconfigboard.mk index 4d2268c13..bf96af3a7 100644 --- a/atmel-samd/boards/trinket_m0/mpconfigboard.mk +++ b/atmel-samd/boards/trinket_m0/mpconfigboard.mk @@ -2,6 +2,7 @@ LD_FILE = boards/samd21x18-bootloader.ld USB_VID = 0x239A USB_PID = 0x801F -FLASH_IMPL = internal_flash.c +INTERNAL_FLASH_FILESYSTEM = 1 +INTERNAL_LIBM = 1 CHIP_VARIANT = SAMD21E18A diff --git a/atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.mk b/atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.mk index cfa924b60..788985cac 100644 --- a/atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.mk +++ b/atmel-samd/boards/trinket_m0_haxpress/mpconfigboard.mk @@ -2,7 +2,7 @@ LD_FILE = boards/samd21x18-bootloader-external-flash-crystalless.ld USB_VID = 0x239A USB_PID = 0x801F -FLASH_IMPL = spi_flash.c +SPI_FLASH_FILESYSTEM = 1 CHIP_VARIANT = SAMD21E18A CHIP_FAMILY = samd21 diff --git a/atmel-samd/mpconfigport.h b/atmel-samd/mpconfigport.h index fc061d1cb..3a79d3394 100644 --- a/atmel-samd/mpconfigport.h +++ b/atmel-samd/mpconfigport.h @@ -189,6 +189,8 @@ extern const struct _mp_obj_module_t usb_hid_module; #define MICROPY_PY_FRAMEBUF (0) #define EXTRA_BUILTIN_MODULES + #define MICROPY_PY_BUILTINS_COMPLEX (0) + #define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (0) #define MICROPY_CPYTHON_COMPAT (0) #endif |
