Skip to content

Update Zephyr RTOS port for Zephyr 1.10 release #2120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions targets/zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the license header.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

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 changes: 0 additions & 62 deletions targets/zephyr/Makefile

This file was deleted.

12 changes: 7 additions & 5 deletions targets/zephyr/Makefile.travis
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
22 changes: 11 additions & 11 deletions targets/zephyr/Makefile.zephyr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 \
Expand All @@ -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; \
Expand Down
4 changes: 2 additions & 2 deletions targets/zephyr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions targets/zephyr/prj.conf
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 0 additions & 5 deletions targets/zephyr/prj.mdef

This file was deleted.