summaryrefslogtreecommitdiff
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
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.
-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
-rw-r--r--py/objnamedtuple.c6
-rw-r--r--py/objnamedtuple.h7
-rw-r--r--py/objtuple.h10
-rw-r--r--shared-bindings/time/__init__.c2
12 files changed, 37 insertions, 10 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();
diff --git a/py/objnamedtuple.c b/py/objnamedtuple.c
index 19fd3c5db..f0134d9be 100644
--- a/py/objnamedtuple.c
+++ b/py/objnamedtuple.c
@@ -125,7 +125,11 @@ mp_obj_t namedtuple_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t
return MP_OBJ_FROM_PTR(tuple);
}
-const mp_rom_obj_tuple_t namedtuple_base_tuple = {{&mp_type_tuple}, 1, {MP_ROM_PTR(&mp_type_tuple)}};
+const mp_rom_obj_tuple1_t namedtuple_base_tuple = {
+ .base = {&mp_type_tuple},
+ .len = 1u,
+ .items = {MP_OBJ_FROM_PTR(&mp_type_tuple)}
+};
STATIC mp_obj_t mp_obj_new_namedtuple_type(qstr name, mp_uint_t n_fields, mp_obj_t *fields) {
mp_obj_namedtuple_type_t *o = m_new_obj_var(mp_obj_namedtuple_type_t, qstr, n_fields);
diff --git a/py/objnamedtuple.h b/py/objnamedtuple.h
index f6621642a..89bc16311 100644
--- a/py/objnamedtuple.h
+++ b/py/objnamedtuple.h
@@ -25,6 +25,9 @@
* THE SOFTWARE.
*/
+#ifndef __MICROPY_INCLUDED_PY_OBJNAMEDTUPLE_H__
+#define __MICROPY_INCLUDED_PY_OBJNAMEDTUPLE_H__
+
#include <string.h>
#include "py/nlr.h"
@@ -50,6 +53,8 @@ void namedtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest);
mp_obj_t namedtuple_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args);
-const mp_rom_obj_tuple_t namedtuple_base_tuple;
+const mp_rom_obj_tuple1_t namedtuple_base_tuple;
#endif // MICROPY_PY_COLLECTIONS
+
+#endif // __MICROPY_INCLUDED_PY_OBJNAMEDTUPLE_H__
diff --git a/py/objtuple.h b/py/objtuple.h
index ebfc5c406..024f38a0d 100644
--- a/py/objtuple.h
+++ b/py/objtuple.h
@@ -36,10 +36,18 @@ typedef struct _mp_obj_tuple_t {
typedef struct _mp_rom_obj_tuple_t {
mp_obj_base_t base;
- mp_uint_t len;
+ uint32_t len;
mp_rom_obj_t items[];
} mp_rom_obj_tuple_t;
+// This is identical to the type above except it makes it clear that there is
+// only one item. This makes lto happy with the namedtuple_base_tuple.
+typedef struct _mp_rom_obj_tuple1_t {
+ mp_obj_base_t base;
+ uint32_t len;
+ mp_rom_obj_t items[1];
+} mp_rom_obj_tuple1_t;
+
void mp_obj_tuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind);
mp_obj_t mp_obj_tuple_unary_op(mp_uint_t op, mp_obj_t self_in);
mp_obj_t mp_obj_tuple_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs);
diff --git a/shared-bindings/time/__init__.c b/shared-bindings/time/__init__.c
index b258b3bbd..8ad05f16b 100644
--- a/shared-bindings/time/__init__.c
+++ b/shared-bindings/time/__init__.c
@@ -139,7 +139,7 @@ STATIC const mp_map_elem_t time_module_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_monotonic), (mp_obj_t)&time_monotonic_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_sleep), (mp_obj_t)&time_sleep_obj },
#if MICROPY_PY_COLLECTIONS
- { MP_OBJ_NEW_QSTR(MP_QSTR_struct_time), (mp_obj_t)&struct_time_type_obj },
+ //{ MP_OBJ_NEW_QSTR(MP_QSTR_struct_time), (mp_obj_t)&struct_time_type_obj },
#endif
};