Skip to content

Commit 2899582

Browse files
authored
Update RIOT target to 2021.10 (#4826)
JerryScript-DCO-1.0-Signed-off-by: Roland Takacs roland.takacs@h-lab.eu
1 parent 06b4c02 commit 2899582

File tree

4 files changed

+116
-135
lines changed

4 files changed

+116
-135
lines changed

targets/riot-stm32f4/Makefile

+42-11
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,67 @@
1313
# limitations under the License.
1414

1515
# application name
16-
APPLICATION = riot_jerry
16+
APPLICATION = riot_jerryscript
1717

1818
# default BOARD enviroment
1919
BOARD ?= stm32f4discovery
2020

21-
# LLVM/Clang-based toolchain
22-
TOOLCHAIN ?= llvm
21+
# path to jerryscript/targets/riot-stm32f4
22+
TARGET_DIR = $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
2323

24-
# path to the RIOT base directory
25-
RIOTBASE ?= $(CURDIR)/../RIOT
2624
# path to the JERRYSCRIPT directory
27-
JERRYDIR ?= $(CURDIR)
25+
JERRYDIR ?= $(TARGET_DIR)/../..
26+
27+
# path to the RIOT base directory
28+
RIOTBASE ?= $(JERRYDIR)/../RIOT
2829

2930
# path to the application directory
3031
APPDIR ?= $(JERRYDIR)/targets/riot-stm32f4/source
3132

3233
# path to the binary directory
33-
BINDIR ?= $(JERRYDIR)/targets/riot-stm32f4/bin/
34+
BUILDDIR ?= $(JERRYDIR)/build/riot-stm32f4
35+
36+
# path to the binary directory
37+
BINDIR ?= $(BUILDDIR)/bin
3438

3539
# Change this to 0 show compiler invocation lines by default:
3640
QUIET ?= 1
3741

38-
INCLUDES += -I$(JERRYDIR)/jerry-core/include -I$(JERRYDIR)/jerry-ext/include
42+
INCLUDES += -I$(JERRYDIR)/jerry-core/include
43+
INCLUDES += -I$(JERRYDIR)/jerry-ext/include
44+
45+
ARCHIVES += $(JERRYDIR)/build/lib/libjerry-core.a
46+
ARCHIVES += $(JERRYDIR)/build/lib/libjerry-ext.a
47+
ARCHIVES += $(JERRYDIR)/build/lib/libjerry-port-default.a
3948

40-
# Add the shell and some shell commands
4149
USEMODULE += shell
4250
USEMODULE += shell_commands
51+
USEMODULE += posix_sleep
52+
53+
.PHONY: libjerry
54+
libjerry:
55+
$(JERRYDIR)/tools/build.py \
56+
--clean \
57+
--lto=OFF \
58+
--jerry-cmdline=OFF \
59+
--jerry-math=ON \
60+
--amalgam=ON \
61+
--mem-heap=70 \
62+
--profile=es.next \
63+
--compile-flag=-fshort-enums \
64+
--toolchain=$(abspath $(JERRYDIR)/cmake/toolchain_mcu_stm32f4.cmake)
65+
66+
.PHONY: clear-cflags
67+
clear-cflags:
68+
$(eval BACKUP := $(CFLAGS))
69+
$(eval CFLAGS := )
4370

44-
# Add the jerry libs
45-
USEMODULE += libjerry-core libjerry-port-default libjerry-ext
71+
.PHONY: restore-cflags
72+
restore-cflags:
73+
$(eval CFLAGS := $(BACKUP))
4674

75+
# CFLAGS is filled by Makefile.include that is only for RIOT.
76+
# Clear CFLAGS temporarily while compiling JerryScript.
77+
all: clear-cflags libjerry restore-cflags
4778

4879
include $(RIOTBASE)/Makefile.include

targets/riot-stm32f4/Makefile.riot

-69
This file was deleted.

targets/riot-stm32f4/Makefile.travis

+2-3
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,14 @@ install-apt-get-deps:
2727

2828
# Fetch RIOT OS repository.
2929
install-clone-riot:
30-
git clone git://github.com/RIOT-OS/RIOT.git ../RIOT -b 2020.01
30+
git clone git://github.com/RIOT-OS/RIOT.git ../RIOT -b 2021.10
3131

3232
# Perform all the necessary (JerryScript-independent) installation steps.
3333
install-noapt: install-clone-riot
3434
install: install-apt-get-deps install-noapt
3535

36-
3736
## Targets for building RIOT with JerryScript.
3837

3938
# Build the firmware (RIOT with JerryScript).
4039
script:
41-
$(MAKE) -f ./targets/riot-stm32f4/Makefile.riot
40+
$(MAKE) -f ./targets/riot-stm32f4/Makefile

targets/riot-stm32f4/README.md

+72-52
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,116 @@
11
### About
22

3-
This folder contains files to run JerryScript on RIOT-OS with STM32F4-Discovery board.
3+
This folder contains files to run JerryScript on
4+
[STM32F4-Discovery board](https://www.st.com/en/evaluation-tools/stm32f4discovery.html) with
5+
[RIOT](https://www.riot-os.org/).
6+
The document had been validated on Ubuntu 20.04 operating system.
47

58
### How to build
69

7-
#### 1. Preface
10+
#### 1. Setup the build environment for STM32F4-Discovery board
811

9-
1, Directory structure
12+
Clone the necessary projects into a `jerry-riot` directory.
13+
The latest tested working version of RIOT is `2021.10`.
1014

11-
Assume `harmony` as the path to the projects to build.
12-
The folder tree related would look like this.
15+
```sh
16+
# Create a base folder for all the projects.
17+
mkdir jerry-riot && cd jerry-riot
1318

19+
git clone https://github.com/jerryscript-project/jerryscript.git
20+
git clone https://github.com/RIOT-OS/RIOT.git -b 2021.10
1421
```
15-
harmony
16-
+ jerryscript
17-
| + targets
18-
| + riot-stm32f4
19-
+ RIOT
20-
```
21-
22-
2, Target board
23-
24-
Assume [STM32F4-Discovery with BB](http://www.st.com/web/en/catalog/tools/FM116/SC959/SS1532/LN1199/PF255417)
25-
as the target board.
26-
27-
#### 2. Prepare RIOT-OS
2822

29-
Follow [this](https://www.riot-os.org/#download) page to get the RIOT-OS source.
23+
#### 2. Install dependencies of the projects
3024

31-
Follow the [Inroduction](https://github.com/RIOT-OS/RIOT/wiki/Introduction) wiki site and also check that you can flash the stm32f4-board.
25+
```
26+
# Assuming you are in jerry-riot folder.
27+
jerryscript/tools/apt-get-install-deps.sh
3228
29+
sudo apt install gcc-arm-none-eabi openocd minicom
30+
```
3331

34-
#### 3. Build JerryScript for RIOT-OS
32+
The following directory structure has been created:
3533

3634
```
37-
# assume you are in harmony folder
38-
cd jerryscript
39-
make -f ./targets/riot-stm32f4/Makefile.riot
35+
jerry-riot
36+
+ jerryscript
37+
| + targets
38+
| + riot-stm32f4
39+
+ RIOT
4040
```
4141

42-
This will generate the following libraries:
43-
```
44-
/build/bin/release.riotstm32f4/librelease.jerry-core.a
45-
/build/bin/release.riotstm32f4/librelease.jerry-math.lib.a
46-
```
42+
#### 3. Build RIOT (with JerryScript)
4743

48-
This will copy one library files to `targets/riot-stm32f4/bin` folder:
4944
```
50-
libjerrycore.a
45+
# Assuming you are in jerry-riot folder.
46+
make BOARD=stm32f4discovery -f jerryscript/targets/riot-stm32f4/Makefile
5147
```
5248

53-
This will create a hex file in the `targets/riot-stm32f4/bin` folder:
54-
```
55-
riot_jerry.elf
56-
```
49+
The created binary is a `riot_jerryscript.elf` named file located in `jerryscript/build/riot-stm32f4/bin/` folder.
5750

58-
#### 4. Flashing
51+
#### 4. Flash the device
52+
53+
Connect Mini-USB for charging and flashing the device.
5954

6055
```
61-
make -f ./targets/riot-stm32f4/Makefile.riot flash
56+
# Assuming you are in jerry-riot folder.
57+
make BOARD=stm32f4discovery -f jerryscript/targets/riot-stm32f4/Makefile flash
6258
```
6359

64-
For how to flash the image with other alternative way can be found here:
65-
[Alternative way to flash](https://github.com/RIOT-OS/RIOT/wiki/Board:-STM32F4discovery#alternative-way-to-flash)
60+
Note: `ST-LINK` also can be used that is described at [this page](https://github.com/RIOT-OS/RIOT/wiki/ST-LINK-tool).
61+
62+
#### 5. Connect to the device
6663

67-
#### 5. Cleaning
64+
Use `USB To TTL Serial Converter` for serial communication. STM32F4-Discovery pins are mapped by RIOT as follows:
6865

69-
To clean the build result:
7066
```
71-
make -f ./targets/riot-stm32f4/Makefile.riot clean
67+
STM32f4-Discovery PA2 pin is configured for TX.
68+
STM32f4-Discovery PA3 pin is configured for RX.
7269
```
7370

71+
* Connect `STM32f4-Discovery` **PA2** pin to **RX** pin of `USB To TTL Serial Converter`
72+
* Connect `STM32f4-Discovery` **PA3** pin to **TX** pin of `USB To TTL Serial Converter`
73+
* Connect `STM32f4-Discovery` **GND** pin to **GND** pin of `USB To TTL Serial Converter`
74+
75+
The device should be visible as `/dev/ttyUSB0`. Use `minicom` communication program with `115200`.
7476

75-
### 5. Running JerryScript Hello World! example
77+
* In `minicom`, set `Add Carriage Ret` to `off` in by `CTRL-A -> Z -> U` key combinations.
78+
* In `minicom`, set `Hardware Flow Control` to `no` by `CTRL-A -> Z -> O -> Serial port setup -> F` key combinations.
7679

77-
You may have to press `RESET` on the board after the flash.
80+
```sh
81+
sudo minicom --device=/dev/ttyUSB0 --baud=115200
82+
```
83+
84+
RIOT prompt looks like as follows:
7885

79-
You can use `minicom` for terminal program, and if the prompt shows like this:
8086
```
81-
main(): This is RIOT! (Version: ****)
82-
You are running RIOT on a(n) stm32f4discovery board.
83-
This board features a(n) stm32f4 MCU.
87+
main(): This is RIOT! (Version: 2021.10)
88+
You are running RIOT on a(n) stm32f4discovery board.
89+
This board features a(n) stm32 MCU.
90+
>
8491
```
85-
please set `Add Carriage Ret` option by `CTRL-A` > `Z` > `U` at the console, if you're using `minicom`.
8692

93+
You may have to press `RESET` on the board and press `Enter` key on the console several times to make RIOT prompt visible.
94+
95+
#### 6. Run JerrySript
96+
97+
Type `help` to list shell commands:
8798

88-
Help will provide a list of commands:
8999
```
90100
> help
101+
Command Description
102+
---------------------------------------
103+
test Jerryscript Hello World test
104+
reboot Reboot the node
105+
version Prints current RIOT_VERSION
106+
pm interact with layered PM subsystem
91107
```
92108

93-
The `test` command will run the test example, which contains the following script code:
109+
Type `test` to execute JerryScript:
110+
94111
```
95-
print ('Hello, World!');
112+
> test
113+
This test run the following script code: [print ('Hello, World!');]
114+
115+
Hello, World!
96116
```

0 commit comments

Comments
 (0)