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/
9765make
9866```
9967
100-
10168#### 5. Flashing
10269
10370Connect 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
13483baud rate to ` 115200 ` .
13584
13685```
137- minicom --device=/dev/ttyACM0 --baud=115200
86+ sudo minicom --device=/dev/ttyACM0 --baud=115200
13887```
13988
140-
14189You may have to press ` RESET ` on the board and press ` Enter ` keys on the console
14290several 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,
152100if you're using ` minicom ` .
153101
154102
155- Run ` jerryscript ` with ` hello.js `
103+ Run ` jerry ` with javascript file(s)
156104
157105```
158106NuttShell (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