targets: zephyr: Update for Zephyr 2.x (#4731)
targets: zephyr: Update for Zephyr 2.2 Zephyr 2.2 removed some deprecated compatibility headers, use the new location. targets: zephyr: Update for Zephyr 2.3 Rename CONFIG_FLOAT -> CONFIG_FPU based on the change done in Zephyr 2.3. JerryScript-DCO-1.0-Signed-off-by: Paul Sokolovsky paul.sokolovsky@linaro.org targets: zephyr: Update CI and docs for Zephyr 2.6 And to the latest Zephyr SDK 0.13.0. arduino_101 board is no longer supported by Zephyr 2.x, so replace it with qemu_x86 (i.e. QEMU emulation target) in CI and with frdm_k64f in docs. JerryScript-DCO-1.0-Signed-off-by: Paul Sokolovsky paul.sokolovsky@linaro.org
This commit is contained in:
@@ -248,7 +248,7 @@ jobs:
|
|||||||
- run: make -f ./targets/mbedos5/Makefile.travis install
|
- run: make -f ./targets/mbedos5/Makefile.travis install
|
||||||
- run: make -f ./targets/mbedos5/Makefile.travis script
|
- run: make -f ./targets/mbedos5/Makefile.travis script
|
||||||
|
|
||||||
Zephyr_Arduino_101_Build_Test:
|
Zephyr_Qemu_x86_Build_Test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|||||||
@@ -27,12 +27,12 @@ install-apt-get-deps:
|
|||||||
|
|
||||||
# Install Zephyr SDK.
|
# Install Zephyr SDK.
|
||||||
install-zephyr-sdk:
|
install-zephyr-sdk:
|
||||||
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.10.0/zephyr-sdk-0.10.0-setup.run -O ../zephyr-sdk-0.10.0-setup.run
|
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.13.0/zephyr-sdk-0.13.0-linux-x86_64-setup.run -O ../zephyr-sdk-0.13.0-linux-x86_64-setup.run
|
||||||
sh ../zephyr-sdk-0.10.0-setup.run -- -y -d $(CURDIR)/../zephyr-sdk-0.10.0
|
sh ../zephyr-sdk-0.13.0-linux-x86_64-setup.run -- -y -d $(CURDIR)/../zephyr-sdk-0.13.0
|
||||||
|
|
||||||
# Fetch Zephyr Project repository and install python dependencies.
|
# Fetch Zephyr Project repository and install python dependencies.
|
||||||
install-zephyr:
|
install-zephyr:
|
||||||
git clone https://github.com/zephyrproject-rtos/zephyr.git ../zephyr -b v1.14-branch
|
git clone https://github.com/zephyrproject-rtos/zephyr.git ../zephyr -b v2.5-branch
|
||||||
pip3 install -U pip
|
pip3 install -U pip
|
||||||
pip3 install -U setuptools
|
pip3 install -U setuptools
|
||||||
pip3 install -r ../zephyr/scripts/requirements.txt
|
pip3 install -r ../zephyr/scripts/requirements.txt
|
||||||
@@ -53,6 +53,6 @@ install: install-apt-get-deps install-noapt
|
|||||||
SHELL=bash
|
SHELL=bash
|
||||||
script:
|
script:
|
||||||
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr && \
|
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr && \
|
||||||
export ZEPHYR_SDK_INSTALL_DIR=$(CURDIR)/../zephyr-sdk-0.10.0 && \
|
export ZEPHYR_SDK_INSTALL_DIR=$(CURDIR)/../zephyr-sdk-0.13.0 && \
|
||||||
source ../zephyr/zephyr-env.sh && \
|
source ../zephyr/zephyr-env.sh && \
|
||||||
$(MAKE) -f ./targets/zephyr/Makefile.zephyr BOARD=arduino_101
|
$(MAKE) -f ./targets/zephyr/Makefile.zephyr BOARD=qemu_x86
|
||||||
|
|||||||
+37
-61
@@ -1,9 +1,7 @@
|
|||||||
### About
|
### About
|
||||||
|
|
||||||
This folder contains files to integrate JerryScript with Zephyr RTOS to
|
This folder contains files to integrate JerryScript with Zephyr RTOS
|
||||||
run on a number of supported boards (like
|
(https://zephyrproject.org/).
|
||||||
[Arduino 101 / Genuino 101](https://www.arduino.cc/en/Main/ArduinoBoard101),
|
|
||||||
[Zephyr Arduino 101](https://www.zephyrproject.org/doc/board/arduino_101.html)).
|
|
||||||
|
|
||||||
### How to build
|
### How to build
|
||||||
|
|
||||||
@@ -25,8 +23,11 @@ harmony
|
|||||||
|
|
||||||
2. Target boards/emulations
|
2. Target boards/emulations
|
||||||
|
|
||||||
Following Zephyr boards were tested: qemu_x86, qemu_cortex_m3, arduino_101,
|
Following Zephyr boards are known to work: qemu_x86, qemu_cortex_m3,
|
||||||
frdm_k64f.
|
frdm_k64f. But generally, any board supported by Zephyr should work,
|
||||||
|
as long as it has enough Flash and RAM (boards which don't have
|
||||||
|
enough of those, will simply have link-time errors of ROM/RAM
|
||||||
|
overflow).
|
||||||
|
|
||||||
|
|
||||||
#### 2. Prepare Zephyr
|
#### 2. Prepare Zephyr
|
||||||
@@ -48,7 +49,7 @@ export ZEPHYR_GCC_VARIANT=zephyr
|
|||||||
export ZEPHYR_SDK_INSTALL_DIR=<sdk installation directory>
|
export ZEPHYR_SDK_INSTALL_DIR=<sdk installation directory>
|
||||||
```
|
```
|
||||||
|
|
||||||
#### 3. Build JerryScript for Zephyr
|
#### 3. Build JerryScript for Zephyr QEMU
|
||||||
|
|
||||||
The easiest way is to build and run on a QEMU emulator:
|
The easiest way is to build and run on a QEMU emulator:
|
||||||
|
|
||||||
@@ -64,88 +65,63 @@ For ARM (Cortex-M) architecture:
|
|||||||
make -f ./targets/zephyr/Makefile.zephyr BOARD=qemu_cortex_m3 run
|
make -f ./targets/zephyr/Makefile.zephyr BOARD=qemu_cortex_m3 run
|
||||||
```
|
```
|
||||||
|
|
||||||
#### 4. Build for Arduino 101
|
#### 4. Build for a real board
|
||||||
|
|
||||||
|
Below, we build for NXP FRDM-K64F board (`frdm_k64f` Zephyr board
|
||||||
|
identifier). Building for other boards is similar. You are expected
|
||||||
|
to read [Supported Boards](https://docs.zephyrproject.org/latest/boards/index.html)
|
||||||
|
section in the Zephyr documentation for more information about
|
||||||
|
Zephyr's support for a particilar board, means to flash binaries,
|
||||||
|
etc.
|
||||||
|
|
||||||
```
|
```
|
||||||
# assume you are in harmony folder
|
# assuming you are in top-level folder
|
||||||
cd jerryscript
|
cd jerryscript
|
||||||
make -f ./targets/zephyr/Makefile.zephyr BOARD=arduino_101
|
make -f ./targets/zephyr/Makefile.zephyr BOARD=frdm_k64f
|
||||||
```
|
```
|
||||||
|
|
||||||
This will generate the following libraries:
|
At the end of the build, you will be given a path to and stats about
|
||||||
```
|
the ELF binary:
|
||||||
./build/arduino_101/librelease-cp_minimal.jerry-core.a
|
|
||||||
./build/arduino_101/librelease-cp_minimal.jerry-math.lib.a
|
|
||||||
./build/arduino_101/librelease.external-cp_minimal-entry.a
|
|
||||||
```
|
|
||||||
|
|
||||||
The final Zephyr image will be located here:
|
|
||||||
```
|
|
||||||
./build/arduino_101/zephyr/zephyr.strip
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 5. Flashing
|
|
||||||
|
|
||||||
Details on how to flash the image can be found here:
|
|
||||||
[Flashing image](https://www.zephyrproject.org/doc/board/arduino_101.html)
|
|
||||||
(or similar page for other supported boards).
|
|
||||||
|
|
||||||
To be able to use this demo in hardware you will need the serial console
|
|
||||||
which will be generating output to Pins 0 & 1.
|
|
||||||
|
|
||||||
You will need a 3.3v TTL to RS232, please follow the zephyr documentation on it.
|
|
||||||
|
|
||||||
Some examples of building the software
|
|
||||||
|
|
||||||
```
|
```
|
||||||
make -f ./targets/zephyr/Makefile.zephyr BOARD=<board> clean
|
...
|
||||||
|
Finished
|
||||||
|
text data bss dec hex filename
|
||||||
|
117942 868 24006 142816 22de0 build/frdm_k64f/zephyr/zephyr/zephyr.elf
|
||||||
```
|
```
|
||||||
|
|
||||||
- Not using a Jtag and having a factory stock Arduino 101.
|
Flashing the binary depends on a particular board used (see links above).
|
||||||
You can follow the Zephyr instructions to flash using the dfu-util command
|
For the FRDM-K64F used as the example, you should copy the *raw* binary
|
||||||
or use this helper:
|
file corresponding to the ELF file above (at
|
||||||
|
`build/frdm_k64f/zephyr/zephyr/zephyr.bin`) to the USB drive appearing
|
||||||
|
after connecting the board to a computer:
|
||||||
|
|
||||||
```
|
```
|
||||||
make -f ./targets/zephyr/Makefile.zephyr BOARD=arduino_101 dfu-x86
|
cp build/frdm_k64f/zephyr/zephyr/zephyr.bin /media/pfalcon/DAPLINK/
|
||||||
```
|
```
|
||||||
|
|
||||||
Make sure you have the factory bootloader in your device to use this method or it will not flash.
|
To interact with JerryScript, connect to a board via serial connection
|
||||||
|
and press Reset button (you first should wait while LEDs on the board
|
||||||
- Using JTAG
|
stop blinking). For `frdm_k64f`:
|
||||||
|
|
||||||
There is a helper function to flash using the JTAG and Flywatter2
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
```
|
```
|
||||||
make -f ./targets/zephyr/Makefile.zephyr BOARD=arduino_101 flash
|
picocom -b115200 /dev/ttyACM0
|
||||||
```
|
```
|
||||||
|
|
||||||
<warning> Careful if you flash the BOARD arduino_101, you will lose the bootloader
|
|
||||||
and you will have to follow the zephyr documentation to get it back from
|
|
||||||
the backup we all know you did at the setup. </warning>
|
|
||||||
|
|
||||||
#### 6. Serial terminal
|
|
||||||
|
|
||||||
Test command line in a serial terminal.
|
|
||||||
|
|
||||||
|
|
||||||
You should see something similar to this:
|
You should see something similar to this:
|
||||||
```
|
```
|
||||||
JerryScript build: Aug 12 2016 17:12:55
|
JerryScript build: Aug 11 2021 16:03:07
|
||||||
JerryScript API 1.0
|
JerryScript API 3.0.0
|
||||||
Zephyr version 1.4.0
|
Zephyr version 2.6.99
|
||||||
js>
|
js>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
Run the example javascript command test function
|
Run the example javascript command test function
|
||||||
```
|
```
|
||||||
js> var test=0; for (t=100; t<1000; t++) test+=t; print ('Hi JS World! '+test);
|
js> var test=0; for (t=100; t<1000; t++) test+=t; print ('Hi JS World! '+test);
|
||||||
Hi JS World! 494550
|
Hi JS World! 494550
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
Try a more complex function:
|
Try a more complex function:
|
||||||
```
|
```
|
||||||
js> function hello(t) {t=t*10;return t}; print("result"+hello(10.5));
|
js> function hello(t) {t=t*10;return t}; print("result"+hello(10.5));
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
CONFIG_BUILD_OUTPUT_BIN=y
|
CONFIG_BUILD_OUTPUT_BIN=y
|
||||||
CONFIG_STDOUT_CONSOLE=y
|
CONFIG_STDOUT_CONSOLE=y
|
||||||
CONFIG_NEWLIB_LIBC=y
|
CONFIG_NEWLIB_LIBC=y
|
||||||
CONFIG_FLOAT=y
|
CONFIG_FPU=y
|
||||||
CONFIG_MAIN_STACK_SIZE=2048
|
CONFIG_MAIN_STACK_SIZE=2048
|
||||||
CONFIG_CONSOLE_HANDLER=y
|
CONFIG_CONSOLE_HANDLER=y
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <zephyr.h>
|
#include <zephyr.h>
|
||||||
#include <uart.h>
|
#include <drivers/uart.h>
|
||||||
#include <drivers/console/console.h>
|
#include <drivers/console/console.h>
|
||||||
#include <drivers/console/uart_console.h>
|
#include <drivers/console/uart_console.h>
|
||||||
#include "getline-zephyr.h"
|
#include "getline-zephyr.h"
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <zephyr.h>
|
#include <zephyr.h>
|
||||||
#include <misc/printk.h>
|
#include <sys/printk.h>
|
||||||
#include "getline-zephyr.h"
|
#include "getline-zephyr.h"
|
||||||
|
|
||||||
#include "jerryscript.h"
|
#include "jerryscript.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user