targets: zephyr: Update for Zephyr 1.10 which uses CMake-based build. (#2155)

In 1.10, Zephyr RTOS switched to CMake as means to generate application
makefiles. Consequently, drop Makefile, and introduce CMakeLists.txt,
and update master Makefile.zephyr accordingly.

With these changes, take a chance to make following "cosmetic" changes:

1. Make "qemu_x86" board target the default instead of "arduino_101".
Arduino 101 is just one of the boards of many supported by Zephyr
(and thus JerryScript port), while qemu_x86 is something everyone has.

2. Zephyr make target to run QEMU switched from "qemu" to "run".

3. Don't rely that there's zephyr.strip, it's presence is now
board-dependent. The most we can rely on is zephyr.elf.

targets: zephyr: Remove deprecated prj.mdef file.

MDEF files have been deprecated and ignored for few Zephyr releases.

targets: zephyr: Increase main (i.e. interpreter) thread stack size.

qemu_x86 target now has stack guard enabled by default and it trips with
the default stack size. Set it to 2K for now.

targets: zephyr: Makefile.travis: Update for Zephyr 1.10.

Zephyr 1.10 requires SDK 0.9.2 and CMake 3.8.2.

Also, don't hardcode CC path, it depends on a board and choosed
automatically by Zephyr build system.

JerryScript-DCO-1.0-Signed-off-by: Paul Sokolovsky paul.sokolovsky@linaro.org
This commit is contained in:
Paul Sokolovsky
2018-01-08 10:49:07 +02:00
committed by László Langó
parent e0e6aa0319
commit 290bc22f0c
7 changed files with 69 additions and 85 deletions
+47
View File
@@ -0,0 +1,47 @@
# Copyright JS Foundation and other contributors, http://js.foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
project(NONE)
target_sources(app PRIVATE src/main-zephyr.c src/jerry-port.c src/getline-zephyr.c)
add_library(jerry-core STATIC IMPORTED)
add_library(jerry-ext STATIC IMPORTED)
set_target_properties(jerry-core PROPERTIES IMPORTED_LOCATION
${CMAKE_CURRENT_BINARY_DIR}/../obj/lib/libjerry-core.a)
set_target_properties(jerry-core PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR}/../../jerry-core/include)
set_target_properties(jerry-ext PROPERTIES IMPORTED_LOCATION
${CMAKE_CURRENT_BINARY_DIR}/../obj/lib/libjerry-ext.a)
set_target_properties(jerry-ext PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR}/../../jerry-ext/include)
target_link_libraries(app jerry-core jerry-ext)
zephyr_get_include_directories_for_lang_as_string(C includes)
zephyr_get_system_include_directories_for_lang_as_string(C system_includes)
zephyr_get_compile_definitions_for_lang_as_string(C definitions)
zephyr_get_compile_options_for_lang_as_string(C options)
add_custom_target(
outputexports
COMMAND echo CC="${CMAKE_C_COMPILER}"
COMMAND echo Z_CFLAGS=${system_includes} ${includes} ${definitions} ${options}
COMMAND echo NOSTDINC_FLAGS=${system_includes}
COMMAND echo ZEPHYRINCLUDE=${includes}
COMMAND echo KBUILD_CFLAGS=${definitions}${options}
VERBATIM
USES_TERMINAL
)
-62
View File
@@ -1,62 +0,0 @@
# Copyright JS Foundation and other contributors, http://js.foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# use TAB-8
.DEFAULT_GOAL := all
ifndef ZEPHYR_BASE
$(error Missing zephyr base)
endif
# For testing without real hardware use qemu_x86 instead of arduino_101
BOARD ?= arduino_101
O ?= $(PROJECT_BASE)/outdir
ZEPHYR ?= $(ZEPHYR_BASE)
TYPE ?= release
JERRYHEAP ?= 16
ZEPHYRINC = $(ZEPHYR_BASE)/include
ZEPHYRLIB = $(ZEPHYR_BASE)/lib
TARGET_ZEPHYR ?= ./targets/zephyr
SOURCE_DIR = $(TARGET_ZEPHYR)/src
export JERRY_INCLUDE = -I$(CURDIR)/jerry-core/include -I$(CURDIR)/jerry-ext/include
MDEF_FILE = $(realpath $(SOURCE_DIR)/../prj.mdef)
CONF_FILE = $(realpath $(SOURCE_DIR)/../prj.conf)
ifdef V
$(info Zephyr)
$(info SOURCE_DIR=$(SOURCE_DIR))
$(info JERRY_INCLUDE=$(JERRY_INCLUDE))
$(info CONF_FILE =$(CONF_FILE))
endif
KERNEL_TYPE = micro
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
+7 -5
View File
@@ -27,12 +27,15 @@ install-apt-get-deps:
# Install Zephyr SDK.
install-zephyr-sdk:
wget https://github.com/zephyrproject-rtos/meta-zephyr-sdk/releases/download/0.9.1/zephyr-sdk-0.9.1-setup.run -O ../zephyr-sdk-0.9.1-setup.run
sh ../zephyr-sdk-0.9.1-setup.run -- -y -d $(CURDIR)/../zephyr-sdk-0.9.1
wget https://github.com/zephyrproject-rtos/meta-zephyr-sdk/releases/download/0.9.2/zephyr-sdk-0.9.2-setup.run -O ../zephyr-sdk-0.9.2-setup.run
sh ../zephyr-sdk-0.9.2-setup.run -- -y -d $(CURDIR)/../zephyr-sdk-0.9.2
wget https://cmake.org/files/v3.8/cmake-3.8.2-Linux-x86_64.sh
sudo sh cmake-3.8.2-Linux-x86_64.sh --prefix=/usr/local --exclude-subdir
cmake --version
# Fetch Zephyr Project repository and install python dependencies.
install-zephyr: install-apt-get-deps
git clone https://github.com/zephyrproject-rtos/zephyr.git ../zephyr -b zephyr-v1.9.1
git clone https://github.com/zephyrproject-rtos/zephyr.git ../zephyr -b v1.10.0
pip3 install --user -r ../zephyr/scripts/requirements.txt
# Perform all the necessary (JerryScript-independent) installation steps.
@@ -45,7 +48,6 @@ install: install-zephyr-sdk install-zephyr
SHELL=bash
script:
export ZEPHYR_GCC_VARIANT=zephyr && \
export ZEPHYR_SDK_INSTALL_DIR=$(CURDIR)/../zephyr-sdk-0.9.1 && \
export ZEPHYR_SDK_INSTALL_DIR=$(CURDIR)/../zephyr-sdk-0.9.2 && \
source ../zephyr/zephyr-env.sh && \
CC=$(CURDIR)/../zephyr-sdk-0.9.1/sysroots/x86_64-pokysdk-linux/usr/bin/i586-zephyr-elfiamcu/i586-zephyr-elfiamcu-gcc \
$(MAKE) -f ./targets/zephyr/Makefile.zephyr BOARD=arduino_101
+11 -11
View File
@@ -18,7 +18,8 @@ ifeq ($(.DEFAULT_GOAL),)
$(warning no default goal is set)
endif
BOARD ?= arduino_101
BOARD ?= qemu_x86
CONF_FILE = prj.conf
export BOARD
TARGET_ZEPHYR ?= ./targets/zephyr
@@ -41,7 +42,7 @@ ifndef ZEPHYR_BASE
$(error Missing Zephyr base, did you source zephyr-env.sh? )
endif
INTERM = build/$(BOARD)/obj-$(BOARD)
INTERM = build/$(BOARD)/obj
OUTPUT = build/$(BOARD)/zephyr
include $(OUTPUT)/Makefile.export
@@ -94,25 +95,24 @@ endif
make -C $(INTERM) $(COMPONENTS) V=1
$(OUTPUT)/Makefile.export: $(OUTPUT)/include/config/auto.conf
make -f $(TARGET_ZEPHYR)/Makefile $(BUILD_CONFIG) outputexports
$(OUTPUT)/Makefile.export: $(OUTPUT)/Makefile
make --no-print-directory -C $(OUTPUT) outputexports CMAKE_COMMAND=: >$@
$(OUTPUT)/include/config/auto.conf:
make -f $(TARGET_ZEPHYR)/Makefile $(BUILD_CONFIG) initconfig
$(OUTPUT)/Makefile:
mkdir -p $(OUTPUT) && cmake -DBOARD=$(BOARD) -DCONF_FILE=$(CONF_FILE) -B$(OUTPUT) -Htargets/zephyr/
zephyr: jerry
ifdef V
@echo "- ZEPHYR -------------------------------------------------------"
endif
+make -f $(TARGET_ZEPHYR)/Makefile $(BUILD_CONFIG)
+make -C $(OUTPUT)
@echo "Finished"
@file $(OUTPUT)/zephyr.strip
@size $(OUTPUT)/zephyr.strip
@size $(OUTPUT)/zephyr/zephyr.elf
jerry: $(EXTERNAL_LIB)
@touch $(EXTERNAL_LIB)
GENERIC_TARGETS = qemu qemugdb flash debug debugserver
GENERIC_TARGETS = run qemugdb flash debug debugserver
KCONFIG_TARGETS = \
initconfig config nconfig menuconfig xconfig gconfig \
oldconfig silentoldconfig defconfig savedefconfig \
@@ -127,7 +127,7 @@ $(GENERIC_TARGETS) $(KCONFIG_TARGETS) $(CLEAN_TARGETS):
ifdef V
@echo "- ZEPHYR -------------------------------------------------------"
endif
make -f $(TARGET_ZEPHYR)/Makefile $(BUILD_CONFIG) $@
make -C $(OUTPUT) $@
dfu-x86: all
@- dfu-util -a x86_app -D build/$(BOARD)/zephyr/zephyr.bin; \
+2 -2
View File
@@ -55,13 +55,13 @@ The easiest way is to build and run on a QEMU emulator:
For x86 architecture:
```
make -f ./targets/zephyr/Makefile.zephyr BOARD=qemu_x86 qemu
make -f ./targets/zephyr/Makefile.zephyr BOARD=qemu_x86 run
```
For ARM (Cortex-M) architecture:
```
make -f ./targets/zephyr/Makefile.zephyr BOARD=qemu_cortex_m3 qemu
make -f ./targets/zephyr/Makefile.zephyr BOARD=qemu_cortex_m3 run
```
#### 4. Build for Arduino 101
+2
View File
@@ -1,6 +1,8 @@
CONFIG_BUILD_OUTPUT_BIN=y
CONFIG_STDOUT_CONSOLE=y
CONFIG_NEWLIB_LIBC=y
CONFIG_FLOAT=y
CONFIG_MAIN_STACK_SIZE=2048
CONFIG_CONSOLE_HANDLER=y
CONFIG_CONSOLE_HANDLER_SHELL=y
CONFIG_ARC_INIT=n
-5
View File
@@ -1,5 +0,0 @@
% Application : JerryScript Sample
% TASK NAME PRIO ENTRY STACK GROUPS
% ==================================
TASK TASKA 7 main 2048 [EXE]