Update RIOT target to 2021.10 (#4826)
JerryScript-DCO-1.0-Signed-off-by: Roland Takacs roland.takacs@h-lab.eu
This commit is contained in:
@@ -13,36 +13,67 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
# application name
|
# application name
|
||||||
APPLICATION = riot_jerry
|
APPLICATION = riot_jerryscript
|
||||||
|
|
||||||
# default BOARD enviroment
|
# default BOARD enviroment
|
||||||
BOARD ?= stm32f4discovery
|
BOARD ?= stm32f4discovery
|
||||||
|
|
||||||
# LLVM/Clang-based toolchain
|
# path to jerryscript/targets/riot-stm32f4
|
||||||
TOOLCHAIN ?= llvm
|
TARGET_DIR = $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||||
|
|
||||||
|
# path to the JERRYSCRIPT directory
|
||||||
|
JERRYDIR ?= $(TARGET_DIR)/../..
|
||||||
|
|
||||||
# path to the RIOT base directory
|
# path to the RIOT base directory
|
||||||
RIOTBASE ?= $(CURDIR)/../RIOT
|
RIOTBASE ?= $(JERRYDIR)/../RIOT
|
||||||
# path to the JERRYSCRIPT directory
|
|
||||||
JERRYDIR ?= $(CURDIR)
|
|
||||||
|
|
||||||
# path to the application directory
|
# path to the application directory
|
||||||
APPDIR ?= $(JERRYDIR)/targets/riot-stm32f4/source
|
APPDIR ?= $(JERRYDIR)/targets/riot-stm32f4/source
|
||||||
|
|
||||||
# path to the binary directory
|
# path to the binary directory
|
||||||
BINDIR ?= $(JERRYDIR)/targets/riot-stm32f4/bin/
|
BUILDDIR ?= $(JERRYDIR)/build/riot-stm32f4
|
||||||
|
|
||||||
|
# path to the binary directory
|
||||||
|
BINDIR ?= $(BUILDDIR)/bin
|
||||||
|
|
||||||
# Change this to 0 show compiler invocation lines by default:
|
# Change this to 0 show compiler invocation lines by default:
|
||||||
QUIET ?= 1
|
QUIET ?= 1
|
||||||
|
|
||||||
INCLUDES += -I$(JERRYDIR)/jerry-core/include -I$(JERRYDIR)/jerry-ext/include
|
INCLUDES += -I$(JERRYDIR)/jerry-core/include
|
||||||
|
INCLUDES += -I$(JERRYDIR)/jerry-ext/include
|
||||||
|
|
||||||
|
ARCHIVES += $(JERRYDIR)/build/lib/libjerry-core.a
|
||||||
|
ARCHIVES += $(JERRYDIR)/build/lib/libjerry-ext.a
|
||||||
|
ARCHIVES += $(JERRYDIR)/build/lib/libjerry-port-default.a
|
||||||
|
|
||||||
# Add the shell and some shell commands
|
|
||||||
USEMODULE += shell
|
USEMODULE += shell
|
||||||
USEMODULE += shell_commands
|
USEMODULE += shell_commands
|
||||||
|
USEMODULE += posix_sleep
|
||||||
|
|
||||||
# Add the jerry libs
|
.PHONY: libjerry
|
||||||
USEMODULE += libjerry-core libjerry-port-default libjerry-ext
|
libjerry:
|
||||||
|
$(JERRYDIR)/tools/build.py \
|
||||||
|
--clean \
|
||||||
|
--lto=OFF \
|
||||||
|
--jerry-cmdline=OFF \
|
||||||
|
--jerry-math=ON \
|
||||||
|
--amalgam=ON \
|
||||||
|
--mem-heap=70 \
|
||||||
|
--profile=es.next \
|
||||||
|
--compile-flag=-fshort-enums \
|
||||||
|
--toolchain=$(abspath $(JERRYDIR)/cmake/toolchain_mcu_stm32f4.cmake)
|
||||||
|
|
||||||
|
.PHONY: clear-cflags
|
||||||
|
clear-cflags:
|
||||||
|
$(eval BACKUP := $(CFLAGS))
|
||||||
|
$(eval CFLAGS := )
|
||||||
|
|
||||||
|
.PHONY: restore-cflags
|
||||||
|
restore-cflags:
|
||||||
|
$(eval CFLAGS := $(BACKUP))
|
||||||
|
|
||||||
|
# CFLAGS is filled by Makefile.include that is only for RIOT.
|
||||||
|
# Clear CFLAGS temporarily while compiling JerryScript.
|
||||||
|
all: clear-cflags libjerry restore-cflags
|
||||||
|
|
||||||
include $(RIOTBASE)/Makefile.include
|
include $(RIOTBASE)/Makefile.include
|
||||||
|
|||||||
@@ -1,69 +0,0 @@
|
|||||||
# 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.
|
|
||||||
|
|
||||||
# Build and output directories
|
|
||||||
BUILD_DIR ?= build/riotstm32f4
|
|
||||||
COPYTARGET ?= targets/riot-stm32f4/bin
|
|
||||||
|
|
||||||
# JerryScript configuration
|
|
||||||
JERRYHEAP ?= 16
|
|
||||||
|
|
||||||
# To be defined on the command line of make if Clang is available via a
|
|
||||||
# different name (e.g., clang-N.M)
|
|
||||||
CC ?= clang
|
|
||||||
|
|
||||||
# Cross-compilation settings for Clang
|
|
||||||
EXT_CFLAGS := -target arm-none-eabi
|
|
||||||
EXT_CFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m4
|
|
||||||
EXT_CFLAGS += -isystem /usr/arm-none-eabi/include
|
|
||||||
EXT_CFLAGS += $(addprefix -isystem $(lastword $(sort $(wildcard /usr/lib/gcc/arm-none-eabi/*/))), include include-fixed)
|
|
||||||
EXT_CFLAGS += -nostdinc
|
|
||||||
|
|
||||||
# For ABI compatibility with RIOT-OS
|
|
||||||
EXT_CFLAGS += -fshort-enums
|
|
||||||
|
|
||||||
|
|
||||||
.PHONY: libjerry riot-jerry flash clean
|
|
||||||
|
|
||||||
all: libjerry riot-jerry
|
|
||||||
|
|
||||||
libjerry:
|
|
||||||
mkdir -p $(BUILD_DIR)
|
|
||||||
cmake -B$(BUILD_DIR) -H./ \
|
|
||||||
-DCMAKE_SYSTEM_NAME=RIOT \
|
|
||||||
-DCMAKE_SYSTEM_PROCESSOR=armv7l \
|
|
||||||
-DCMAKE_C_COMPILER=$(CC) \
|
|
||||||
-DCMAKE_C_COMPILER_WORKS=TRUE \
|
|
||||||
-DENABLE_LTO=OFF \
|
|
||||||
-DJERRY_CMDLINE=OFF \
|
|
||||||
-DJERRY_PROFILE="es5.1" \
|
|
||||||
-DEXTERNAL_COMPILE_FLAGS="$(EXT_CFLAGS)" \
|
|
||||||
-DJERRY_GLOBAL_HEAP_SIZE=$(JERRYHEAP)
|
|
||||||
make -C$(BUILD_DIR) jerry-core jerry-port-default jerry-ext
|
|
||||||
|
|
||||||
mkdir -p $(COPYTARGET)
|
|
||||||
cp $(BUILD_DIR)/lib/libjerry-core.a $(COPYTARGET)
|
|
||||||
cp $(BUILD_DIR)/lib/libjerry-port-default.a $(COPYTARGET)
|
|
||||||
cp $(BUILD_DIR)/lib/libjerry-ext.a $(COPYTARGET)
|
|
||||||
|
|
||||||
riot-jerry: libjerry
|
|
||||||
make -f ./targets/riot-stm32f4/Makefile
|
|
||||||
|
|
||||||
flash: libjerry
|
|
||||||
make -f ./targets/riot-stm32f4/Makefile flash
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -rf $(COPYTARGET)
|
|
||||||
rm -rf $(BUILD_DIR)
|
|
||||||
make -f ./targets/riot-stm32f4/Makefile clean
|
|
||||||
@@ -27,15 +27,14 @@ install-apt-get-deps:
|
|||||||
|
|
||||||
# Fetch RIOT OS repository.
|
# Fetch RIOT OS repository.
|
||||||
install-clone-riot:
|
install-clone-riot:
|
||||||
git clone git://github.com/RIOT-OS/RIOT.git ../RIOT -b 2020.01
|
git clone git://github.com/RIOT-OS/RIOT.git ../RIOT -b 2021.10
|
||||||
|
|
||||||
# Perform all the necessary (JerryScript-independent) installation steps.
|
# Perform all the necessary (JerryScript-independent) installation steps.
|
||||||
install-noapt: install-clone-riot
|
install-noapt: install-clone-riot
|
||||||
install: install-apt-get-deps install-noapt
|
install: install-apt-get-deps install-noapt
|
||||||
|
|
||||||
|
|
||||||
## Targets for building RIOT with JerryScript.
|
## Targets for building RIOT with JerryScript.
|
||||||
|
|
||||||
# Build the firmware (RIOT with JerryScript).
|
# Build the firmware (RIOT with JerryScript).
|
||||||
script:
|
script:
|
||||||
$(MAKE) -f ./targets/riot-stm32f4/Makefile.riot
|
$(MAKE) -f ./targets/riot-stm32f4/Makefile
|
||||||
|
|||||||
@@ -1,96 +1,116 @@
|
|||||||
### About
|
### About
|
||||||
|
|
||||||
This folder contains files to run JerryScript on RIOT-OS with STM32F4-Discovery board.
|
This folder contains files to run JerryScript on
|
||||||
|
[STM32F4-Discovery board](https://www.st.com/en/evaluation-tools/stm32f4discovery.html) with
|
||||||
|
[RIOT](https://www.riot-os.org/).
|
||||||
|
The document had been validated on Ubuntu 20.04 operating system.
|
||||||
|
|
||||||
### How to build
|
### How to build
|
||||||
|
|
||||||
#### 1. Preface
|
#### 1. Setup the build environment for STM32F4-Discovery board
|
||||||
|
|
||||||
1, Directory structure
|
Clone the necessary projects into a `jerry-riot` directory.
|
||||||
|
The latest tested working version of RIOT is `2021.10`.
|
||||||
|
|
||||||
Assume `harmony` as the path to the projects to build.
|
```sh
|
||||||
The folder tree related would look like this.
|
# Create a base folder for all the projects.
|
||||||
|
mkdir jerry-riot && cd jerry-riot
|
||||||
|
|
||||||
|
git clone https://github.com/jerryscript-project/jerryscript.git
|
||||||
|
git clone https://github.com/RIOT-OS/RIOT.git -b 2021.10
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 2. Install dependencies of the projects
|
||||||
|
|
||||||
```
|
```
|
||||||
harmony
|
# Assuming you are in jerry-riot folder.
|
||||||
|
jerryscript/tools/apt-get-install-deps.sh
|
||||||
|
|
||||||
|
sudo apt install gcc-arm-none-eabi openocd minicom
|
||||||
|
```
|
||||||
|
|
||||||
|
The following directory structure has been created:
|
||||||
|
|
||||||
|
```
|
||||||
|
jerry-riot
|
||||||
+ jerryscript
|
+ jerryscript
|
||||||
| + targets
|
| + targets
|
||||||
| + riot-stm32f4
|
| + riot-stm32f4
|
||||||
+ RIOT
|
+ RIOT
|
||||||
```
|
```
|
||||||
|
|
||||||
2, Target board
|
#### 3. Build RIOT (with JerryScript)
|
||||||
|
|
||||||
Assume [STM32F4-Discovery with BB](http://www.st.com/web/en/catalog/tools/FM116/SC959/SS1532/LN1199/PF255417)
|
|
||||||
as the target board.
|
|
||||||
|
|
||||||
#### 2. Prepare RIOT-OS
|
|
||||||
|
|
||||||
Follow [this](https://www.riot-os.org/#download) page to get the RIOT-OS source.
|
|
||||||
|
|
||||||
Follow the [Inroduction](https://github.com/RIOT-OS/RIOT/wiki/Introduction) wiki site and also check that you can flash the stm32f4-board.
|
|
||||||
|
|
||||||
|
|
||||||
#### 3. Build JerryScript for RIOT-OS
|
|
||||||
|
|
||||||
```
|
```
|
||||||
# assume you are in harmony folder
|
# Assuming you are in jerry-riot folder.
|
||||||
cd jerryscript
|
make BOARD=stm32f4discovery -f jerryscript/targets/riot-stm32f4/Makefile
|
||||||
make -f ./targets/riot-stm32f4/Makefile.riot
|
|
||||||
```
|
```
|
||||||
|
|
||||||
This will generate the following libraries:
|
The created binary is a `riot_jerryscript.elf` named file located in `jerryscript/build/riot-stm32f4/bin/` folder.
|
||||||
```
|
|
||||||
/build/bin/release.riotstm32f4/librelease.jerry-core.a
|
|
||||||
/build/bin/release.riotstm32f4/librelease.jerry-math.lib.a
|
|
||||||
```
|
|
||||||
|
|
||||||
This will copy one library files to `targets/riot-stm32f4/bin` folder:
|
#### 4. Flash the device
|
||||||
```
|
|
||||||
libjerrycore.a
|
|
||||||
```
|
|
||||||
|
|
||||||
This will create a hex file in the `targets/riot-stm32f4/bin` folder:
|
Connect Mini-USB for charging and flashing the device.
|
||||||
```
|
|
||||||
riot_jerry.elf
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 4. Flashing
|
|
||||||
|
|
||||||
```
|
```
|
||||||
make -f ./targets/riot-stm32f4/Makefile.riot flash
|
# Assuming you are in jerry-riot folder.
|
||||||
|
make BOARD=stm32f4discovery -f jerryscript/targets/riot-stm32f4/Makefile flash
|
||||||
```
|
```
|
||||||
|
|
||||||
For how to flash the image with other alternative way can be found here:
|
Note: `ST-LINK` also can be used that is described at [this page](https://github.com/RIOT-OS/RIOT/wiki/ST-LINK-tool).
|
||||||
[Alternative way to flash](https://github.com/RIOT-OS/RIOT/wiki/Board:-STM32F4discovery#alternative-way-to-flash)
|
|
||||||
|
|
||||||
#### 5. Cleaning
|
#### 5. Connect to the device
|
||||||
|
|
||||||
|
Use `USB To TTL Serial Converter` for serial communication. STM32F4-Discovery pins are mapped by RIOT as follows:
|
||||||
|
|
||||||
To clean the build result:
|
|
||||||
```
|
```
|
||||||
make -f ./targets/riot-stm32f4/Makefile.riot clean
|
STM32f4-Discovery PA2 pin is configured for TX.
|
||||||
|
STM32f4-Discovery PA3 pin is configured for RX.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
* Connect `STM32f4-Discovery` **PA2** pin to **RX** pin of `USB To TTL Serial Converter`
|
||||||
|
* Connect `STM32f4-Discovery` **PA3** pin to **TX** pin of `USB To TTL Serial Converter`
|
||||||
|
* Connect `STM32f4-Discovery` **GND** pin to **GND** pin of `USB To TTL Serial Converter`
|
||||||
|
|
||||||
### 5. Running JerryScript Hello World! example
|
The device should be visible as `/dev/ttyUSB0`. Use `minicom` communication program with `115200`.
|
||||||
|
|
||||||
You may have to press `RESET` on the board after the flash.
|
* In `minicom`, set `Add Carriage Ret` to `off` in by `CTRL-A -> Z -> U` key combinations.
|
||||||
|
* In `minicom`, set `Hardware Flow Control` to `no` by `CTRL-A -> Z -> O -> Serial port setup -> F` key combinations.
|
||||||
|
|
||||||
You can use `minicom` for terminal program, and if the prompt shows like this:
|
```sh
|
||||||
|
sudo minicom --device=/dev/ttyUSB0 --baud=115200
|
||||||
```
|
```
|
||||||
main(): This is RIOT! (Version: ****)
|
|
||||||
You are running RIOT on a(n) stm32f4discovery board.
|
RIOT prompt looks like as follows:
|
||||||
This board features a(n) stm32f4 MCU.
|
|
||||||
|
```
|
||||||
|
main(): This is RIOT! (Version: 2021.10)
|
||||||
|
You are running RIOT on a(n) stm32f4discovery board.
|
||||||
|
This board features a(n) stm32 MCU.
|
||||||
|
>
|
||||||
```
|
```
|
||||||
please set `Add Carriage Ret` option by `CTRL-A` > `Z` > `U` at the console, if you're using `minicom`.
|
|
||||||
|
|
||||||
|
You may have to press `RESET` on the board and press `Enter` key on the console several times to make RIOT prompt visible.
|
||||||
|
|
||||||
|
#### 6. Run JerrySript
|
||||||
|
|
||||||
|
Type `help` to list shell commands:
|
||||||
|
|
||||||
Help will provide a list of commands:
|
|
||||||
```
|
```
|
||||||
> help
|
> help
|
||||||
|
Command Description
|
||||||
|
---------------------------------------
|
||||||
|
test Jerryscript Hello World test
|
||||||
|
reboot Reboot the node
|
||||||
|
version Prints current RIOT_VERSION
|
||||||
|
pm interact with layered PM subsystem
|
||||||
```
|
```
|
||||||
|
|
||||||
The `test` command will run the test example, which contains the following script code:
|
Type `test` to execute JerryScript:
|
||||||
|
|
||||||
```
|
```
|
||||||
print ('Hello, World!');
|
> test
|
||||||
|
This test run the following script code: [print ('Hello, World!');]
|
||||||
|
|
||||||
|
Hello, World!
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user