• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1### About
2
3This folder contains files to integrate JerryScript with Zephyr RTOS to
4run 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)).
7
8### How to build
9
10#### 1. Preface
11
121. Directory structure
13
14Assume `harmony` as the path to the projects to build.
15The folder tree related would look like this.
16
17```
18harmony
19  + jerryscript
20  |  + targets
21  |      + zephyr
22  + zephyr-project
23```
24
25
262. Target boards/emulations
27
28Following Zephyr boards were tested: qemu_x86, qemu_cortex_m3, arduino_101,
29frdm_k64f.
30
31
32#### 2. Prepare Zephyr
33
34Follow [this](https://www.zephyrproject.org/doc/getting_started/getting_started.html) page to get
35the Zephyr source and configure the environment.
36
37If you just start with Zephyr, you may want to follow "Building a Sample
38Application" section in the doc above and check that you can flash your
39target board.
40
41Remember to source the Zephyr environment as explained in the zephyr documenation:
42
43```
44cd zephyr-project
45source zephyr-env.sh
46
47export ZEPHYR_GCC_VARIANT=zephyr
48export ZEPHYR_SDK_INSTALL_DIR=<sdk installation directory>
49```
50
51#### 3. Build JerryScript for Zephyr
52
53The easiest way is to build and run on a QEMU emulator:
54
55For x86 architecture:
56
57```
58make -f ./targets/zephyr/Makefile.zephyr BOARD=qemu_x86 run
59```
60
61For ARM (Cortex-M) architecture:
62
63```
64make -f ./targets/zephyr/Makefile.zephyr BOARD=qemu_cortex_m3 run
65```
66
67#### 4. Build for Arduino 101
68
69```
70# assume you are in harmony folder
71cd jerryscript
72make -f ./targets/zephyr/Makefile.zephyr BOARD=arduino_101
73```
74
75This will generate the following libraries:
76```
77./build/arduino_101/librelease-cp_minimal.jerry-core.a
78./build/arduino_101/librelease-cp_minimal.jerry-libm.lib.a
79./build/arduino_101/librelease.external-cp_minimal-entry.a
80```
81
82The final Zephyr image will be located here:
83```
84./build/arduino_101/zephyr/zephyr.strip
85```
86
87#### 5. Flashing
88
89Details on how to flash the image can be found here:
90[Flashing image](https://www.zephyrproject.org/doc/board/arduino_101.html)
91(or similar page for other supported boards).
92
93To be able to use this demo in hardware you will need the serial console
94which will be generating output to Pins 0 & 1.
95
96You will need a 3.3v TTL to RS232, please follow the zephyr documentation on it.
97
98Some examples of building the software
99
100```
101make -f ./targets/zephyr/Makefile.zephyr BOARD=<board> clean
102```
103
104- Not using a Jtag and having a factory stock Arduino 101.
105You can follow the Zephyr instructions to flash using the dfu-util command
106or use this helper:
107
108```
109make -f ./targets/zephyr/Makefile.zephyr BOARD=arduino_101 dfu-x86
110```
111
112Make sure you have the factory bootloader in your device to use this method or it will not flash.
113
114- Using JTAG
115
116There is a helper function to flash using the JTAG and Flywatter2
117
118![alt tag](docs/arduino_101.jpg?raw=true "Example")
119
120```
121make -f ./targets/zephyr/Makefile.zephyr BOARD=arduino_101 flash
122```
123
124<warning> Careful if you flash the BOARD arduino_101, you will lose the bootloader
125and you will have to follow the zephyr documentation to get it back from
126the backup we all know you did at the setup. </warning>
127
128#### 6. Serial terminal
129
130Test command line in a serial terminal.
131
132
133You should see something similar to this:
134```
135JerryScript build: Aug 12 2016 17:12:55
136JerryScript API 1.0
137Zephyr version 1.4.0
138js>
139```
140
141
142Run the example javascript command test function
143```
144js> var test=0; for (t=100; t<1000; t++) test+=t; print ('Hi JS World! '+test);
145Hi JS World! 494550
146```
147
148
149Try a more complex function:
150```
151js> function hello(t) {t=t*10;return t}; print("result"+hello(10.5));
152```
153