Notable changes:
- Updated and the port API interface, new functions have been added
and some have been changed. The port library is now cleaned up to
not have any dependency on jerry-core, as it should be. The port library
is now strictly a collection of functions that implement
embedding/platform specific behavior.
- The default port implementation has been split for windows and unix.
Implemented port functions have been categorized and reorganized,
and marked with attribute((weak)) for better reusability.
- External context allocation has been moved to the port API instead
of a core API callback. The iterface has also been extended with a
function to free the allocated context. When external context is
enabled, jerry_init now automatically calls the port implementation
to allocate the context and jerry_cleanup automatically calls the port
to free the context.
- jerry_port_log has been changed to no longer require formatting to
be implemented by the port. The reason beind this is that it was vague what
format specifiers were used by the engine, and in what manner. The port
function now takes a zero-terminated string, and should only implement
how the string should be logged.
- Logging and log message formatting is now handled by the core jerry library
where it can be implemented as necessary. Logging can be done through a new
core API function, which uses the port to output the final log message.
- Log level has been moved into jerry-core, and an API function has
been added to set the log level. It should be the library that
filters log messages based on the requested log level, instead of
logging everything and requiring the user to do so.
- Module resolving logic has been moved into jerry-core. There's no
reason to have it in the port library and requiring embedders to
duplicate the code. It also added an unnecessary dependency on
jerry-core to the port. Platform specific behavior is still used through
the port API, like resolving module specifiers, and reading source file
contents. If necessary, the resolving logic can still be overridden as
previously.
- The jerry-ext library has also been cleaned up, and many utility
functions have been added that previously were implemented in
jerry-main. This allows easier reusability for some common operations,
like printing unhandled exceptions or providing a repl console.
- Debugger interaction with logged/printed messages has been fixed, so
that it's no longer the port implementations responsibility to send
the output to the debugger, as the port should have no notion of what a
debugger is. The printing and logging functions will now pass the
result message to the debugger, if connected.
- Cleaned up TZA handling in the date port implementation, and simplified
the API function prototype.
- Moved property access helper functions that use ASCII strings as
keys from jerry-ext to the core API.
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
About
This folder contains files to run JerryScript on STM32F4-Discovery board with Zephyr. The document had been validated on Ubuntu 20.04 operating system.
1. Setup the build environment
Clone the necessary projects into a jerry-zephyr directory.
The latest tested working version of Zephyr is v2.7.0.
mkdir jerry-zephyr && cd jerry-zephyr
git clone https://github.com/jerryscript-project/jerryscript.git
git clone https://github.com/zephyrproject-rtos/zephyr -b v2.7.0
# Zephyr requires its toolchain.
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.13.2/zephyr-toolchain-arm-0.13.2-linux-x86_64-setup.run
The following directory structure has been created:
jerry-zephyr
+ jerryscript
| + targets
| + os
| + zephyr
+ zephyr
+ zephyr-toolchain-arm-0.13.2-linux-x86_64-setup.run
2. Install dependencies of the projects
# Assuming you are in jerry-zephyr folder.
jerryscript/tools/apt-get-install-deps.sh
# Tool dependencies of Zephyr.
sudo apt install --no-install-recommends \
git cmake ninja-build gperf ccache dfu-util device-tree-compiler \
python3-dev python3-pip python3-setuptools python3-tk python3-wheel \
xz-utils file make gcc gcc-multilib g++-multilib libsdl2-dev
# Install Python dependencies of Zephyr.
pip3 install --user -r zephyr/scripts/requirements.txt
# Install Zephyr toolchain.
chmod +x zephyr-toolchain-arm-0.13.2-linux-x86_64-setup.run
./zephyr-toolchain-arm-0.13.2-linux-x86_64-setup.run -- -y -d ${PWD}/zephyr-toolchain-0.13.2
Note: CMake 3.20 is required. If the installed CMake is older, upgrade it for example this way.
3. Initialize west meta-tool for Zephyr
# Assuming you are in jerry-zephyr folder.
west init -l zephyr
west update hal_stm32 cmsis
west zephyr-export
4. Build Zephyr (with JerryScript)
# Assuming you are in jerry-zephyr folder.
west build -p auto -b stm32f4_disco jerryscript/targets/os/zephyr/
The created binary is a zephyr.elf named file located in jerry-zephyr/build/zephyr/bin/ folder.
5. Flash
Install udev rules which allows to flash STM32F4-Discovery as a regular user:
# Assuming you are in jerry-zephyr folder.
sudo cp zephyr-toolchain-0.13.2/sysroots/x86_64-pokysdk-linux/usr/share/openocd/contrib/60-openocd.rules /etc/udev/rules.d
sudo udevadm control --reload
Connect Mini-USB for charging and flasing the device.
# Assuming you are in jerry-zephyr folder.
west flash
6. Connect to the device
Use USB To TTL Serial Converter for serial communication. STM32F4-Discovery pins are mapped by Zephyr as follows:
STM32f4-Discovery PA2 pin is configured for TX.
STM32f4-Discovery PA3 pin is configured for RX.
- Connect
STM32f4-DiscoveryPA2 pin to RX pin ofUSB To TTL Serial Converter - Connect
STM32f4-DiscoveryPA3 pin to TX pin ofUSB To TTL Serial Converter - Connect
STM32f4-DiscoveryGND pin to GND pin ofUSB To TTL Serial Converter
The device should be visible as /dev/ttyUSB0. Use minicom communication program with 115200.
- In
minicom, setAdd Carriage Rettooffin byCTRL-A -> Z -> Ukey combinations. - In
minicom, setHardware Flow ControltonobyCTRL-A -> Z -> O -> Serial port setup -> Fkey combinations.
sudo minicom --device=/dev/ttyUSB0 --baud=115200
Press RESET on the board to get the initial message with JerryScript command prompt:
*** Booting Zephyr OS build v2.7.99-1786-ga08b65ef42db ***
JerryScript build: Nov 25 2021 14:17:17
JerryScript API 3.0.0
Zephyr version 2.7.99
js>
Run the following JavaScript example:
js> var test = 0; for (t = 100; t < 1000; t++) test += t; print ('Hello World! ' + test);
Hello World! 494550
undefined