From 9955b7d050f23d0e61c3ea0dd9b0ba1a321e7ad3 Mon Sep 17 00:00:00 2001 From: Richard Eoin Meadows Date: Wed, 9 Jul 2014 21:51:46 +0100 Subject: [PATCH] Added support and example for libm --- Makefile | 2 +- chip/sections.ld | 2 ++ src/main.c | 8 +++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 35468be..fe1ad25 100644 --- a/Makefile +++ b/Makefile @@ -95,7 +95,7 @@ endif CFLAGS += $(COMPILATION_FLAGS) -Wall -Wextra $(ACCEPT_WARN) -std=gnu99 \ -ffunction-sections -fdata-sections $(ARCH_FLAGS) ASFLAGS += -Wall $(ARCH_FLAGS) -a=/dev/null -LDFLAGS += $(COMPILATION_FLAGS) -lm $(LINKER_FLAGS) -lm -Wextra $(ARCH_FLAGS) +LDFLAGS += $(COMPILATION_FLAGS) $(LINKER_FLAGS) -Wextra $(ARCH_FLAGS) # Compilation Defines # diff --git a/chip/sections.ld b/chip/sections.ld index fe368db..23f7ed4 100644 --- a/chip/sections.ld +++ b/chip/sections.ld @@ -54,6 +54,8 @@ */ ENTRY(Reset_Handler) +GROUP(libgcc.a libc.a libm.a) + SECTIONS { .text : diff --git a/src/main.c b/src/main.c index 6966f58..cbc9978 100644 --- a/src/main.c +++ b/src/main.c @@ -26,6 +26,7 @@ #include "pindefs.h" #include +#include #include "semihosting.h" int main(void) @@ -41,7 +42,12 @@ int main(void) /* Configure the SysTick for 50ms interrupts */ SysTick_Config(SystemCoreClock / 20); - semihost_printf("Hello World\n"); + volatile double d, dd; + + d = 2; + dd = sqrt(d); + + semihost_printf("Hello World %f\n", dd); while (1); }