• Home
Name
Date
Size
#Lines
LOC

..--

.gitignoreD12-May-202486 87

KconfigD12-May-2024630 3124

Make.defsD12-May-2024698 1816

MakefileD12-May-20241.8 KiB6331

Makefile.travisD12-May-20243 KiB7129

README.mdD12-May-20244.8 KiB188140

jerry_main.cD12-May-202411.8 KiB466334

jerry_port.cD12-May-20245.2 KiB230122

setjmp.SD12-May-20241.4 KiB6628

setjmp.hD12-May-2024807 267

README.md

1 ### About
2 
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/)
5 
6 ### How to build
7 
8 #### 1. Setup the build environment for STM32F4-Discovery board
9 
10 Clone the necessary projects into a `jerry-nuttx` directory. The last tested working version of NuttX is 7.28.
11 
12 ```sh
13 # Create a base folder for all the projects.
14 mkdir jerry-nuttx && cd jerry-nuttx
15 
16 git clone https://github.com/jerryscript-project/jerryscript.git
17 git clone https://bitbucket.org/nuttx/nuttx.git -b nuttx-7.28
18 git clone https://bitbucket.org/nuttx/apps.git -b nuttx-7.28
19 git clone https://github.com/texane/stlink.git -b v1.5.1
20 ```
21 
22 The following directory structure is created after these commands:
23 
24 ```
25 jerry-nuttx
26   + apps
27   + jerryscript
28   |  + targets
29   |      + nuttx-stm32f4
30   + nuttx
31   + stlink
32 ```
33 
34 #### 2. Build JerryScript for NuttX
35 
36 Build JerryScript as a static library using the NuttX folder as sysroot. The created static libraries will be used later by NuttX.
37 
38 ```sh
39 # Assuming you are in jerry-nuttx folder.
40 jerryscript/tools/build.py \
41     --clean \
42     --lto=OFF \
43     --jerry-cmdline=OFF \
44     --jerry-libm=ON \
45     --all-in-one=ON \
46     --mem-heap=70 \
47     --profile=es2015-subset \
48     --compile-flag="--sysroot=${PWD}/nuttx" \
49     --toolchain=${PWD}/jerryscript/cmake/toolchain_mcu_stm32f4.cmake
50 ```
51 
52 #### 3. Copy JerryScript's application files to NuttX
53 
54 After creating the static libs (see previous step), it is needed to move the JerryScript application files to the NuttX's interpreter path.
55 
56 ```sh
57 # Assuming you are in jerry-nuttx folder.
58 mkdir -p apps/interpreters/jerryscript
59 cp jerryscript/targets/nuttx-stm32f4/* apps/interpreters/jerryscript/
60 
61 # Or more simply:
62 # ln -s jerryscript/targets/nuttx-stm32f4 apps/interpreters/jerryscript
63 ```
64 
65 #### 4. Configure NuttX
66 
67 NuttX requires configuration first. The configuration creates a `.config` file in the root folder of NuttX that has all the necessary options for the build.
68 
69 ```sh
70 # Assuming you are in jerry-nuttx folder.
71 cd nuttx/tools
72 
73 # Configure NuttX to use USB console shell.
74 ./configure.sh stm32f4discovery/usbnsh
75 ```
76 
77 By default, JerryScript is not enabled, so it is needed to modify the configuration file.
78 
79 ##### 4.1 Enable JerryScript without user interaction
80 
81 ```sh
82 # Assuming you are in jerry-nuttx folder.
83 sed --in-place "s/CONFIG_HOST_WINDOWS/# CONFIG_HOST_WINDOWS/g" nuttx/.config
84 sed --in-place "s/CONFIG_WINDOWS_CYGWIN/# CONFIG_WINDOWS_CYGWIN/g" nuttx/.config
85 sed --in-place "s/CONFIG_TOOLCHAIN_WINDOWS/# CONFIG_TOOLCHAIN_WINDOWS/g" nuttx/.config
86 
87 cat >> nuttx/.config << EOL
88 CONFIG_HOST_LINUX=y
89 CONFIG_ARCH_FPU=y
90 CONFIG_JERRYSCRIPT=y
91 CONFIG_JERRYSCRIPT_PRIORITY=100
92 CONFIG_JERRYSCRIPT_STACKSIZE=16384
93 EOL
94 ```
95 
96 ##### 4.2 Enable JerryScript using kconfig-frontend
97 
98 `kconfig-frontend` could be useful if there are another options that should be enabled or disabled in NuttX.
99 
100 ###### 4.2.1 Install kconfig-frontend
101 
102 ```sh
103 # Assuming you are in jerry-nuttx folder.
104 git clone https://bitbucket.org/nuttx/tools.git nuttx-tools
105 cd nuttx-tools/kconfig-frontends
106 
107 ./configure \
108     --disable-nconf \
109     --disable-gconf \
110     --disable-qconf \
111     --disable-utils \
112     --disable-shared \
113     --enable-static \
114     --prefix=${PWD}/install
115 
116 make
117 sudo make install
118 
119 # Add the install folder to PATH
120 PATH=$PATH:${PWD}/install/bin
121 ```
122 
123 ###### 4.2.2 Enable JerryScript
124 ```sh
125 # Assuming you are in jerry-nuttx folder.
126 # Might be required to run `make menuconfig` twice.
127 make -C nuttx menuconfig
128 ```
129 
130 * Change `Build Setup -> Build Host Platform` to Linux
131 * Enable `System Type -> FPU support`
132 * Enable JerryScript `Application Configuration -> Interpreters -> JerryScript`
133 
134 #### 5. Build NuttX
135 
136 ```sh
137 # Assuming you are in jerry-nuttx folder.
138 make -C nuttx
139 ```
140 
141 #### 6. Flash the device
142 
143 Connect Mini-USB for power supply and connect Micro-USB for `NSH` console.
144 
145 ```sh
146 # Assuming you are in jerry-nuttx folder.
147 make -C stlink release
148 
149 sudo stlink/build/Release/st-flash write nuttx/nuttx.bin 0x8000000
150 ```
151 
152 ### Running JerryScript
153 
154 You can use `minicom` for terminal program, or any other you may like, but set
155 baud rate to `115200`.
156 
157 ```sh
158 sudo minicom --device=/dev/ttyACM0 --baud=115200
159 ```
160 
161 You may have to press `RESET` on the board and press `Enter` keys on the console
162 several times to make `nsh` prompt to appear.
163 
164 If the prompt shows like this,
165 ```
166 NuttShell (NSH)
167                nsh>
168                     nsh>
169                          nsh>
170 ```
171 please set `Add Carriage Ret` option by `CTRL-A` > `Z` > `U` at the console,
172 if you're using `minicom`.
173 
174 
175 Run `jerry` with javascript file(s)
176 
177 ```
178 NuttShell (NSH)
179 nsh> jerry full_path/any.js
180 ```
181 
182 Without argument it prints:
183 ```
184 nsh> jerry
185 No input files, running a hello world demo:
186 Hello world 5 times from JerryScript
187 ```
188