diff options
author | Roland Takacs <1487864+rtakacs@users.noreply.github.com> | 2021-11-23 13:17:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-23 13:17:46 +0100 |
commit | 2899582080d1ddb5d38c51776f7b75d05b0d552f (patch) | |
tree | 93fdc439deb7e91a3705247dde63f035910fc923 /targets | |
parent | 06b4c02204baba613723cfa798b7286d3eb26c4d (diff) |
Update RIOT target to 2021.10 (#4826)
JerryScript-DCO-1.0-Signed-off-by: Roland Takacs roland.takacs@h-lab.eu
Diffstat (limited to 'targets')
-rw-r--r-- | targets/riot-stm32f4/Makefile | 53 | ||||
-rw-r--r-- | targets/riot-stm32f4/Makefile.riot | 69 | ||||
-rw-r--r-- | targets/riot-stm32f4/Makefile.travis | 5 | ||||
-rw-r--r-- | targets/riot-stm32f4/README.md | 124 |
4 files changed, 116 insertions, 135 deletions
diff --git a/targets/riot-stm32f4/Makefile b/targets/riot-stm32f4/Makefile index 5e49ae11..e8030cab 100644 --- a/targets/riot-stm32f4/Makefile +++ b/targets/riot-stm32f4/Makefile @@ -13,36 +13,67 @@ # limitations under the License. # application name -APPLICATION = riot_jerry +APPLICATION = riot_jerryscript # default BOARD enviroment BOARD ?= stm32f4discovery -# LLVM/Clang-based toolchain -TOOLCHAIN ?= llvm +# path to jerryscript/targets/riot-stm32f4 +TARGET_DIR = $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) -# path to the RIOT base directory -RIOTBASE ?= $(CURDIR)/../RIOT # path to the JERRYSCRIPT directory -JERRYDIR ?= $(CURDIR) +JERRYDIR ?= $(TARGET_DIR)/../.. + +# path to the RIOT base directory +RIOTBASE ?= $(JERRYDIR)/../RIOT # path to the application directory APPDIR ?= $(JERRYDIR)/targets/riot-stm32f4/source # 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: 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_commands +USEMODULE += posix_sleep + +.PHONY: libjerry +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 := ) -# Add the jerry libs -USEMODULE += libjerry-core libjerry-port-default libjerry-ext +.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 diff --git a/targets/riot-stm32f4/Makefile.riot b/targets/riot-stm32f4/Makefile.riot deleted file mode 100644 index 1600ba75..00000000 --- a/targets/riot-stm32f4/Makefile.riot +++ /dev/null @@ -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 diff --git a/targets/riot-stm32f4/Makefile.travis b/targets/riot-stm32f4/Makefile.travis index a40f23e7..a4bf7101 100644 --- a/targets/riot-stm32f4/Makefile.travis +++ b/targets/riot-stm32f4/Makefile.travis @@ -27,15 +27,14 @@ install-apt-get-deps: # Fetch RIOT OS repository. 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. install-noapt: install-clone-riot install: install-apt-get-deps install-noapt - ## Targets for building RIOT with JerryScript. # Build the firmware (RIOT with JerryScript). script: - $(MAKE) -f ./targets/riot-stm32f4/Makefile.riot + $(MAKE) -f ./targets/riot-stm32f4/Makefile diff --git a/targets/riot-stm32f4/README.md b/targets/riot-stm32f4/README.md index f8905b99..9810293e 100644 --- a/targets/riot-stm32f4/README.md +++ b/targets/riot-stm32f4/README.md @@ -1,96 +1,116 @@ ### 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 -#### 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. -The folder tree related would look like this. +```sh +# 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 ``` -harmony - + jerryscript - | + targets - | + riot-stm32f4 - + RIOT -``` - -2, Target board - -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. +#### 2. Install dependencies of the projects -Follow the [Inroduction](https://github.com/RIOT-OS/RIOT/wiki/Introduction) wiki site and also check that you can flash the stm32f4-board. +``` +# Assuming you are in jerry-riot folder. +jerryscript/tools/apt-get-install-deps.sh +sudo apt install gcc-arm-none-eabi openocd minicom +``` -#### 3. Build JerryScript for RIOT-OS +The following directory structure has been created: ``` -# assume you are in harmony folder -cd jerryscript -make -f ./targets/riot-stm32f4/Makefile.riot +jerry-riot + + jerryscript + | + targets + | + riot-stm32f4 + + RIOT ``` -This will generate the following libraries: -``` -/build/bin/release.riotstm32f4/librelease.jerry-core.a -/build/bin/release.riotstm32f4/librelease.jerry-math.lib.a -``` +#### 3. Build RIOT (with JerryScript) -This will copy one library files to `targets/riot-stm32f4/bin` folder: ``` -libjerrycore.a +# Assuming you are in jerry-riot folder. +make BOARD=stm32f4discovery -f jerryscript/targets/riot-stm32f4/Makefile ``` -This will create a hex file in the `targets/riot-stm32f4/bin` folder: -``` -riot_jerry.elf -``` +The created binary is a `riot_jerryscript.elf` named file located in `jerryscript/build/riot-stm32f4/bin/` folder. -#### 4. Flashing +#### 4. Flash the device + +Connect Mini-USB for charging and flashing the device. ``` -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: -[Alternative way to flash](https://github.com/RIOT-OS/RIOT/wiki/Board:-STM32F4discovery#alternative-way-to-flash) +Note: `ST-LINK` also can be used that is described at [this page](https://github.com/RIOT-OS/RIOT/wiki/ST-LINK-tool). + +#### 5. Connect to the device -#### 5. Cleaning +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` + +The device should be visible as `/dev/ttyUSB0`. Use `minicom` communication program with `115200`. -### 5. Running JerryScript Hello World! example +* 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 may have to press `RESET` on the board after the flash. +```sh +sudo minicom --device=/dev/ttyUSB0 --baud=115200 +``` + +RIOT prompt looks like as follows: -You can use `minicom` for terminal program, and if the prompt shows like this: ``` -main(): This is RIOT! (Version: ****) - You are running RIOT on a(n) stm32f4discovery board. - 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 +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! ``` |