Skip to content

Commit 062fac1

Browse files
committed
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.
1 parent 3fd19c6 commit 062fac1

File tree

12 files changed

+37
-10
lines changed

12 files changed

+37
-10
lines changed

atmel-samd/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ CFLAGS_CORTEX_M0 = \
115115
-DTC_ASYNC=true \
116116
-DUSB_DEVICE_LPM_SUPPORT \
117117
--param max-inline-insns-single=500
118-
CFLAGS = $(INC) -Wall -Werror -std=gnu11 -nostdlib $(CFLAGS_CORTEX_M0) $(COPT)
118+
CFLAGS = $(INC) -Wall -Werror -std=gnu11 -nostdlib $(CFLAGS_CORTEX_M0) $(COPT) $(BOARD_CFLAGS)
119119

120120
#Debugging/Optimization
121121
# 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
139139
CFLAGS += -DMICROPY_MODULE_FROZEN_MPY
140140
endif
141141

142-
LIBM_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-file-name=libm.a)
143-
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
142+
#LIBM_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-file-name=libm.a)
143+
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
144144
LIBS = -larm_cortexM0l_math -lsamd21_qtouch_gcc -lm -lgcc -lc
145145

146146
SRC_ASF = $(addprefix asf/sam0/,\

atmel-samd/asf/sam0/utils/cmsis/samd21/source/gcc/startup_samd21.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ void AC1_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler
127127
#endif
128128

129129
/* Exception Table */
130-
__attribute__ ((section(".vectors")))
130+
__attribute__ ((used, section(".vectors")))
131131
const DeviceVectors exception_table = {
132132

133133
/* Configure Initial Stack Pointer, using linker-generated symbols */
@@ -229,7 +229,7 @@ const DeviceVectors exception_table = {
229229
* \brief This is the code that gets called on processor reset.
230230
* To initialize the device, and call the main() routine.
231231
*/
232-
void Reset_Handler(void)
232+
__attribute__ ((used))void Reset_Handler(void)
233233
{
234234
uint32_t *pSrc, *pDest;
235235

atmel-samd/boards/arduino_zero/mpconfigboard.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ USB_PID = 0x824D
55
FLASH_IMPL = internal_flash.c
66

77
CHIP_VARIANT = SAMD21G18A
8+
9+
BOARD_CFLAGS = -flto

atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ USB_PID = 0x8015
55
FLASH_IMPL = internal_flash.c
66

77
CHIP_VARIANT = SAMD21G18A
8+
9+
BOARD_CFLAGS = -flto

atmel-samd/boards/feather_m0_basic/mpconfigboard.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ USB_PID = 0x8015
55
FLASH_IMPL = internal_flash.c
66

77
CHIP_VARIANT = SAMD21G18A
8+
9+
BOARD_CFLAGS = -flto

atmel-samd/boards/gemma_m0/mpconfigboard.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ USB_PID = 0x8015
55
FLASH_IMPL = internal_flash.c
66

77
CHIP_VARIANT = SAMD21E18A
8+
9+
BOARD_CFLAGS = -flto

atmel-samd/boards/trinket_m0/mpconfigboard.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ USB_PID = 0x8015
55
FLASH_IMPL = internal_flash.c
66

77
CHIP_VARIANT = SAMD21E18A
8+
9+
BOARD_CFLAGS = -flto

atmel-samd/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ void samd21_init(void) {
500500
nvm_set_config(&config_nvm);
501501
}
502502

503-
int main(int argc, char **argv) {
503+
int main(void) {
504504
// initialise the cpu and peripherals
505505
samd21_init();
506506

py/objnamedtuple.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,11 @@ mp_obj_t namedtuple_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t
125125
return MP_OBJ_FROM_PTR(tuple);
126126
}
127127

128-
const mp_rom_obj_tuple_t namedtuple_base_tuple = {{&mp_type_tuple}, 1, {MP_ROM_PTR(&mp_type_tuple)}};
128+
const mp_rom_obj_tuple1_t namedtuple_base_tuple = {
129+
.base = {&mp_type_tuple},
130+
.len = 1u,
131+
.items = {MP_OBJ_FROM_PTR(&mp_type_tuple)}
132+
};
129133

130134
STATIC mp_obj_t mp_obj_new_namedtuple_type(qstr name, mp_uint_t n_fields, mp_obj_t *fields) {
131135
mp_obj_namedtuple_type_t *o = m_new_obj_var(mp_obj_namedtuple_type_t, qstr, n_fields);

py/objnamedtuple.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
* THE SOFTWARE.
2626
*/
2727

28+
#ifndef __MICROPY_INCLUDED_PY_OBJNAMEDTUPLE_H__
29+
#define __MICROPY_INCLUDED_PY_OBJNAMEDTUPLE_H__
30+
2831
#include <string.h>
2932

3033
#include "py/nlr.h"
@@ -50,6 +53,8 @@ void namedtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest);
5053

5154
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);
5255

53-
const mp_rom_obj_tuple_t namedtuple_base_tuple;
56+
const mp_rom_obj_tuple1_t namedtuple_base_tuple;
5457

5558
#endif // MICROPY_PY_COLLECTIONS
59+
60+
#endif // __MICROPY_INCLUDED_PY_OBJNAMEDTUPLE_H__

0 commit comments

Comments
 (0)