Skip to content

Commit 1e82ae1

Browse files
author
Zsolt Borbély
committed
Update the nuttx-stm32f4 target
Related issue: #1202 JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély [email protected]
1 parent e93e326 commit 1e82ae1

File tree

6 files changed

+264
-242
lines changed

6 files changed

+264
-242
lines changed

targets/nuttx-stm32f4/Kconfig

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#
2+
# For a description of the syntax of this configuration file,
3+
# see the file kconfig-language.txt in the NuttX tools repository.
4+
#
5+
6+
config JERRYSCRIPT
7+
bool "Jerryscript"
8+
default n
9+
---help---
10+
Enable Jerryscript ECMAScript 5.1 interpreter
11+
12+
if JERRYSCRIPT
13+
14+
config JERRYSCRIPT_PROGNAME
15+
string "Program name"
16+
default "jerry"
17+
depends on BUILD_KERNEL
18+
---help---
19+
This is the name of the program that will be
20+
use when the NSH ELF program is installed.
21+
22+
config JERRYSCRIPT_PRIORITY
23+
int "Jerryscript task priority"
24+
default 100
25+
26+
config JERRYSCRIPT_STACKSIZE
27+
int "Jerryscript stack size"
28+
default 16384
29+
30+
config JERRYSCRIPT_HEAPSIZE
31+
int "Jerryscript heap size"
32+
default 107520
33+
34+
endif

targets/nuttx-stm32f4/Make.defs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright 2016 Samsung Electronics Co., Ltd.
2+
# Copyright 2016 University of Szeged
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
ifeq ($(CONFIG_JERRYSCRIPT),y)
17+
CONFIGURED_APPS += interpreters/jerryscript
18+
endif

targets/nuttx-stm32f4/Makefile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Copyright 2016 Samsung Electronics Co., Ltd.
2+
# Copyright 2016 University of Szeged
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
-include $(TOPDIR)/Make.defs
17+
18+
# Jerryscript built-in application info
19+
20+
CONFIG_JERRYSCRIPT_PRIORITY ?= SCHED_PRIORITY_DEFAULT
21+
CONFIG_JERRYSCRIPT_STACKSIZE ?= 16384
22+
CONFIG_JERRYSCRIPT_HEAPSIZE ?= 107520
23+
24+
APPNAME = jerry
25+
# path to the project dir, "jerry-nuttx" by default
26+
ROOT_DIR = ../../..
27+
PRIORITY = $(CONFIG_JERRYSCRIPT_PRIORITY)
28+
STACKSIZE = $(CONFIG_JERRYSCRIPT_STACKSIZE)
29+
CFLAGS += -std=c99 -DJERRY_NDEBUG '-DCONFIG_MEM_HEAP_AREA_SIZE=$(CONFIG_JERRYSCRIPT_HEAPSIZE)'
30+
CFLAGS += -I$(ROOT_DIR)/ $(shell find $(ROOT_DIR)/jerryscript/jerry-core -type d | sed -r -e 's/^/-I/g')
31+
32+
# Jerryscript
33+
34+
.PHONY: jerry_core_allin.c
35+
jerry_core_allin.c:
36+
echo '#include "jerryscript/jerry-libm/nextafter.c"' > jerry_core_allin.c
37+
find $(ROOT_DIR)/jerryscript/jerry-core -name "*.c" | sed -r -e 's/(\.\.\/)*(.+)/#include "\2"/g' >> jerry_core_allin.c
38+
39+
ASRCS =
40+
CSRCS = jerry_core_allin.c
41+
MAINSRC = jerry_main.c
42+
43+
CONFIG_JERRYSCRIPT_PROGNAME ?= jerry$(EXEEXT)
44+
PROGNAME = $(CONFIG_JERRYSCRIPT_PROGNAME)
45+
46+
include $(APPDIR)/Application.mk

targets/nuttx-stm32f4/Makefile.nuttx

Lines changed: 0 additions & 68 deletions
This file was deleted.

targets/nuttx-stm32f4/README.md

Lines changed: 51 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,143 +1,91 @@
11
### About
22

