• This repository has been archived on 05/Aug/2022
  • Stars
    star
    176
  • Rank 209,322 (Top 5 %)
  • Language
    C
  • License
    Other
  • Created almost 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

JavaScript* Runtime for Zephyr* OS

DISCONTINUATION OF PROJECT.

This project will no longer be maintained by Intel.

Intel has ceased development and contributions including, but not limited to, maintenance, bug fixes, new releases, or updates, to this project.

Intel no longer accepts patches to this project.

If you have an ongoing need to use this project, are interested in independently developing it, or would like to maintain patches for the open source software community, please create your own fork of this project.

JavaScript* Runtime for Zephyr™ OS

The JavaScript* Runtime for the Zephyr™ OS project (ZJS for short) provides an IoT web runtime environment with JavaScript APIs for the Zephyr operating system, based on the JerryScript engine. It is intended for systems with little memory where Node.js with V8 is too big.

This code requires a local copy of JerryScript and Zephyr OS source. We will upstream patches to those projects as appropriate, but this repo is for everything else.

Index

Getting Started

ZJS should work on most of the boards supported by the Zephyr OS, though it does have higher memory / flash requirements so it won't work on the very smallest boards. So far we've had our hands on these boards: Arduino 101 / tinyTILE, FRDM-K64F, nRF52-DK, Arduino Due, NUCLEO-F411RE, STM32F4DISCOVERY, 96Boards Carbon, and OLIMEX STM32 E407. Please do try it with any other boards Zephyr supports and let us know what works and what doesn't.

Up until recently, the Web IDE which makes ZJS development very easy only worked on Arduino 101. So the following instructions are still specific to Arduino 101 but we'll try to update them soon; until then please ask for help on IRC if you have questions about working with a particular board.

This section will walk you through building and running your first ZJS application on Arduino 101*.

Prerequisites

Developing with the Web-based IDE

The easiest way to develop your JavaScript app on Zephyr is using our Web-based IDE which allows you to write JS apps on the fly in our online editor and upload them directly to the Arduino 101 board through WebUSB. Please follow our Zephyr Project JavaScript & WebIDE Tutorial to get started with the Web IDE and check out the ashell guide for more advanced usages.

Zephyr Project JavaScript & WebIDE Tutorial

Classical 'Build and Flash' development

Initial Setup

Windows and OSX users: These instructions are for Ubuntu 16.04. Be sure to also consult Zephyr Project's Getting Started documentation for Windows or OSX.

Install dependencies

First, install these packages that you will need beyond those installed by default with Ubuntu:

sudo apt update
sudo apt install cmake dfu-util git python3-yaml screen uglifyjs

Note: python3-yaml is a recent requirement for the frdm-k64f build due to a change in Zephyr, so it could be left out currently if you don't use k64f. Before that, for a while python-yaml was needed when the script was using Python 2.

You may also need to install pip3 to get pyelftools:

$ sudo apt install python3-pip
$ sudo pip3 install pyelftools

Clone the ZJS repo

Next, clone this git repo:

git clone http://github.com/intel/zephyr.js.git

Check out the desired version

If you want to use a stable release version, the latest is 0.5:

git checkout v0.5

If you do nothing and remain on master, you will be looking at the very latest changes which may have regressions or instability. You can read the version file in the root of the source tree to see what version you're on. If you're on the master development branch it will just say 'devel'.

Install the Zephyr SDK

Download the latest Zephyr SDK, then:

chmod +x /path/to/zephyr-sdk-<VERSION>-setup.run
sudo /path/to/zephyr-sdk-<VERSION>-setup.run

Follow the prompts, but the defaults should be fine.

Set up Zephyr SDK environment variables

Add the following two lines to your ~/.bashrc. If you installed your Zephyr SDK elsewhere, adjust as needed.

export ZEPHYR_GCC_VARIANT=zephyr
export ZEPHYR_SDK_INSTALL_DIR=/opt/zephyr-sdk

Then source the .bashrc :

source ~/.bashrc

Join the plugdev group

Add your user to the plugdev group with this command:

sudo usermod -a -G plugdev USERNAME

Add udev rules

Copy these two files into your /etc/udev/rules.d directory (/etc/udev.rules for Ubuntu 14.04):

Then run this command:

sudo udevadm control --reload-rules

This should cause your /dev/tty* entries to have the plugdev group, which will let you use them without root privileges. Otherwise, you will have to run some of the following commands with sudo.

Shell setup

Whenever you open a new terminal to work with this repo, you need to set up environment variables.

Set up ZJS environment variables

First, the ZJS variables:

cd zephyr.js
source zjs-env.sh

Get source dependencies

Next, this command will check out additional git repos into the deps/ subdirectory, if you haven't done so before:

make update

