The built-in `print` is removed from jerry-core, but an external `print` implementation is added to jerry-main. From now on, all embedders of the engine have to implement their own `print` if they need such a functionality. For printing results in REPL mode of jerry-main, the external `print` handler is called directly instead of looking up the `print` function registered into the global object. (The two are the same, but the indirection is not needed anymore.) Because jerry-core does not contain `print` anymore, `jerry_port_console` is removed from the port API. The default port is updated, i.e., the implementation of `jerry_port_console` is removed. Additionally, all references to `jerry_port_console` in jerry-main are replaced by `printf`. Speculatively, `jerry_port_console` is also removed from all non-default targets. Most targets implemented it for the sake of the engine only; in those targets the removal was trivial. Where the function was called from the embedder application as well, the calls were replaced with equivalents (e.g., `printf`, `printk`). NOTE 1: This is a breaking change! NOTE 2: This patch still leaves several targets without a JS `print` implementation. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
About
This folder contains files to run JerryScript on STM32F4-Discovery board with NuttX
How to build
1. Setting up the build environment for STM32F4-Discovery board
Clone JerryScript and NuttX into jerry-nuttx directory
mkdir jerry-nuttx
cd jerry-nuttx
git clone https://github.com/jerryscript-project/jerryscript.git
git clone https://bitbucket.org/nuttx/nuttx.git
git clone https://bitbucket.org/nuttx/apps.git
git clone https://github.com/texane/stlink.git
The following directory structure is created after these commands
jerry-nuttx
+ apps
+ jerryscript
| + targets
| + nuttx-stm32f4
+ nuttx
+ stlink
2. Adding JerryScript as an interpreter for NuttX
cd apps/interpreters
mkdir jerryscript
cp ../../jerryscript/targets/nuttx-stm32f4/* ./jerryscript/
3. Configure NuttX
# assuming you are in jerry-nuttx folder
cd nuttx/tools
# configure NuttX USB console shell
./configure.sh stm32f4discovery/usbnsh
cd ..
# might require to run "make menuconfig" twice
make menuconfig
We must set the following options:
- Change
Build Setup -> Build Host Platformfrom Windows to Linux - Enable
System Type -> FPU support - Enable
Application Configuration -> Interpreters -> JerryScript
If you get kconfig-mconf: not found error when you run make menuconfig you may have to install kconfig-frontends:
# assume you are in jerry-nuttx folder
sudo apt-get install gperf flex bison libncurses-dev
git clone https://github.com/jameswalmsley/kconfig-frontends.git
cd kconfig-frontends
./bootstrap
./configure --enable-mconf
make
sudo make install
sudo ldconfig
4. Build JerryScript for NuttX
# assuming you are in jerry-nuttx folder
cd nuttx/
make
5. Flashing
Connect Mini-USB for power supply and connect Micro-USB for NSH console.
To configure stlink utility for flashing, follow the instructions in the official Stlink repository.
To flash,
# assuming you are in nuttx folder
sudo ../stlink/build/Release/st-flash write nuttx.bin 0x8000000
Running JerryScript
You can use minicom for terminal program, or any other you may like, but set
baud rate to 115200.
sudo minicom --device=/dev/ttyACM0 --baud=115200
You may have to press RESET on the board and press Enter keys on the console
several times to make nsh prompt to appear.
If the prompt shows like this,
NuttShell (NSH)
nsh>
nsh>
nsh>
please set Add Carriage Ret option by CTRL-A > Z > U at the console,
if you're using minicom.
Run jerry with javascript file(s)
NuttShell (NSH)
nsh> jerry full_path/any.js
Without argument it prints:
nsh> jerry
No input files, running a hello world demo:
Hello world 5 times from JerryScript