From 863a5c1734f9c6d4da43c1b3f3f9b528d7c8dcf1 Mon Sep 17 00:00:00 2001 From: Glenn Ruben Bakke Date: Tue, 18 Jul 2017 00:18:05 +0200 Subject: [PATCH] nrf: Add support for floating point on nrf52 targets. Duplicating pattern for detecting location of libm, libc and libgcc from teensy port. Activating MICROPY_FLOAT_IMPL (FLOAT) for nrf52 targets and adding libs into the compile. For nrf51 targets it is still set to NONE as code grows to much (about 30k). Some numbers on flash use if MICROPY_FLOAT_IMPL is set to MICROPY_FLOAT_IMPL_FLOAT and math libraries are enabled (lgcc, lc, lm). nrf51: ====== without float support: text data bss dec hex filename 144088 260 30020 174368 2a920 build-pca10028/firmware.elf with float support: text data bss dec hex filename 176228 1336 30020 207584 32ae0 build-pca10028/firmware.elf nrf52: ====== without float support: text data bss dec hex filename 142040 356 36236 178632 2b9c8 build-pca10040/firmware.elf with float support: text data bss dec hex filename 165068 1436 36236 202740 317f4 build-pca10040/firmware.elf --- nrf/Makefile | 12 +++++++++++- nrf/mpconfigport.h | 5 +++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/nrf/Makefile b/nrf/Makefile index 83ed917c52..1b0a7c655b 100644 --- a/nrf/Makefile +++ b/nrf/Makefile @@ -90,7 +90,17 @@ CFLAGS += -Os -DNDEBUG LDFLAGS += -Os endif -LIBS += \ +LIBS = \ + +ifeq ($(MCU_VARIANT), nrf52) +LIBM_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-file-name=libm.a) +LIBC_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-file-name=libc.a) +LIBGCC_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name) + +LIBS += -L $(dir $(LIBM_FILE_NAME)) -lm +LIBS += -L $(dir $(LIBC_FILE_NAME)) -lc +LIBS += -L $(dir $(LIBGCC_FILE_NAME)) -lgcc +endif SRC_LIB = $(addprefix lib/,\ libc/string0.c \ diff --git a/nrf/mpconfigport.h b/nrf/mpconfigport.h index 4c437f0232..e90c5a4ccd 100644 --- a/nrf/mpconfigport.h +++ b/nrf/mpconfigport.h @@ -45,7 +45,12 @@ #define MICROPY_REPL_AUTO_INDENT (1) #define MICROPY_ENABLE_SOURCE_LINE (0) #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ) +#if NRF51 #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE) +#else +#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT) +#endif + #define MICROPY_OPT_COMPUTED_GOTO (0) #define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (0) #define MICROPY_OPT_MPZ_BITWISE (0)