(If this is the first time you've run this, will see an error.)

Set up Zephyr OS environment variables

As the previous command will complain, you need to set up some Zephyr OS environment variables, too. Here's the right way to do that:

source deps/zephyr/zephyr-env.sh

Note: cmake 3.8.2 or later is required, and your system might install an older version, if this is the case, you'll have to manually install the latest version of cmake:

$ mkdir $HOME/cmake && cd $HOME/cmake
$ wget https://cmake.org/files/v3.8/cmake-3.8.2-Linux-x86_64.sh
$ yes | sh cmake-3.8.2-Linux-x86_64.sh | cat
$ echo "export PATH=$PWD/cmake-3.8.2-Linux-x86_64/bin:\$PATH" >> $HOME/.zephyrrc
$ source $ZJS_ROOT/deps/zephyr/zephyr-env.sh
$ cmake --version

Build and Flash

x86 application image and ARC support image

Now you're ready to build the x86 and ARC images. The x86 image includes the JerryScript engine and the ZJS runtime support, along with your JavaScript application, and the ARC support image acts as a helper library that channels some of the data needed from the ARC processor to the x86 processor.

Note: you'll need to build both the x86 and ARC images with the same JS file so the required sub-modules are enabled on both images.

You can build both with a single command:

make JS=samples/TrafficLight.js

The JS= argument lets you provide the path to your application. The TrafficLight sample is a good first choice because you don't need to wire up any additional hardware. It just blinks onboard LEDs on your Arduino 101. Also, for many of the samples you will want to hook up the serial console (see below), but for this one it's not really needed.

Then connect the Arduino 101 to your host with a USB A/B cable. Press the Master Reset button on the Arduino 101 and within a few seconds type:

make dfu

This will flash both the images to the device using the dfu-util program.

If you get a permission error, make sure you followed the plugdev group instructions above for this user. You shouldn't need to run this command with sudo.

After this flashing completes successfully, reboot the device with the Master Reset button to start the application. After a few seconds the onboard LEDs should start cycling.

You have built and run your first ZJS application!

If you want to make changes to the application, or run a different .js sample, you just need to repeat the steps the desired JavaScript filename.

Next steps

Set up serial console

Without the serial console set up, you won't be able to see error messages and other output from your ZJS application. To hook up the serial console, you need a USB to TTL Serial Cable, such as the TTL-232R-3V3. On that particular cable, you wire the black wire to ground on the Arduino 101 board, the orange wire to GPIO pin 0 (RX), and the yellow wire to GPIO pin 1 (TX). The other three are unused.

When you plug this in, the device should show up as something such as /dev/ttyUSB0. You can then use the screen command to connect to the device with a command such as this:

watch screen /dev/ttyUSB0 115200

The watch utility will restart screen when you disconnect and reconnect your Arduino 101, so you shouldn't miss anything. You can leave a dedicated terminal running to watch the output.

In screen, you can scroll back the output with Ctrl-A, Esc, followed by PgUp/PgDn. Then Esc again to get back to the latest output (out of "Copy Mode").

Debugging

Debugging native C code

See Zephyr's supported boards documentation for information on debugging with a specific board. For the Arduino 101, ZJS has special make targets: use the commands make adebug and make agdb in two separate terminals to connect to the device with a debugger. Then you can set breakpoints such as b main and run to start debugging as usual with gdb.

Debugging JavaScript code

JerryScript has a built-in remote debugger which allows debugging JavaScript programs. At the moment only a Websocket-based implementation is provided by JerryScript which transmits messages over TCP/IP networks, but it currently only supports ethernet, so you'll need to run it on a board that has ethernet support, for example, the FRDM-K64F or Linux.

To enable the remote debugger for a particular JS application:

make BOARD=frdm_k64f DEBUGGER=on JS=xxx.js

When you flash and run the JS application, it will start in debugging mode, running on 192.168.1.101:5001, and you will see the following on serial output:

Debugger mode: connect using jerry-client-ws.py

Waiting for client connection

you might need to add a route on your PC to connect to the network if you are connecting the board directly to your PC:

ip route add 192.168.1/24 dev eno1

Then you can use the jerryscript command line or html client to connect to the debugger to debug your JS application:

python jerryscript/jerry-debugger/jerry-client-ws.py --display 10 192.168.1.1

In the client, type 'help' to get a list of debugger commands, such as adding breakpoints, stepping through JS sources, etc.

Alternatively, we've created a client that integrates with Chome DevTools, which lets you use the Chrome's built-in debugger to connect and you can use it to set breakpoints and step through source from all within the browser. Please see installation instructions on how to set it up from here

Debugging JavaScript code on Linux:

To enable the remote debugger on Linux:

make BOARD=linux DEBUGGER=on
outdir/linux/release/jslinux app.js --debugger

It will then be run on debugger mode waiting for client connection, you can then in another terminal, you can connect to it by running the python client in JerryScript:

python jerryscript/jerry-debugger/jerry-client-ws.py --display 10 localhost

Additional details

See below for a few more tips, such as increasing the space available for your application on the Arduino 101, or how to use ZJS with the FRDM-K64F.

Getting more space on your Arduino 101

Arduino 101 comes with a 144K X86 partition, but we're able to use more space by telling Zephyr there is more space and then splicing the images we flash to the device. You can control this with the ROM= flag to make. So if you want to allocated 256KB for x86, use ROM=256.

You can also just build without it until you see a message like this:

lfiamcu/5.2.1/real-ld: region `ROM' overflowed by 53728 bytes

That implies you need an extra 53K of space, so you could try passing ROM=200. If it's the ARC image that needs more space, you should decrease the ROM you're passing instead.

Note: Earlier, we would physically repartition the device and install a new bootloader that knew about it. This is no longer necessary, so if you have such a device you should restore it to factory condition with the 256-to-144 flashpack.

You can also influence the amount of RAM allocated to the X86 side with a new RAM= argument. Here the default is 55 but it can theoretically go as high as 79 if ARC was disabled; realistically up to maybe 75 or so depending on how few modules you require in the ARC build.

The RAM and ROM sizes being used are now displayed at the top of the make output when you do build for Arduino 101.

JS Minifier

To save space it is recommended to use a minifier. In convert.py, the script used to encode your JS into a source file, we use uglifyjs. If you didn't install this earlier, you can do so with the command:

sudo apt install node-uglify

Other HW Platforms

nRF52 Platform

This is an experimental ZJS platform and has not been tested. There should be no expectation that any given sample/test/application will work at all on this platform. The good news is that there have been ZJS networking samples run on the nRF52 board with success therefore we mention it here so anyone can try it out and contribute fixes to anything that does not work, potentially getting it stable enough to adopt as a supported board in the future. The nRF52 board we have tested is nRF52 DK (nrf52_pca10040). Please see Zephyr's project page to see the supported nRF5x variant boards, since each board will have different instructions to flash. To flash to the nRF52 DK, you'll need to downloand and install the JLink Software and Documentation Pack and the nRF5x command-line tools.

See the Zephyr docs for general information about running Zephyr OS on the nRF52.

Connecting to serial output is quite similar to the Arduino 101, except the nRF52 will have an ACM port rather than USB. You can connect with minicom by doing:

minicom -D /dev/ttyACM0

Building is the same as any other ZJS platform, just use nrf52_pca10040 as the BOARD name:

make JS=samples/HelloWorld.js BOARD=nrf52_pca10040

You should now have a Zephyr binary in outdir/nrf52_pca10040/. You can flash it to the nRF52 DK board with the nRF5x command line tools:

  1. Connect the micro-USB cable to the nRF52 DK and to your computer and turn on the power switch.

  2. Erase the flash memory in the nRF52832:

$ nrfjprog --eraseall -f nrf52
  1. Flash the application using the nrfjprog tool:
$ nrfjprog --program outdir/nrf52_pca10040/zephyr.hex -f nrf52

You should see the lights flashing on the nRF52 board. When it stops you can reset the board and you should see your application output on /dev/ttyACM0. If you don't see any output, try pressing the BOOT/RESET button next to the power switch to boot it again.

From here the device can be connected with BLE to a Linux machine as you do with an Arduino 101.

FRDM-K64F Platform

See the Zephyr docs for general information about running Zephyr OS on the FRDM-K64F.

The instructions below assume Ubuntu 14.04 on the host PC.

Connect a micro-USB cable from the device to your PC.

If you hit the Reset switch and wait about five seconds, you should be able to start up a serial console. Either:

screen /dev/ttyACM0 115200

or

minicom -D /dev/ttyACM0

(I typically had to try either command several times before it would work.) The benefit of minicom is it will keep running even if you unplug the cable and then plug it back in later.

Check your dmesg output or watch your /dev directory to know what device it shows up as.

Then, follow these instructions to update your firmware.

Next, you can try to build ZJS for the platform:

make BOARD=frdm_k64f JS=samples/HelloWorld.js
cp outdir/frdm_k64f/zephyr/zephyr.bin /media/<USERNAME>/MBED/

After you copy the new .bin file to that directory, the device will reboot, blink an LED quickly as it writes the image, and then you should see the device reconnect as a USB storage device to your PC. Then you can press the Reset button to run the Zephyr image. You should see "Hello, ZJS world!" output on the serial console in less than a second.

If something doesn't work, you may want to establish that you're able to upload the K64F hello world application.

Then, you could try the Zephyr OS hello_world sample to narrow down the problem:

cd deps/zephyr/samples/hello_world/
mkdir build && cd build
cmake -DBOARD=frdm_k64f ..
make
cp zephyr/zephyr.bin /media/<USERNAME>/MBED/

Using the same procedure as above, once you hit Reset you should see "Hello World!" within a second on your serial console.

ST STM32F4DISCOVERY Platform

See the Zephyr Project Wiki for general information about running Zephyr OS on the STM32F4DISCOVERY.

Building is the same as any other ZJS platform, just use stm32f4_disco as the BOARD name:

make BOARD=stm32f4_disco ide

You should now have a Zephyr binary in outdir/stm32f4_disco/. You can flash it to the STM32F4DISCOVERY board with the openocd:

  1. Connect the Mini USB cable from the device(CN1) to your PC.

  2. Connect a micro-USB cable from the device (CN5) to your PC.

  3. Flash the application using the following command:

make BOARD=stm32f4_disco flash

You should see the lights flashing on the STM32F4DISCOVERY board. When it stops you should see WebIDE url notification from Chrome.

From here the device can be connected with WebIDE and upload JS code to the device.

OLIMEX-STM32-E407 Platform

See the Zephyr Project Wiki for general information about running Zephyr OS on the OLIMEX-STM32-E407.

Building is the same as any other ZJS platform, just use olimex_stm32_e407 as the BOARD name:

make BOARD=olimex_stm32_e407 ide

You should now have a Zephyr binary in outdir/olimex_stm32_e407/. You can flash it to the OLIMEX-STM32-E407 board with the openocd:

  1. Connect the ST-Link USB dongle to your host computer and to the JTAG port of the OLIMEX-STM32-E407 board.
  2. Connect the Mini USB cable to the device(OTG1 near LAN connector) to your PC.
  3. Flash the application using the following command:
make BOARD=olimex_stm32_e407 flash

You should see the lights flashing on the ST-Link USB dongle. When it stops you should see WebIDE url notification from Chrome.

From here the device can be connected with WebIDE and upload JS code to the device.

Running the JS app on Linux or Mac

Building and running on Linux

In addition to Zephyr there is a "linux" target which does not use Zephyr at all and instead uses the host OS. This can be built on Linux or MacOS using the command:

make BOARD=linux

The executable will be outputted to outdir/linux/<variant>/jslinux. Where <variant> is either debug or release. This is specified the same as the Zephyr target by passing in VARIANT= when running make. The default is release.

Note: To build on MacOS using BOARD=linux, see instructions in the next section.

What makes the linux target convenient is that a JS script does not have to be bundled with the final executable. By default samples/HelloWorld.js will be bundled but you can always just pass in a script on the command line when running jslinux e.g.:

./outdir/linux/release/jslinux samples/Timers.js

If a script is passed in on the command line it will take the priority over any script bundled with the executable (using JS=).

By default jslinux will exit when there are no pending events but if this is not desired, there are two flags which can be used to cause jslinux to run longer (or forever). The first is the --noexit flag. If this flag is used, jslinux will run indefinitely. The second flag (-t) will cause jslinux to run until a specified timeout (in milliseconds) is met. This flag can be used like:

./outdir/linux/release/jslinux -t <ms>

It should be noted that the Linux target has only very partial support to hardware compared to Zephyr. This target runs the core code, but most modules do not run on it, specifically the hardware modules (AIO, I2C, GPIO etc.). There are some modules which can be used though like Events, Promises, Performance an OCF. This list may grow if other modules are ported to the Linux target.

Building and running on MacOS

Mac support is still limited at this point. As Zephyr does not provide the SDK/toolchain to compile on MacOS natively, you will have to build your own or use a 3rd-party toolchain. Currently the targets we support building on Mac are "linux", "qemu_x86", with limited support for "arduino_101" and "frdm-k64f" boards. You'll need to have a recent version of MacOS and XCode command line tools from App store to get you started. Depending on your system setup and target, you might have to perform additional steps, but if you run into build issues, you should first make sure that you can build Zephyr native apps on Mac using the toolchain you installed. Once you verify that it works, then our project should also build and link correctly, but we'll try to update the document as we find these kinds of issues. Currently we enable Travis CI to build the linux target only against a recent version of MacOS (10.12) and XCode Command Line Tools (provided by XCode SDK) for sanity check purposes.

Set up

The basic requirement for building Zephyr boards is that you'll need to install and setup the correct cross-compiler toolchain on your Mac for the boards you are trying to build. You need to install crosstool-ng, which allows you to build the x86 images you can run on QEMU, and for Arduino 101, you need to install the ARC compiler, which can be found by installing the Arduino IDE for Mac, this is used to build the ARC support image.

Requirements:

  • MacOS 10.12 (Sierra) or later
  • XCode Command Line Tools: 8.1 or later (clang)
  • Python: 2.7 or later
  • Homebrew
  • Crosstool-ng
  • ARC cross-compiler (for building Arduino 101)
  • Python-yaml

First, make sure you have Homebrew installed, instructions here, and then install the following brew packages:

brew install cmake ninja dfu-util doxygen qemu dtc python3 gperf

Install tools needed for building the toolchain:

brew install binutils gawk gettext help2man mpfr gmp coreutils wget
brew tap homebrew/dupes
brew install grep --with-default-names
brew install gnu-sed

If you have installed these packages before, make sure you update to the latest:

brew update
brew upgrade

Next, you'll need to update to the latest MacOS and install/upgrade to the latest XCode Command Line Tools (we tested MacOS Sierra 10.12 and XCode 9.1) from App store.

To install XCode Command Line Tools, open a terminal and type the following, it should pop up a window to ask you to install the tools:

xcode-select --install

You'll then set up the environment variables:

cd zephyr.js
source zjs-env.sh
make update
source deps/zephyr/zephyr-env.sh

Install Zephyr dependencies:

curl -O 'https://bootstrap.pypa.io/get-pip.py'
sudo python ./get-pip.py
rm get-pip.py
cd deps/zephyr
pip3 install --user -r scripts/requirements.txt

Build Kconfig in $ZEPHYR_BASE/build and add it to path

brew install gtk+ libglade
cd $ZEPHYR_BASE
mkdir build && cd build
cmake ../scripts
make
echo "export PATH=$PWD/kconfig:\$PATH" >> $HOME/.zephyrrc
source $ZEPHYR_BASE/zephyr-env.sh

Note: You only need to do this once after cloning the git repository.

Building Linux target

You can build the "linux" target on MacOS using BOARD=linux, follow instructions for "Building and running on Linux". This will create the jslinux ouput.

Building QEMU and Arduino 101 targets

You can build QEMU with BOARD=qemu_x86 and Arduino 101 with BOARD=arduino_101, you'll need to install crosstool-ng (1.23 or later) and ARC compiler from Arduino IDE.

Install crosstool-ng:

wget http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.23.0.tar.bz2
tar xvf crosstool-ng-1.23.0.tar.bz2
cd crosstool-ng-1.23.0/
./configure
make
make install

After installing crosstool-ng, create and mount the image using our script osxmountzephyr.sh:

osxmountzephyr.sh

Once you've created the image the first time, you can subsequently re-mount and un-mount the images with:

hdiutil mount CrossToolNG.sparseimage
diskutil umount force /Volumes/CrossToolNG

This will create an image mounted under /Volumes/CrossToolNG. You can then configure crosstool-ng:

cd /Volumes/CrossToolNG
mkdir build
cd build

In the Zephyr kernel source tree we provide configurations that can be used to preselect the options needed for building the toolchain.

The configuration files can be found in $ZEPHYR_BASE/scripts/cross_compiler/.

Currently the following configurations are provided:

i586.config: for standard ABI, for example for Galileo and qemu_x86 iamcu.config: for IAMCU ABI, for example for the Arduino 101

(replace i586.config with iamcu.config for Arduino 101)
cp ${ZEPHYR_BASE}/scripts/cross_compiler/i586.config .config
ct-ng oldconfig

After you are done, edit the generated .config, and make sure you have these settings, or you will run into build errors later:

...
CT_LOCAL_TARBALLS_DIR="/Volumes/CrossToolNG/src"
# CT_SAVE_TARBALLS is not set
CT_WORK_DIR="${CT_TOP_DIR}/.build"
CT_BUILD_TOP_DIR="${CT_WORK_DIR}/${CT_HOST:+HOST-${CT_HOST}/}${CT_TARGET}"
CT_PREFIX_DIR="/Volumes/CrossToolNG/x-tools/${CT_TARGET}"
CT_INSTALL_DIR="${CT_PREFIX_DIR}"
# Following options prevent link errors
CT_WANTS_STATIC_LINK=n
CT_CC_STATIC_LIBSTDCXX=n
...

If you experience issue building Cross GDB at the end, you can ignore it or comment out the following:

# CT_GDB_CROSS=y

Now you can build crosstool-ng. It will take 20~30 mins:

ct-ng build

When finished, you should have the toolchain setup in /Volumes/CrossToolNG/x-tools directory. now go back to the project's directory and set some environment variables:

export ZEPHYR_GCC_VARIANT=xtools
export XTOOLS_TOOLCHAIN_PATH=/Volumes/CrossToolNG/x-tools

To use the same toolchain in future sessions, you can set the variables in the file $HOME/.zephyrrc. For example:

cat <<EOF > ~/.zephyrrc
export XTOOLS_TOOLCHAIN_PATH=/Volumes/CrossToolNG/x-tools
export ZEPHYR_GCC_VARIANT=xtools
EOF

For a new environment, create a symlink for Python2.7:

ln -s /usr/bin/python2.7 /usr/local/bin/python2

Now, you can build and run on QEMU using this command:

make JS=samples/HelloWorld.js BOARD=qemu_x86 qemu

You should see output (To exit from QEMU enter: 'CTRL+a, x') :

SeaBIOS (version rel-1.11.0-0-g63451fca13-prebuilt.qemu-project.org)
Booting from ROM..
Hello, ZJS world!

Note: There are currently some cmake issues and crosstool-ng using the latest Zephyr (1.10.0), and here are some of the work-arounds.

If you see an compile error like:

No such file or directory: CMAKE_READELF:
'/Volumes/CrossToolNG/x-tools/i586-zephyr-elfiamcu/bin/i586-zephyr-elfiamcu-readelf'

edit ${ZEPHYR_BASE}/cmake/toolchain-xtools.cmake and change the line:

set(CROSS_COMPILE_TARGET_x86 i586-zephyr-elfiamcu)

to

set(CROSS_COMPILE_TARGET_x86 i586-zephyr-elf)

and append the following line:

set(TOOLCHAIN_INCLUDES ${TOOLCHAIN_HOME}/${CROSS_COMPILE_TARGET}/${CROSS_COMPILE_TARGET}/include)

If you see a QEMU error like, it could be the qemu package on your system were installed to /usr/local/share/ :

qemu-system-i386: -L -bios: Could not open 'bios.bin': No such file or directory

edit ${ZEPHYR_BASE}/boards/x86/qemu_x86/board.cmake and change the line:

-L ${QEMU_BIOS}

to

-L /usr/share/local/qemu

To build for Arduino 101, you'll need to download the latest Arduino IDE here. Once you have the IDE installed, open the IDE and click on Tools->Board->Board Manager, and install the latest version of the board support package "Intel Curie Boards". This will install the arc-elf compiler located in the following directory:

$HOME/Library/Arduino15/packages/Intel/tools/arc-elf32/

Then copy the compiler to where you installed the crosstool-ng toolchain:

cp -pR $HOME/Library/Arduino15/packages/Intel/tools/arc-elf32 /Volumes/CrossToolNG/

The compiler is in a subdirectory, such as 1.6.9+1.0.1. You'll need to set this path in cmake to make to find the right bin file.

Edit deps/zephyr/cmake/toolchain-xtools.cmake, and change the following:

set(CROSS_COMPILE ${TOOLCHAIN_HOME}/${CROSS_COMPILE_TARGET}/bin/${CROSS_COMPILE_TARGET}-)

to

set(CROSS_COMPILE /Volumes/CrossToolNG/arc-elf32/1.6.9+1.0.1/bin/arc-elf32-)

You can now build for Arduino 101 (without setting BOARD=, it builds arduino_101 by default)

make JS=samples/HelloWorld.js

Note: There's currently a bug that you'll run into a build issue when buiding for the Arduino 101 using the latest Zephyr (1.10.). See bug

Other targets like FRDM-K64F or possibly other ARM boards on Mac

These also have limited support currently. The requiremenet is that you'll need to install the GCC ARM Embedded cross compiler here

After you download it, set these environment variables:

export GCCARMEMB_TOOLCHAIN_PATH="/Users/<USERNAME>/Downloads/gcc-arm-none-eabi-6-2017-q1-update"
export ZEPHYR_GCC_VARIANT=gccarmemb

Then you can build like this:

make JS=samples/HelloWorld.js BOARD=frdm_k64f CROSS_COMPILE=~/Downloads/gcc-arm-none-eabi-6-2017-q1-update/bin/arm-none-eabi-

For additional information, see here on how to setup third-party compilers.

Supported modules on Linux and Zephyr

See board summary for some basic comparison information about the boards we've tested on.

There is only partial support for modules on Linux compared to Zephyr. Any hardware specific module (I2C, UART, GPIO, ADC etc.) is not supported on Linux. Trying to run a Zephyr specific module on Linux will result in the JavaScript not running successfully. Below is a complete table of modules and target support. Some Zephyr targets listed are experimental and have not been fully tested. For this reason we have the following possibilities for support:

  • X - Supported
  • E - Experimental, not formally tested by QA but basic functionality verified.
  • NT - Not tested at all
  • Blank - Not Supported
Module Linux A101/tT K64F nRF52 Due F411RE STM32F4 OLIMEX E407 Carbon
HelloWorld X X X X X X X X X
ADC X X
BLE X X
Buffer X X X X X X X X X
Console X X X X X X X X X
Dgram X X
Event X X X X X X X X X
File System X X
GPIO X X
I2C X X
Net X X
OCF X X X NT
Performance X X X X X X X X X
PME X
PWM X
Sensor X X
Timers X X X X X X X X X
UART X NT
WebSocket X X
WebUSB X

Networking with QEMU

QEMU has support for networking features that can be tested on your Linux desktop. To do this you will need to build a separate "net-tools" project:

git clone https://github.com/zephyrproject-rtos/net-tools
cd net-tools
make

If the build fails, you may need to install the libpcap-dev package:

sudo apt install libpcap-dev

Open up 2 terminals to run the tools from the net-tools directory: Terminal 1:

./loop-socat.sh

If this fails, you may need to install the socat package:

sudo apt install socat

Terminal 2:

sudo ./loop-slip-tap.sh

Then run QEMU as your normally would e.g.

make BOARD=qemu_x86 JS=samples/OcfServer.js qemu

Note: At this point, this setup is relatively unstable. You may experience crashes or things just not working in general. If the behavior does not seem normal you can usually fix it by restarting the two scripts and running QEMU again.

The original instructions document can be found on the Zephyr website here

Networking with BLE

It is possible to use IP networking over BLE using 6LowPAN. This is explained in a dedicated document.

Specific Device Support

ENC28J60 Ethernet Board

This SPI Ethernet board is now supported for use with the Arduino 101. To configure it, wire IO10-IO13 (the SPI pins) to CS, SI, SO, SCK on the board, respectively. Then wire VCC to 3.3V power (somewhere online I saw a reference that some of these boards tolerate 5V and some do not) and GND to ground. Finally, wire INT on the board to pin IO4; this is a GPIO used to communicate with the board as well.

Then when building a networking application, use FORCE=zjs_net_l2_enc28j60.json on your make command line to override the default Bluetooth/6LoWPAN networking.

For a simple test configuration, connect the Ethernet port to a secondary Ethernet on your host PC (I use a USB Ethernet device). Configure that interface on your PC with static IPv4 or IPv6 addresses that work with what's configured on the device. With the TCPEchoServ[46].js samples at present, you would use something like 192.168.201.2 w/ 255.255.255.0 mask for IPv4, and 2001:db8::2 w/ 64 prefix for IPv6.

(The simple board doesn't do auto-crossover detection so if your host Ethernet adapter doesn't either, you may need to use a crossover cable or hook them both up to a dedicated switch as I've done.)

Contributing

If you want to contribute code to the ZJS project, first you need to fork the project. The next step is to send a pull request (PR) for review to the ZJS repository. The PR will be reviewed by the project team members. You need at least two plus-ones (+1) , "Look Good To Me (LGTM)" or other positive signals for the project members. Once you have gained the required signals the project maintainers will merge the PR.

To report a security issue, please follow the procedure described here.

Travis and local sanity checking

We run a series of tests on each pull request and merged commit using Travis. This relies on a script in the repo called trlite. One easy way to run these tests on your local $ZJS_BASE git tree is to use make check or make quickcheck for a faster subset of the tests. These run with your code as it stands in your tree. This will not catch a problem like you failing to add a new file to your commit.

For a slightly safer sanity check, which might catch that kind of problem, you can run trlite directly or trlite linux for the "quick subset". This will clone a second copy of your git tree into a .trlite subdirectory, apply changes that git diff knows about, and run the build tests. Another option trlite -j will cause it to run four threads of tests to speed up execution; these will use four directories named .trlite[1-4]. If there is a test failure, the affected .trlite* trees are left in place so that you can investigate.

Repo Organization

File Descriptions

  • zjs-env.sh - Source this file to set environment variables and path to be able to use tools from scripts/ anywhere.
  • prj.conf - The main configuration file for a Zephyr application; overrides settings from a defconfig file in the Zephyr tree. In the ZJS builds, we assemble the prj.conf file at build time from other fragments.

Subdirectories

  • arc/ - Contains sensor subsystem code for ARC side of the Arduino 101.
  • cmake/ - Contains CMake build files for building Zephyr and JerryScript
  • deps/ - Contains dependency repos and scripts for working with them.
  • docs/ - Documentation in Markdown format (use API.md as index).
  • fragments/ - Contains project file fragments for project configuration.
  • modules/ - Contains different Javascript modules that can be loaded.
  • outdir/ - Directory generated by build, can be safely removed.
  • samples/ - Sample JavaScript files that can be built with make JS=.
  • scripts/ - Subdirectory containing tools useful during development.
  • src/ - JS API bindings for JerryScript written directly on top of Zephyr.
  • tests/ - JavaScript unit tests (incomplete).
  • tools/ - Helper utility for building JS using snapshot.

Zephyr is a trademark of the Linux Foundation. *Other names and brands may be claimed as the property of others.

More Repositories

1

hyperscan

High-performance regular expression matching library
C++
4,478
star
2

acat

Assistive Context-Aware Toolkit (ACAT)
C#
3,191
star
3

haxm

Intel® Hardware Accelerated Execution Manager (Intel® HAXM)
C
3,029
star
4

appframework

The definitive HTML5 mobile javascript framework
CSS
2,435
star
5

pcm

Intel® Performance Counter Monitor (Intel® PCM)
C++
2,083
star
6

neural-compressor

SOTA low-bit LLM quantization (INT8/FP8/INT4/FP4/NF4) & sparsity; leading model compression techniques on TensorFlow, PyTorch, and ONNX Runtime
Python
1,939
star
7

intel-extension-for-transformers

⚡ Build your chatbot within minutes on your favorite device; offer SOTA compression techniques for LLMs; run LLMs efficiently on Intel Platforms⚡
Python
1,910
star
8

intel-extension-for-pytorch

A Python package for extending the official PyTorch that can easily obtain performance on Intel platform
Python
1,203
star
9

linux-sgx

Intel SGX for Linux*
C++
1,180
star
10

scikit-learn-intelex

Intel(R) Extension for Scikit-learn is a seamless way to speed up your Scikit-learn application
Python
954
star
11

llvm

Intel staging area for llvm.org contribution. Home for Intel LLVM-based projects.
918
star
12

nemu

ARCHIVED: Modern Hypervisor for the Cloud. See https://github.com/cloud-hypervisor/cloud-hypervisor instead
C
915
star
13

compute-runtime

Intel® Graphics Compute Runtime for oneAPI Level Zero and OpenCL™ Driver
C++
912
star
14

caffe

This fork of BVLC/Caffe is dedicated to improving performance of this deep learning framework when running on CPU, in particular Intel® Xeon processors.
C++
845
star
15

isa-l

Intelligent Storage Acceleration Library
C
816
star
16

media-driver

C
783
star
17

cve-bin-tool

The CVE Binary Tool helps you determine if your system includes known vulnerabilities. You can scan binaries for over 200 common, vulnerable components (openssl, libpng, libxml2, expat and others), or if you know the components used, you can get a list of known vulnerabilities associated with an SBOM or a list of components and versions.
Python
721
star
18

intel-cmt-cat

User space software for Intel(R) Resource Director Technology
C
630
star
19

fastuidraw

C++
603
star
20

optimization-manual

Contains the source code examples described in the "Intel® 64 and IA-32 Architectures Optimization Reference Manual"
Assembly
602
star
21

libipt

libipt - an Intel(R) Processor Trace decoder library
C
594
star
22

libxcam

libXCam is a project for extended camera(not limited in camera) features and focus on image quality improvement and video analysis. There are lots features supported in image pre-processing, image post-processing and smart analysis. This library makes GPU/CPU/ISP working together to improve image quality. OpenCL is used to improve performance in different platforms.
C++
577
star
23

clDNN

Compute Library for Deep Neural Networks (clDNN)
C++
573
star
24

libva

Libva is an implementation for VA-API (Video Acceleration API)
C
558
star
25

intel-graphics-compiler

C++
503
star
26

wds

Wireless Display Software For Linux OS (WDS)
C++
496
star
27

thermal_daemon

Thermal daemon for IA
C++
485
star
28

x86-simd-sort

C++ header file library for high performance SIMD based sorting algorithms for primitive datatypes
C++
485
star
29

Intel-Linux-Processor-Microcode-Data-Files

466
star
30

gvt-linux

C
463
star
31

kernel-fuzzer-for-xen-project

Kernel Fuzzer for Xen Project (KF/x) - Hypervisor-based fuzzing using Xen VM forking, VMI & AFL
C
441
star
32

tinycbor

Concise Binary Object Representation (CBOR) Library
C
432
star
33

openfl

An open framework for Federated Learning.
Python
427
star
34

cc-oci-runtime

OCI (Open Containers Initiative) compatible runtime for Intel® Architecture
C
415
star
35

tinycrypt

tinycrypt is a library of cryptographic algorithms with a focus on small, simple implementation.
C
373
star
36

compile-time-init-build

C++ library for composing modular firmware at compile-time.
C++
372
star
37

ARM_NEON_2_x86_SSE

The platform independent header allowing to compile any C/C++ code containing ARM NEON intrinsic functions for x86 target systems using SIMD up to SSE4 intrinsic functions
C
369
star
38

yarpgen

Yet Another Random Program Generator
C++
357
star
39

intel-device-plugins-for-kubernetes

Collection of Intel device plugins for Kubernetes
Go
356
star
40

QAT_Engine

Intel QuickAssist Technology( QAT) OpenSSL Engine (an OpenSSL Plug-In Engine) which provides cryptographic acceleration for both hardware and optimized software using Intel QuickAssist Technology enabled Intel platforms. https://developer.intel.com/quickassist
C
356
star
41

linux-sgx-driver

Intel SGX Linux* Driver
C
334
star
42

safestringlib

C
328
star
43

xess

C
313
star
44

idlf

Intel® Deep Learning Framework
C++
311
star
45

ad-rss-lib

Library implementing the Responsibility Sensitive Safety model (RSS) for Autonomous Vehicles
C++
298
star
46

intel-vaapi-driver

VA-API user mode driver for Intel GEN Graphics family
C
289
star
47

ipp-crypto

C
269
star
48

rohd

The Rapid Open Hardware Development (ROHD) framework is a framework for describing and verifying hardware in the Dart programming language. ROHD enables you to build and traverse a graph of connectivity between module objects using unrestricted software.
Dart
256
star
49

opencl-intercept-layer

Intercept Layer for Debugging and Analyzing OpenCL Applications
C++
255
star
50

FSP

Intel(R) Firmware Support Package (FSP)
C
244
star
51

dffml

The easiest way to use Machine Learning. Mix and match underlying ML libraries and data set sources. Generate new datasets or modify existing ones with ease.
Python
241
star
52

intel-ipsec-mb

Intel(R) Multi-Buffer Crypto for IPSec
C
238
star
53

userspace-cni-network-plugin

Go
232
star
54

isa-l_crypto

Assembly
232
star
55

confidential-computing-zoo

Confidential Computing Zoo provides confidential computing solutions based on Intel SGX, TDX, HEXL, etc. technologies.
CMake
229
star
56

intel-extension-for-tensorflow

Intel® Extension for TensorFlow*
C++
226
star
57

bmap-tools

BMAP Tools
Python
220
star
58

ozone-wayland

Wayland implementation for Chromium Ozone classes
C++
214
star
59

intel-qs

High-performance simulator of quantum circuits
C++
202
star
60

SGXDataCenterAttestationPrimitives

C++
202
star
61

intel-sgx-ssl

Intel® Software Guard Extensions SSL
C
197
star
62

msr-tools

C
195
star
63

depth-camera-web-demo

JavaScript
194
star
64

CPU-Manager-for-Kubernetes

Kubernetes Core Manager for NFV workloads
Python
190
star
65

rmd

Go
189
star
66

asynch_mode_nginx

C
186
star
67

hexl

Intel®️ Homomorphic Encryption Acceleration Library accelerates modular arithmetic operations used in homomorphic encryption
C++
181
star
68

ros_object_analytics

C++
177
star
69

generic-sensor-demos

HTML
175
star
70

ipmctl

C
172
star
71

sgx-ra-sample

C++
171
star
72

lmbench

C
171
star
73

cri-resource-manager

Kubernetes Container Runtime Interface proxy service with hardware resource aware workload placement policies
Go
166
star
74

virtual-storage-manager

Python
164
star
75

PerfSpect

System performance characterization tool based on linux perf
Python
164
star
76

systemc-compiler

This tool translates synthesizable SystemC code to synthesizable SystemVerilog.
C++
155
star
77

webml-polyfill

Deprecated, the Web Neural Network Polyfill project has been moved to https://github.com/webmachinelearning/webnn-polyfill
Python
153
star
78

pmem-csi

Persistent Memory Container Storage Interface Driver
Go
151
star
79

libyami

Yet Another Media Infrastructure. it is core part of media codec with hardware acceleration, it is yummy to your video experience on Linux like platform.
C++
148
star
80

ros_openvino_toolkit

C++
147
star
81

rib

Rapid Interface Builder (RIB) is a browser-based design tool for quickly prototyping and creating the user interface for web applications. Layout your UI by dropping widgets onto a canvas. Run the UI in an interactive "Preview mode". Export the generated HTML and Javascript. It's that simple!
JavaScript
147
star
82

ideep

Intel® Optimization for Chainer*, a Chainer module providing numpy like API and DNN acceleration using MKL-DNN.
C++
145
star
83

libva-utils

Libva-utils is a collection of tests for VA-API (VIdeo Acceleration API)
C
144
star
84

gmmlib

C++
141
star
85

platform-aware-scheduling

Enabling Kubernetes to make pod placement decisions with platform intelligence.
Go
140
star
86

numatop

NumaTOP is an observation tool for runtime memory locality characterization and analysis of processes and threads running on a NUMA system.
C
139
star
87

ros2_grasp_library

C++
138
star
88

XBB

C++
133
star
89

tdx-tools

Cloud Stack and Tools for Intel TDX (Trust Domain Extension)
C
131
star
90

ros2_intel_realsense

This project is deprecated and no more maintained. Please visit https://github.com/IntelRealSense/realsense-ros for ROS2 wrapper.
C++
131
star
91

linux-intel-lts

C
131
star
92

CeTune

Python
130
star
93

cm-compiler

C++
130
star
94

pti-gpu

Profiling Tools Interfaces for GPU (PTI for GPU) is a set of Getting Started Documentation and Tools Library to start performance analysis on Intel(R) Processor Graphics easily
C++
129
star
95

fMBT

Free Model Based tool
Python
129
star
96

zlib

C
128
star
97

ros_intel_movidius_ncs

C++
126
star
98

mpi-benchmarks

C
125
star
99

mOS

C
124
star
100

sgx-software-enable

C
122
star