summaryrefslogtreecommitdiff
path: root/atmel-samd
diff options
context:
space:
mode:
authorScott Shawcroft <scott.shawcroft@gmail.com>2017-02-25 12:19:33 +0100
committerScott Shawcroft <scott.shawcroft@gmail.com>2017-02-26 01:00:33 +0100
commit062fac1d43d42b35e0ecdaaec124c29b65db7c68 (patch)
treeab2b653796caea6d368ae793e07e5382b0759bab /atmel-samd
parent3fd19c60ccd879ed676bae72d42b709b34eeaa23 (diff)
atmel-samd: Use link time optimization to reduce code size of builds which
share space with the file system. "Express" builds with SPI flash crash the compiler for some reason so its currently disabled for them.
Diffstat (limited to 'atmel-samd')
-rw-r--r--atmel-samd/Makefile6
-rw-r--r--atmel-samd/asf/sam0/utils/cmsis/samd21/source/gcc/startup_samd21.c4
-rw-r--r--atmel-samd/boards/arduino_zero/mpconfigboard.mk2
-rw-r--r--atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk2
-rw-r--r--atmel-samd/boards/feather_m0_basic/mpconfigboard.mk2
-rw-r--r--atmel-samd/boards/gemma_m0/mpconfigboard.mk2
-rw-r--r--atmel-samd/boards/trinket_m0/mpconfigboard.mk2
-rw-r--r--atmel-samd/main.c2
8 files changed, 16 insertions, 6 deletions
diff --git a/atmel-samd/Makefile b/atmel-samd/Makefile
index bb5913fd4..defbf1591 100644
--- a/atmel-samd/Makefile
+++ b/atmel-samd/Makefile
@@ -115,7 +115,7 @@ CFLAGS_CORTEX_M0 = \
-DTC_ASYNC=true \
-DUSB_DEVICE_LPM_SUPPORT \
--param max-inline-insns-single=500
-CFLAGS = $(INC) -Wall -Werror -std=gnu11 -nostdlib $(CFLAGS_CORTEX_M0) $(COPT)
+CFLAGS = $(INC) -Wall -Werror -std=gnu11 -nostdlib $(CFLAGS_CORTEX_M0) $(COPT) $(BOARD_CFLAGS)
#Debugging/Optimization
# TODO(tannewt): Figure out what NDEBUG does. Adding it to the debug build
@@ -139,8 +139,8 @@ CFLAGS += -DMICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool
CFLAGS += -DMICROPY_MODULE_FROZEN_MPY
endif
-LIBM_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-file-name=libm.a)
-LDFLAGS = -mthumb -mcpu=cortex-m0plus -Lasf/thirdparty/CMSIS/Lib/GCC/ -LQTouch/ -L$(dir $(LIBM_FILE_NAME)) -Wl,-nostdlib -Wl,-T,$(LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nano.specs
+#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/ -LQTouch/ -Wl,-nostdlib -Wl,-T,$(LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nano.specs
LIBS = -larm_cortexM0l_math -lsamd21_qtouch_gcc -lm -lgcc -lc
SRC_ASF = $(addprefix asf/sam0/,\
diff --git a/atmel-samd/asf/sam0/utils/cmsis/samd21/source/gcc/startup_samd21.c b/atmel-samd/asf/sam0/utils/cmsis/samd21/source/gcc/startup_samd21.c
index 670fb0d61..8e14b991f 100644
--- a/atmel-samd/asf/sam0/utils/cmsis/samd21/source/gcc/startup_samd21.c
+++ b/atmel-samd/asf/sam0/utils/cmsis/samd21/source/gcc/startup_samd21.c
@@ -127,7 +127,7 @@ void AC1_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler
#endif
/* Exception Table */
-__attribute__ ((section(".vectors")))
+__attribute__ ((used, section(".vectors")))
const DeviceVectors exception_table = {
/* Configure Initial Stack Pointer, using linker-generated symbols */
@@ -229,7 +229,7 @@ const DeviceVectors exception_table = {
* \brief This is the code that gets called on processor reset.
* To initialize the device, and call the main() routine.
*/
-void Reset_Handler(void)
+__attribute__ ((used))void Reset_Handler(void)
{
uint32_t *pSrc, *pDest;
diff --git a/atmel-samd/boards/arduino_zero/mpconfigboard.mk b/atmel-samd/boards/arduino_zero/mpconfigboard.mk
index 9ea93525d..726e4b96d 100644
--- a/atmel-samd/boards/arduino_zero/mpconfigboard.mk
+++ b/atmel-samd/boards/arduino_zero/mpconfigboard.mk
@@ -5,3 +5,5 @@ USB_PID = 0x824D
FLASH_IMPL = internal_flash.c
CHIP_VARIANT = SAMD21G18A
+
+BOARD_CFLAGS = -flto
diff --git a/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk b/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk
index 755157cb7..733d3a0ec 100644
--- a/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk
+++ b/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk
@@ -5,3 +5,5 @@ USB_PID = 0x8015
FLASH_IMPL = internal_flash.c
CHIP_VARIANT = SAMD21G18A
+
+BOARD_CFLAGS = -flto
diff --git a/atmel-samd/boards/feather_m0_basic/mpconfigboard.mk b/atmel-samd/boards/feather_m0_basic/mpconfigboard.mk
index 755157cb7..733d3a0ec 100644
--- a/atmel-samd/boards/feather_m0_basic/mpconfigboard.mk
+++ b/atmel-samd/boards/feather_m0_basic/mpconfigboard.mk
@@ -5,3 +5,5 @@ USB_PID = 0x8015
FLASH_IMPL = internal_flash.c
CHIP_VARIANT = SAMD21G18A
+
+BOARD_CFLAGS = -flto
diff --git a/atmel-samd/boards/gemma_m0/mpconfigboard.mk b/atmel-samd/boards/gemma_m0/mpconfigboard.mk
index 8e1b73208..d0b28a4ea 100644
--- a/atmel-samd/boards/gemma_m0/mpconfigboard.mk
+++ b/atmel-samd/boards/gemma_m0/mpconfigboard.mk
@@ -5,3 +5,5 @@ USB_PID = 0x8015
FLASH_IMPL = internal_flash.c
CHIP_VARIANT = SAMD21E18A
+
+BOARD_CFLAGS = -flto
diff --git a/atmel-samd/boards/trinket_m0/mpconfigboard.mk b/atmel-samd/boards/trinket_m0/mpconfigboard.mk
index 8e1b73208..d0b28a4ea 100644
--- a/atmel-samd/boards/trinket_m0/mpconfigboard.mk
+++ b/atmel-samd/boards/trinket_m0/mpconfigboard.mk
@@ -5,3 +5,5 @@ USB_PID = 0x8015
FLASH_IMPL = internal_flash.c
CHIP_VARIANT = SAMD21E18A
+
+BOARD_CFLAGS = -flto
diff --git a/atmel-samd/main.c b/atmel-samd/main.c
index 17be1123b..44c0e6494 100644
--- a/atmel-samd/main.c
+++ b/atmel-samd/main.c
@@ -500,7 +500,7 @@ void samd21_init(void) {
nvm_set_config(&config_nvm);
}
-int main(int argc, char **argv) {
+int main(void) {
// initialise the cpu and peripherals
samd21_init();