From 78186445a45e2874193d5f6dc4f16b7f02880d7e Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Mon, 6 Jun 2016 23:44:35 +0300 Subject: [PATCH] targets/arduino_101: Refactor to better support other Zephyr targets. This adds support for ARM/Thumb2 (Cortex-M) architecture, tested with BOARD=qemu_cortex_m3 (i.e. QEMU with Cortex-M emulation). Should also ease porting to other architectures supported by Zephyr. This uses method of passing external libraries and link options into a Zephyr application using ALL_LIBS and LDFLAGS_zephyr make variables, as suggested by the Zephyr developers: https://gerrit.zephyrproject.org/r/#/c/2476/ , and makes sure to append to them, instead of assigning, to not overwrite important target-specific options set by the Zephyr core. JerryScript-DCO-1.0-Signed-off-by: Paul Sokolovsky paul.sokolovsky@linaro.org --- targets/arduino_101/Makefile | 5 +++++ targets/arduino_101/Makefile.arduino_101 | 16 +++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/targets/arduino_101/Makefile b/targets/arduino_101/Makefile index 4ce34c942..d4746afc6 100644 --- a/targets/arduino_101/Makefile +++ b/targets/arduino_101/Makefile @@ -51,6 +51,11 @@ KBUILD_VERBOSE = $(V) APP = main-zephyr.c +ALL_LIBS += $(USER_LIBS) +export ALL_LIBS +LDFLAGS_zephyr += $(USER_LIB_INCLUDE_DIR) +export LDFLAGS_zephyr + include ${ZEPHYR_BASE}/Makefile.inc .PHONY = showconfig diff --git a/targets/arduino_101/Makefile.arduino_101 b/targets/arduino_101/Makefile.arduino_101 index 4cea7d18a..f3ac05208 100644 --- a/targets/arduino_101/Makefile.arduino_101 +++ b/targets/arduino_101/Makefile.arduino_101 @@ -61,13 +61,19 @@ EXT_CFLAGS += -ffunction-sections -fno-inline-functions ifeq ($(BOARD),qemu_x86) CONFIG_TOOLCHAIN_VARIANT = x86 +CPU = x86 EXT_CFLAGS += -march=pentium +EXT_CFLAGS += -mpreferred-stack-boundary=2 -mno-sse +else ifeq ($(BOARD),qemu_cortex_m3) +CONFIG_TOOLCHAIN_VARIANT = arm +CPU = arm7-m +EXT_CFLAGS += -march=armv7-m -mthumb -mcpu=cortex-m3 -mabi=aapcs else CONFIG_TOOLCHAIN_VARIANT = iamcu +CPU = lakemont EXT_CFLAGS += -march=lakemont -mtune=lakemont -miamcu -msoft-float -endif - EXT_CFLAGS += -mpreferred-stack-boundary=2 -mno-sse +endif EXT_CFLAGS += -Wall -Wno-format-zero-length -Wno-pointer-sign EXT_CFLAGS += -Werror=format -Werror=implicit-int -Wno-unused-but-set-variable @@ -89,12 +95,12 @@ EXTERNAL_LIB = $(INTERM)/lib$(TYPE).external$(VARIETY)-entry.a ZEPHYR_BIN = $(OUTPUT)/zephyr/zephyr.strip PREFIX = $(TYPE)$(VARIETY) -LIBS = $(TYPE).external$(VARIETY)-entry $(PREFIX).jerry-core $(PREFIX).jerry-libm.lib $(TOOLCHAIN_LIBS) c +LIBS = $(TYPE).external$(VARIETY)-entry $(PREFIX).jerry-core $(PREFIX).jerry-libm.lib # TODO @sergioamr Change how we link the library to USER_LDFLAGS # https://gerrit.zephyrproject.org/r/#/c/2048/ -BUILD_CONFIG = O="$(OUTPUT)/zephyr" V=$(V) TOOLCHAIN_LIBS="$(LIBS)" LIB_INCLUDE_DIR="$(LIB_INCLUDE_DIR)" +BUILD_CONFIG = O="$(OUTPUT)/zephyr" V=$(V) USER_LIBS="$(LIBS)" USER_LIB_INCLUDE_DIR="-L $(CURDIR)/$(OUTPUT)" .PHONY: all all: jerry zephyr @@ -112,7 +118,7 @@ endif -DCMAKE_VERBOSE_MAKEFILE=$(V) \ -DEXTERNAL_CMAKE_C_COMPILER=$(CC) \ -DEXTERNAL_CMAKE_C_COMPILER_ID=GNU \ - -DEXTERNAL_CMAKE_SYSTEM_PROCESSOR=x86 \ + -DEXTERNAL_CMAKE_SYSTEM_PROCESSOR=$(CPU) \ -DEXTERNAL_MEM_HEAP_SIZE_KB=$(JERRYHEAP) \ -DEXTERNAL_COMPILE_FLAGS="$(EXT_CFLAGS)" \ -DEXTERNAL_CMAKE_SYSTEM_PROCESSOR=lakemont \