Skip to content

Commit 4091444

Browse files
committed
targets/zephyr: Rename from arduino_101, with more targets supported.
- Add preliminary support for ARC architecture. Using "em_starterkit" board supported by Zephyr. Only build for this board is tested, not booted on a real device due to lack of access. There's no QEMU emulation support for ARC in Zephyr (yet) either. - Update README to cover different Zephyr architectures/boards. - Changed the arduino_101 paths to something more generic and adaptable - Made sure it compiles and runs on Arduino 101 JerryScript-DCO-1.0-Signed-off-by: Sergio Martinez [email protected] JerryScript-DCO-1.0-Signed-off-by: Paul Sokolovsky [email protected]
1 parent 64f4938 commit 4091444

File tree

9 files changed

+59
-41
lines changed

9 files changed

+59
-41
lines changed

targets/arduino_101/Makefile renamed to targets/zephyr/Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
ifndef ZEPHYR_BASE
1919
$(error Missing zephyr base)
2020
endif
21-
21+
2222
# For testing without real hardware use qemu_x86 instead of arduino_101
2323
BOARD ?= arduino_101
24-
24+
2525
O ?= $(PROJECT_BASE)/outdir
2626

2727
ZEPHYR ?= $(ZEPHYR_BASE)
@@ -31,7 +31,8 @@ JERRYHEAP ?= 16
3131
ZEPHYRINC = $(ZEPHYR_BASE)/include
3232
ZEPHYRLIB = $(ZEPHYR_BASE)/lib
3333

34-
SOURCE_DIR = ./targets/arduino_101/src
34+
TARGET_ZEPHYR ?= ./targets/zephyr
35+
SOURCE_DIR = $(TARGET_ZEPHYR)/src
3536

3637
export JERRY_INCLUDE = $(CURDIR)/jerry-core/
3738

targets/arduino_101/Makefile.arduino_101 renamed to targets/zephyr/Makefile.zephyr

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ ifeq ($(BOARD),qemu_x86)
2929
BOARD_NAME ?= qemu_x86
3030
endif
3131

32+
TARGET_ZEPHYR ?= ./targets/zephyr
33+
SOURCE_DIR = $(TARGET_ZEPHYR)/src
34+
3235
TYPE ?= release
3336
JERRYHEAP ?= 16
3437

@@ -68,6 +71,11 @@ else ifeq ($(BOARD),qemu_cortex_m3)
6871
CONFIG_TOOLCHAIN_VARIANT = arm
6972
CPU = arm7-m
7073
EXT_CFLAGS += -march=armv7-m -mthumb -mcpu=cortex-m3 -mabi=aapcs
74+
else ifeq ($(BOARD),em_starterkit)
75+
# TODO: Tested only to build, untested to boot
76+
CONFIG_TOOLCHAIN_VARIANT = arc
77+
CPU = arc
78+
EXT_CFLAGS += -mARCv2EM -mav2em -mno-sdata
7179
else
7280
CONFIG_TOOLCHAIN_VARIANT = iamcu
7381
CPU = lakemont
@@ -97,10 +105,7 @@ ZEPHYR_BIN = $(OUTPUT)/zephyr/zephyr.strip
97105
PREFIX = $(TYPE)$(VARIETY)
98106
LIBS = $(TYPE).external$(VARIETY)-entry $(PREFIX).jerry-core $(PREFIX).jerry-libm.lib
99107

100-
# TODO @sergioamr Change how we link the library to USER_LDFLAGS
101-
# https://gerrit.zephyrproject.org/r/#/c/2048/
102-
103-
BUILD_CONFIG = O="$(OUTPUT)/zephyr" V=$(V) USER_LIBS="$(LIBS)" USER_LIB_INCLUDE_DIR="-L $(CURDIR)/$(OUTPUT)"
108+
BUILD_CONFIG = O="$(OUTPUT)/zephyr" V=$(V) USER_LIBS="$(LIBS)" USER_LIB_INCLUDE_DIR="-L $(CURDIR)/$(OUTPUT)" TARGET_ZEPHYR=$(TARGET_ZEPHYR)
104109