3-
This folder contains files to run JerryScript on NuttX with
4-
[STM32F4-Discovery with BB](http://www.st.com/web/en/catalog/tools/FM116/SC959/SS1532/LN1199/PF255417)
5-
3+
This folder contains files to run JerryScript on
4+
[STM32F4-Discovery board](http://www.st.com/content/st_com/en/products/evaluation-tools/product-evaluation-tools/mcu-eval-tools/stm32-mcu-eval-tools/stm32-mcu-discovery-kits/stm32f4discovery.html) with [NuttX](http://nuttx.org/)
65

76
### How to build
87

9-
#### 1. Preface
8+
#### 1. Setting up the build environment for STM32F4-Discovery board
9+
10+
Clone JerryScript and NuttX into jerry-nuttx directory
1011

11-
1, Directory structure
12+
```
13+
mkdir jerry-nuttx
14+
cd jerry-nuttx
15+
git clone https://github.com/Samsung/jerryscript.git
16+
git clone https://bitbucket.org/nuttx/nuttx.git
17+
git clone https://bitbucket.org/nuttx/apps.git
18+
git clone https://github.com/texane/stlink.git
19+
```
1220

13-
Assume `harmony` as the root folder to the projects to build.
14-
The folder tree related would look like this.
21+
The following directory structure is created after these commands
1522

1623
```
17-
harmony
24+
jerry-nuttx
25+
+ apps
1826
+ jerryscript
1927
| + targets
2028
| + nuttx-stm32f4
2129
+ nuttx
22-
| + nuttx
23-
| + lib
24-
+ st-link
25-
```
26-
27-
28-
2, Target board
29-
30-
Assume [STM32F4-Discovery with BB](http://www.st.com/web/en/catalog/tools/FM116/SC959/SS1532/LN1199/PF255417)
31-
as the target board.
32-
33-
34-
3, Micro SD-Card memory for Script source files
35-
36-
37-
#### 2. Prepare NuttX
38-
39-
Follow [this](https://bitbucket.org/seanshpark/nuttx/wiki/Home) page to get
40-
NuttX source and do the first build. When it stops with and error,
41-
change default project from `IoT.js` to `JerryScript` as follows;
42-
43-
2-1) run menuconfig
30+
+ stlink
4431
```
45-
# assume you are in nuttx folder where .config exist
46-
make menuconfig
47-
```
48-
2-2) Select `Application Configuration` --> `Interpreters`
49-
50-
2-3) Check `[*] JerryScript interpreter` (Move cursor to the line and press `Space`)
5132

52-
2-4) `< Exit >` once on the bottom of the sceen (Press `Right arrow` and `Enter`)
33+
#### 2. Adding JerryScript as an interpreter for NuttX
5334

54-
2-5) Select `System Libraries and NSH Add-Ons`
55-
56-
2-6) Un-Check `[ ] iotjs program` (Move cursor to the line and press `Space`)
57-
58-
2-7) `< Exit >` till `menuconfig` ends. Save new configugation when asked.
59-
60-
2-7) `make` again
6135
```
62-
make
36+
cd apps/interpreters
37+
mkdir jerryscript
38+
cp ../../jerryscript/targets/nuttx-stm32f4/* ./jerryscript/
6339
```
6440

65-
It'll show the last error but it's ok. Nows the time to build JerryScript.
66-
41+
#### 3. Configure NuttX
6742

68-
#### 3. Build JerryScript for NuttX
69-
70-
```
71-
# assume you are in harmony folder
72-
cd jerryscript
73-
make -f ./targets/nuttx-stm32f4/Makefile.nuttx
7443
```
44+
# assuming you are in jerry-nuttx folder
45+
cd nuttx/tools
7546
76-
If you have NuttX at another path than described above, you can give the
77-
absolute path with `NUTTX` variable , for example,
78-
```
79-
NUTTX=/home/user/work/nuttx make -f ./targets/nuttx-stm32f4/Makefile.nuttx
80-
```
47+
# configure NuttX USB console shell
48+
./configure.sh stm32f4discovery/usbnsh
8149
82-
Make will copy three library files to `nuttx/nuttx/lib` folder
83-
```
84-
libjerryentry.a
85-
libjerrycore.a
86-
libjerrylibm.a
50+
cd ..
51+
# might require to run "make menuconfig" twice
52+
make menuconfig
8753
```
8854

