1
1
### About
2
2
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/ )
6
5
7
6
### How to build
8
7
9
- #### 1. Preface
8
+ #### 1. Setting up the build environment for STM32F4-Discovery board
9
+
10
+ Clone JerryScript and NuttX into jerry-nuttx directory
10
11
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
+ ```
12
20
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
15
22
16
23
```
17
- harmony
24
+ jerry-nuttx
25
+ + apps
18
26
+ jerryscript
19
27
| + targets
20
28
| + nuttx-stm32f4
21
29
+ 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
44
31
```
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 ` )
51
32
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
53
34
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
61
35
```
62
- make
36
+ cd apps/interpreters
37
+ mkdir jerryscript
38
+ cp ../../jerryscript/targets/nuttx-stm32f4/* ./jerryscript/
63
39
```
64
40
65
- It'll show the last error but it's ok. Nows the time to build JerryScript.
66
-
41
+ #### 3. Configure NuttX
67
42
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
74
43
```
44
+ # assuming you are in jerry-nuttx folder
45
+ cd nuttx/tools
75
46
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
81
49
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
87
53
```
88
54
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"
91
59
92
- #### 4. Continue build NuttX
60
+ #### 4. Build JerryScript for NuttX
93
61
94
62
```
95
- # asssume you are in harmony folder
96
- cd nuttx/nuttx
63
+ # assuming you are in jerry-nuttx folder
64
+ cd nuttx/
97
65
make
98
66
```
99
67
100
-
101
68
#### 5. Flashing
102
69
103
70
Connect Mini-USB for power supply and connect Micro-USB for ` NSH ` console.
104
71
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 ) .
116
73
117
- To clean the build result ,
74
+ To flash ,
118
75
```
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
120
78
```
121
79
122
-
123
80
### Running JerryScript
124
81
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
134
83
baud rate to ` 115200 ` .
135
84
136
85
```
137
- minicom --device=/dev/ttyACM0 --baud=115200
86
+ sudo minicom --device=/dev/ttyACM0 --baud=115200
138
87
```
139
88
140
-
141
89
You may have to press ` RESET ` on the board and press ` Enter ` keys on the console
142
90
several times to make ` nsh ` prompt to appear.
143
91
@@ -152,27 +100,16 @@ please set `Add Carriage Ret` option by `CTRL-A` > `Z` > `U` at the console,
152
100
if you're using ` minicom ` .
153
101
154
102
155
- Run ` jerryscript ` with ` hello.js `
103
+ Run ` jerry ` with javascript file(s)
156
104
157
105
```
158
106
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
178
115
```
0 commit comments