105110
.PHONY: all
106111
all: jerry zephyr
@@ -124,7 +129,7 @@ endif
124129
-DEXTERNAL_CMAKE_SYSTEM_PROCESSOR=lakemont \
125130
-DEXTERNAL_LIBC_INTERFACE="$(ZEPHYR_LIBC_INC)" \
126131
-DCMAKE_TOOLCHAIN_FILE=build/configs/toolchain_external.cmake \
127-
-DEXTERNAL_BUILD_ENTRY_FILE=./targets/arduino_101/src/jerry-entry.c
132+
-DEXTERNAL_BUILD_ENTRY_FILE=$(SOURCE_DIR)/jerry-entry.c
128133

129134
make -C $(INTERM) $(TYPE).external$(VARIETY) V=1
130135
cp `cat $(INTERM)/$(TYPE).external$(VARIETY)/list` $(OUTPUT)/.
@@ -134,7 +139,7 @@ $(ZEPHYR_BIN):
134139
ifdef V
135140
@echo "- ZEPHYR -------------------------------------------------------"
136141
endif
137-
make -f ./targets/arduino_101/Makefile $(BUILD_CONFIG)
142+
make -f $(TARGET_ZEPHYR)/Makefile $(BUILD_CONFIG)
138143
@echo "Finished"
139144
@file $(OUTPUT)/zephyr/zephyr.strip
140145
@size $(OUTPUT)/zephyr/zephyr.strip
@@ -146,10 +151,10 @@ zephyr: $(EXTERNAL_LIB) $(ZEPHYR_BIN)
146151
@touch $(ZEPHYR_BIN)
147152

148153
qemu: $(EXTERNAL_LIB) $(ZEPHYR_BIN)
149-
make -f ./targets/arduino_101/Makefile $(BUILD_CONFIG) qemu
154+
make -f $(TARGET_ZEPHYR)/Makefile $(BUILD_CONFIG) qemu
150155

151156
flash: $(EXTERNAL_LIB) $(OUTPUT)/zephyr/zephyr.strip
152-
make -f ./targets/arduino_101/Makefile $(BUILD_CONFIG) flash
157+
make -f $(TARGET_ZEPHYR)/Makefile $(BUILD_CONFIG) flash
153158

154159
usage:
155160
help:
@@ -171,19 +176,20 @@ showconfig:
171176
@echo "LIBS = $(LIBS) "
172177
@echo "LIB_INCLUDE_DIR = $(LIB_INCLUDE_DIR) "
173178
@echo "BUILD_CONFIG = $(BUILD_CONFIG) "
174-
make -f ./targets/arduino_101/Makefile $(BUILD_CONFIG) showconfig
179+
make -f $(TARGET_ZEPHYR)/Makefile $(BUILD_CONFIG) showconfig
175180

