From 24ea3bcafaad376540644ca8a9a5df37f2ac3b02 Mon Sep 17 00:00:00 2001 From: Janek Mann Date: Mon, 11 Aug 2014 00:30:06 +0100 Subject: [PATCH 1/4] fixes to NRF51822 GCC template --- workspace_tools/export/gcc_arm_nrf51822.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workspace_tools/export/gcc_arm_nrf51822.tmpl b/workspace_tools/export/gcc_arm_nrf51822.tmpl index bea937d85e..b9b6425dd2 100644 --- a/workspace_tools/export/gcc_arm_nrf51822.tmpl +++ b/workspace_tools/export/gcc_arm_nrf51822.tmpl @@ -23,7 +23,7 @@ CPU = -mcpu=cortex-m0 -mthumb CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections CC_SYMBOLS = {% for s in symbols %}-D{{s}} {% endfor %} -LD_FLAGS = -mcpu=cortex-m0 -mthumb -Wl,--gc-sections --specs=nano.specs -u _printf_float -u _scanf_float +LD_FLAGS = -mcpu=cortex-m0 -mthumb -Wl,--wrap=main --specs=nano.specs -u _printf_float -u _scanf_float LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys ifeq ($(DEBUG), 1) From 7e2001b98020f7c72c8d2f4b7a91f775c866df11 Mon Sep 17 00:00:00 2001 From: Janek Mann Date: Mon, 11 Aug 2014 11:23:13 +0100 Subject: [PATCH 2/4] workaround for --gc-sections issue with NRF51822 --- workspace_tools/toolchains/gcc.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/workspace_tools/toolchains/gcc.py b/workspace_tools/toolchains/gcc.py index c42f1828ee..ab42256266 100644 --- a/workspace_tools/toolchains/gcc.py +++ b/workspace_tools/toolchains/gcc.py @@ -75,7 +75,10 @@ class GCC(mbedToolchain): self.cc = [join(GOANNA_PATH, "goannacc"), "--with-cc=" + main_cc.replace('\\', '/'), "-std=gnu99", "--dialect=gnu", '--output-format="%s"' % self.GOANNA_FORMAT] + common_flags self.cppc= [join(GOANNA_PATH, "goannac++"), "--with-cxx=" + main_cppc.replace('\\', '/'), "-std=gnu++98", "-fno-rtti", "--dialect=gnu", '--output-format="%s"' % self.GOANNA_FORMAT] + common_flags - self.ld = [join(tool_path, "arm-none-eabi-gcc"), "-Wl,--gc-sections", "-Wl,--wrap,main"] + self.cpu + if target.name in ["NRF51822"]: + self.ld = [join(tool_path, "arm-none-eabi-gcc"), "-Wl,--wrap,main"] + self.cpu + else: + self.ld = [join(tool_path, "arm-none-eabi-gcc"), "-Wl,--gc-sections", "-Wl,--wrap,main"] + self.cpu self.sys_libs = ["stdc++", "supc++", "m", "c", "gcc"] self.ar = join(tool_path, "arm-none-eabi-ar") From c5f07dc672abee55a011dff92b66c31faafc596c Mon Sep 17 00:00:00 2001 From: Janek Mann Date: Mon, 11 Aug 2014 11:42:41 +0100 Subject: [PATCH 3/4] fix for NRF51822 linker script --- .../TOOLCHAIN_GCC_ARM/NRF51822.ld | 17 ++++++++--------- workspace_tools/toolchains/gcc.py | 5 +---- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/libraries/mbed/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_GCC_ARM/NRF51822.ld b/libraries/mbed/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_GCC_ARM/NRF51822.ld index e2d062ef7e..43e0ac80da 100644 --- a/libraries/mbed/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_GCC_ARM/NRF51822.ld +++ b/libraries/mbed/targets/cmsis/TARGET_NORDIC/TARGET_MCU_NRF51822/TOOLCHAIN_GCC_ARM/NRF51822.ld @@ -43,8 +43,8 @@ SECTIONS KEEP(*(.Vectors)) *(.text*) - *(.init) - *(.fini) + KEEP(*(.init)) + KEEP(*(.fini)) /* .ctors */ *crtbegin.o(.ctors) @@ -62,7 +62,7 @@ SECTIONS *(.rodata*) - *(.eh_frame*) + KEEP(*(.eh_frame*)) } > FLASH @@ -89,22 +89,22 @@ SECTIONS . = ALIGN(4); /* preinit data */ PROVIDE_HIDDEN (__preinit_array_start = .); - *(.preinit_array) + KEEP(*(.preinit_array)) PROVIDE_HIDDEN (__preinit_array_end = .); . = ALIGN(4); /* init data */ PROVIDE_HIDDEN (__init_array_start = .); - *(SORT(.init_array.*)) - *(.init_array) + KEEP(*(SORT(.init_array.*))) + KEEP(*(.init_array)) PROVIDE_HIDDEN (__init_array_end = .); . = ALIGN(4); /* finit data */ PROVIDE_HIDDEN (__fini_array_start = .); - *(SORT(.fini_array.*)) - *(.fini_array) + KEEP(*(SORT(.fini_array.*))) + KEEP(*(.fini_array)) PROVIDE_HIDDEN (__fini_array_end = .); *(.jcr) @@ -149,4 +149,3 @@ SECTIONS /* Check if data + heap + stack exceeds RAM limit */ ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") } - diff --git a/workspace_tools/toolchains/gcc.py b/workspace_tools/toolchains/gcc.py index ab42256266..c42f1828ee 100644 --- a/workspace_tools/toolchains/gcc.py +++ b/workspace_tools/toolchains/gcc.py @@ -75,10 +75,7 @@ class GCC(mbedToolchain): self.cc = [join(GOANNA_PATH, "goannacc"), "--with-cc=" + main_cc.replace('\\', '/'), "-std=gnu99", "--dialect=gnu", '--output-format="%s"' % self.GOANNA_FORMAT] + common_flags self.cppc= [join(GOANNA_PATH, "goannac++"), "--with-cxx=" + main_cppc.replace('\\', '/'), "-std=gnu++98", "-fno-rtti", "--dialect=gnu", '--output-format="%s"' % self.GOANNA_FORMAT] + common_flags - if target.name in ["NRF51822"]: - self.ld = [join(tool_path, "arm-none-eabi-gcc"), "-Wl,--wrap,main"] + self.cpu - else: - self.ld = [join(tool_path, "arm-none-eabi-gcc"), "-Wl,--gc-sections", "-Wl,--wrap,main"] + self.cpu + self.ld = [join(tool_path, "arm-none-eabi-gcc"), "-Wl,--gc-sections", "-Wl,--wrap,main"] + self.cpu self.sys_libs = ["stdc++", "supc++", "m", "c", "gcc"] self.ar = join(tool_path, "arm-none-eabi-ar") From 4357cdb2292988080e613cb204c03b685b5047ce Mon Sep 17 00:00:00 2001 From: Janek Mann Date: Mon, 11 Aug 2014 11:51:58 +0100 Subject: [PATCH 4/4] adding --gc-sections back in to the template --- workspace_tools/export/gcc_arm_nrf51822.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workspace_tools/export/gcc_arm_nrf51822.tmpl b/workspace_tools/export/gcc_arm_nrf51822.tmpl index b9b6425dd2..823298e9d1 100644 --- a/workspace_tools/export/gcc_arm_nrf51822.tmpl +++ b/workspace_tools/export/gcc_arm_nrf51822.tmpl @@ -23,7 +23,7 @@ CPU = -mcpu=cortex-m0 -mthumb CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections CC_SYMBOLS = {% for s in symbols %}-D{{s}} {% endfor %} -LD_FLAGS = -mcpu=cortex-m0 -mthumb -Wl,--wrap=main --specs=nano.specs -u _printf_float -u _scanf_float +LD_FLAGS = -mcpu=cortex-m0 -mthumb -Wl,--gc-sections -Wl,--wrap=main --specs=nano.specs -u _printf_float -u _scanf_float LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys ifeq ($(DEBUG), 1)