89-
In NuttX, if you run `make clean`, above library files are also removed so you
90-
may have to build JerryScript again.
55+
Change "Build Setup" -> "Build Host Platform" from "Windows" to "Linux"
56+
Enable "System Type" -> "FPU support"
57+
Enable "Library Routines" -> "Standard Math library"
58+
Enable "Application Configuration" -> "Interpreters->JerryScript"
9159

92-
#### 4. Continue build NuttX
60+
#### 4. Build JerryScript for NuttX
9361

9462
```
95-
# asssume you are in harmony folder
96-
cd nuttx/nuttx
63+
# assuming you are in jerry-nuttx folder
64+
cd nuttx/
9765
make
9866
```
9967

100-
10168
#### 5. Flashing
10269

10370
Connect Mini-USB for power supply and connect Micro-USB for `NSH` console.
10471

105-
Please refer [this](https://github.com/Samsung/iotjs/wiki/Build-for-NuttX#prepare-flashing-to-target-board)
106-
link to prepare `stlink` utility.
107-
108-
109-
To flash with `Makefile.nuttx`,
110-
```
111-
# assume you are in jerryscript folder
112-
make -f ./targets/nuttx-stm32f4/Makefile.nuttx flash
113-
```
114-
115-
#### 6. Cleaning
72+
To configure `stlink` utility for flashing, follow the instructions [here](https://github.com/texane/stlink#build-from-sources).
11673

117-
To clean the build result,
74+
To flash,
11875
```
119-
make -f ./targets/nuttx-stm32f4/Makefile.nuttx clean
76+
# assuming you are in nuttx folder
77+
sudo ../stlink/build/st-flash write nuttx.bin 0x8000000
12078
```
12179

122-
12380
### Running JerryScript
12481

125-
Prepare a micro SD-card and prepare `hello.js` like this in the root directory of SD-card.
126-
127-
```
128-
print("Hello JerryScript!");
129-
```
130-
131-
Power Off(unplug both USB cables), plug the memory card to BB, and power on again.
132-
133-
You can use `minicom` for terminal program, or any other you may like, but match
82+
You can use `minicom` for terminal program, or any other you may like, but set
13483
baud rate to `115200`.
13584

13685
```
137-
minicom --device=/dev/ttyACM0 --baud=115200
86+
sudo minicom --device=/dev/ttyACM0 --baud=115200
13887
```
13988

140-
14189
You may have to press `RESET` on the board and press `Enter` keys on the console
14290
several times to make `nsh` prompt to appear.
14391

@@ -152,27 +100,16 @@ please set `Add Carriage Ret` option by `CTRL-A` > `Z` > `U` at the console,
152100
if you're using `minicom`.
153101

154102

155-
Run `jerryscript` with `hello.js`
103+
Run `jerry` with javascript file(s)
156104

157105
```
158106
NuttShell (NSH)
159-
nsh>
160-
nsh>
161-
nsh> jerryscript /mnt/sdcard/hello.js
162-
PARAM 1 : [/mnt/sdcard/hello.js]
163-
Hello JerryScript!
164-
```
165-
166-
Please give absolute path of the script file or may get an error like this.
167-
```
168-
nsh> cd /mnt/sdcard
169-
nsh> jerryscript ./hello.js
170-
PARAM 1 : [./hello.js]
171-
Failed to fopen [./hello.js]
172-
JERRY_STANDALONE_EXIT_CODE_FAIL
173-
nsh>
174-
nsh>
175-
nsh> jerryscript /mnt/sdcard/hello.js
176-
PARAM 1 : [/mnt/sdcard/hello.js]
177-
Hello JerryScript!
107+
nsh> jerry full_path/any.js
108+
```
109+
110+
Without argument it prints:
111+
```
112+
nsh> jerry
113+
No input files, running a hello world demo:
114+
Hello world 5 times from JerryScript
178115
```

0 commit comments

Comments
 (0)