176181
# TODO @sergioamr Temporal cleanup before finding why Zephyr is ignoring my
177182
# outdir for the project
178183
clean:
179184
@echo "Clearing Jerryscript"
180185
@rm -rf $(OUTPUT)
181186
@rm -rf $(INTERM)
182-
@rm -f ./targets/arduino_101/src/.*.o.cmd
183-
@rm -f ./targets/arduino_101/src/*.o
187+
@rm -f $(SOURCE_DIR)/.*.o.cmd
188+
@rm -f $(SOURCE_DIR)/*.o
184189
@echo "Clearing Zephyr"
185-
make -f ./targets/arduino_101/Makefile clean
186-
make -f ./targets/arduino_101/Makefile pristine
190+
make -f $(TARGET_ZEPHYR)/Makefile clean
191+
make -f $(TARGET_ZEPHYR)/Makefile pristine
187192

188193
mrproper:
189-
make -f ./targets/arduino_101/Makefile mrproper
194+
make -f $(TARGET_ZEPHYR)/Makefile mrproper
195+

targets/arduino_101/README.md renamed to targets/zephyr/README.md

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
### About
22

3-
This folder contains files to run JerryScript on Zephyr with
4-
[Arduino 101 / Genuino 101](https://www.arduino.cc/en/Main/ArduinoBoard101)
5-
6-
Zephyr project arduino 101
7-
[Zephyr Arduino 101](https://www.zephyrproject.org/doc/board/arduino_101.html)
3+
This folder contains files to integrate JerryScript with Zephyr RTOS to
4+
run on a number of supported boards (like
5+
[Arduino 101 / Genuino 101](https://www.arduino.cc/en/Main/ArduinoBoard101),
6+
[Zephyr Arduino 101](https://www.zephyrproject.org/doc/board/arduino_101.html)).
87

98
### How to build
109

1110
#### 1. Preface
1211

13-
1, Directory structure
12+
1. Directory structure
1413

1514
Assume `harmony` as the path to the projects to build.
1615
The folder tree related would look like this.
1716

1817
```
1918
harmony
20-
+ jerry
19+
+ jerryscript
2120
| + targets
22-
| + arduino_101
21+
| + zephyr
2322
+ zephyr
2423
```
2524

2625

27-
2, Target board
26+
2. Target boards/emulations
2827

29-
Assume [Arduino 101 / Genuino 101](https://www.arduino.cc/en/Main/ArduinoBoard101)
30-
as the target board.
28+
Following Zephyr boards were tested: qemu_x86, qemu_cortex_m3, arduino_101.
3129

3230

3331
#### 2. Prepare Zephyr
3432

3533
Follow [this](https://www.zephyrproject.org/doc/getting_started/getting_started.html) page to get
3634
the Zephyr source and configure the environment.
3735

38-
Follow "Building a Sample Application" and check that you can flash the Arduino 101
36+
If you just start with Zephyr, you may want to follow "Building a Sample
37+
Application" section in the doc above and check that you can flash your
38+
target board.
3939

40-
Remember to source the zephyr environment.
40+
Remember to source the Zephyr environment:
4141

4242
```
4343
source zephyr-env.sh
@@ -49,10 +49,26 @@ export ZEPHYR_SDK_INSTALL_DIR=<sdk installation directory>
4949

5050
#### 3. Build JerryScript for Zephyr
5151

52+
The easiest way is to build and run on a QEMU emulator:
53+
54+
For x86 architecture:
55+
56+
```
57+
make -f ./targets/zephyr/Makefile.zephyr BOARD=qemu_x86 qemu
58+
```
59+
60+
For ARM (Cortex-M) architecture:
61+
62+
```
63+
make -f ./targets/zephyr/Makefile.zephyr BOARD=qemu_cortex_m3 qemu
64+
```
65+
66+
#### 4. Build for Arduino 101
67+
5268
```
5369
# assume you are in harmony folder
5470
cd jerry
55-
make -f ./targets/arduino_101/Makefile.arduino_101
71+
make -f ./targets/zephyr/Makefile.zephyr BOARD=arduino_101
5672
```
5773

5874
This will generate the following libraries:
@@ -71,20 +87,21 @@ The final Zephyr image will be located here:
7187

7288
Details on how to flash the image can be found here:
7389
[Flashing image](https://www.zephyrproject.org/doc/board/arduino_101.html)
90+
(or similar page for other supported boards).
7491

7592
To be able to use this demo in hardware you will need the serial console
7693
which will be generating output to Pins 0 & 1
7794

7895
Some examples of building the software
7996

8097
```
81-
make -f ./targets/arduino_101/Makefile.arduino_101 clean
98+
make -f ./targets/zephyr/Makefile.zephyr clean
8299
```
83100

84101
- Not using a Jtag and having a factory stock Arduino 101.
85102

86103
```
87-
make -f ./targets/arduino_101/Makefile.arduino_101 BOARD=arduino_101_factory
104+
make -f ./targets/zephyr/Makefile.zephyr BOARD=arduino_101_factory
88105
```
89106

90107
Follow the Zephyr instructions to flash using the dfu-util command.
@@ -96,16 +113,10 @@ There is a helper function to flash using the JTAG and Flywatter2
96113

97114
![alt tag](docs/arduino_101.jpg?raw=true "Example")
98115
```
99-
make -f ./targets/arduino_101/Makefile.arduino_101 BOARD=arduino_101 flash
116+
make -f ./targets/zephyr/Makefile.zephyr BOARD=arduino_101 flash
100117
101118
```
102119

103-
- Compiling and running with the emulator
104-
```
105-
make -f ./targets/arduino_101/Makefile.arduino_101 BOARD=qemu_x86 qemu
106-
```
107-
108-
109120
#### 6. Serial terminal
110121

111122
Test command line in a serial terminal.
@@ -137,4 +148,4 @@ Help will provide a list of commands
137148
> help
138149
```
139150

140-
This program, is built in top of the Zephyr command line, so there is a limit of 10 spaces.
151+
This program, is built in top of the Zephyr command line, so there is a limit of 10 spaces.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)