Add support for Mbed-OS 6.15.0 (#4909)
The default Mbed OS device (STM32F4) had been changed to FRDM-K64F that is supported by both Mbed OS 5 and Mbed OS 6 versions. Makefile had also been modified to have a flash recipe. JerryScript-DCO-1.0-Signed-off-by: Roland Takacs roland.takacs@h-lab.eu
This commit is contained in:
@@ -12,8 +12,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# default board: STM32F4-Discovery
|
||||
BOARD ?= DISCO_F407VG
|
||||
# default board: FRDM-K64F
|
||||
BOARD ?= K64F
|
||||
|
||||
# defult toolchain
|
||||
TOOLCHAIN ?= GCC_ARM
|
||||
@@ -30,28 +30,44 @@ BUILD_DIR ?= $(JERRY_ROOT_DIR)/build/mbed-os
|
||||
# default jerry heap size (in KB)
|
||||
JERRY_HEAP_SIZE ?= 70
|
||||
|
||||
define MBED_CLI_FLAGS
|
||||
--clean
|
||||
--build $(BUILD_DIR)
|
||||
--source $(MBED_OS_DIR)
|
||||
--source $(JERRY_ROOT_DIR)
|
||||
--source $(JERRY_TARGET_DIR)
|
||||
--toolchain $(TOOLCHAIN)
|
||||
--target $(BOARD)
|
||||
--artifact-name mbedos
|
||||
--macro JERRY_GLOBAL_HEAP_SIZE=$(JERRY_HEAP_SIZE)
|
||||
endef
|
||||
|
||||
.PHONY: all
|
||||
all: .mbedignore-copy .mbed-build .mbedignore-remove
|
||||
all: .build
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
clean: .mbedignore-remove
|
||||
rm -rf $(JERRY_ROOT_DIR)/build/mbed-os
|
||||
|
||||
.PHONY: flash
|
||||
flash: .mbed-set-flash-flag .build
|
||||
|
||||
.PHONY: .mbed-set-flash-flag
|
||||
.mbed-set-flash-flag:
|
||||
$(eval MBED_CLI_FLAGS += --flash)
|
||||
|
||||
.PHONY: .build
|
||||
.build: .mbedignore-copy .mbed-build .mbedignore-remove
|
||||
|
||||
.PHONY: .mbed-build
|
||||
.mbed-build:
|
||||
mbed config -G MBED_OS_DIR $(MBED_OS_DIR)
|
||||
mbed compile \
|
||||
--clean \
|
||||
--build $(BUILD_DIR) \
|
||||
--source $(MBED_OS_DIR) \
|
||||
--source $(JERRY_ROOT_DIR) \
|
||||
--source $(JERRY_TARGET_DIR) \
|
||||
--toolchain $(TOOLCHAIN) \
|
||||
--target $(BOARD) \
|
||||
--macro JERRY_GLOBAL_HEAP_SIZE=$(JERRY_HEAP_SIZE)
|
||||
mbed compile $(strip $(MBED_CLI_FLAGS))
|
||||
|
||||
.PHONY: .mbedignore-copy
|
||||
.mbedignore-copy:
|
||||
cp .mbedignore $(JERRY_ROOT_DIR)
|
||||
cp mbedignore.txt $(JERRY_ROOT_DIR)/.mbedignore
|
||||
|
||||
.PHONY: .mbedignore-remove
|
||||
.mbedignore-remove:
|
||||
rm $(JERRY_ROOT_DIR)/.mbedignore
|
||||
rm -f $(JERRY_ROOT_DIR)/.mbedignore
|
||||
@@ -19,10 +19,10 @@ all:
|
||||
$(MAKE) script
|
||||
|
||||
|
||||
## Targets for installing build dependencies of the Mbed OS 5 JerryScript target.
|
||||
## Targets for installing build dependencies of the Mbed OS JerryScript target.
|
||||
|
||||
install-mbedos:
|
||||
git clone https://github.com/ARMmbed/mbed-os.git ../mbed-os -b mbed-os-5.15
|
||||
git clone https://github.com/ARMmbed/mbed-os.git ../mbed-os -b mbed-os-6.15.0
|
||||
|
||||
# Deploy Mbed and install Mbed Python dependencies.
|
||||
install-mbedos-deps:
|
||||
@@ -31,8 +31,8 @@ install-mbedos-deps:
|
||||
|
||||
install: install-mbedos install-mbedos-deps
|
||||
|
||||
## Targets for building Mbed OS 5 with JerryScript.
|
||||
## Targets for building Mbed OS with JerryScript.
|
||||
|
||||
# Build the firmware (Mbed OS 5 with JerryScript).
|
||||
# Build the firmware (Mbed OS with JerryScript).
|
||||
script:
|
||||
$(MAKE) -C targets/os/mbedos5 BOARD=K64F MBED_OS_DIR=$(realpath ../mbed-os)
|
||||
$(MAKE) -C targets/os/mbedos MBED_OS_DIR=$(realpath ../mbed-os)
|
||||
@@ -0,0 +1,77 @@
|
||||
### About
|
||||
|
||||
This folder contains files to run JerryScript on
|
||||
[FRDM-K64F board](https://os.mbed.com/platforms/frdm-k64f/) with
|
||||
[Mbed OS](https://os.mbed.com/).
|
||||
The document had been validated on Ubuntu 20.04 operating system.
|
||||
|
||||
#### 1. Setup the build environment
|
||||
|
||||
Clone the necessary projects into a `jerry-mbedos` directory.
|
||||
The latest tested working version of Mbed is `mbed-os-6.15.0`.
|
||||
|
||||
```sh
|
||||
mkdir jerry-mbedos && cd jerry-mbedos
|
||||
|
||||
git clone https://github.com/jerryscript-project/jerryscript.git
|
||||
git clone https://github.com/ARMmbed/mbed-os.git -b mbed-os-6.15.0
|
||||
```
|
||||
|
||||
The following directory structure has been created:
|
||||
|
||||
```
|
||||
jerry-mbedos
|
||||
+ jerryscript
|
||||
| + targets
|
||||
| + os
|
||||
| + mbedos
|
||||
+ mbed-os
|
||||
```
|
||||
|
||||
#### 2. Install dependencies of the projects
|
||||
|
||||
```sh
|
||||
# Assuming you are in jerry-mbedos folder.
|
||||
jerryscript/tools/apt-get-install-deps.sh
|
||||
|
||||
sudo apt install stlink-tools
|
||||
pip install --user mbed-cli
|
||||
# Install Python dependencies of Mbed OS.
|
||||
pip install --user -r mbed-os/requirements.txt
|
||||
```
|
||||
|
||||
#### 3. Build Mbed OS (with JerryScript)
|
||||
|
||||
```
|
||||
# Assuming you are in jerry-mbedos folder.
|
||||
make -C jerryscript/targets/os/mbedos MBED_OS_DIR=${PWD}/mbed-os
|
||||
```
|
||||
|
||||
The created binary is a `mbedos.bin` named file located in `jerryscript/build/mbed-os` folder.
|
||||
|
||||
#### 4. Flash
|
||||
|
||||
Connect Micro-USB for charging and flashing the device.
|
||||
|
||||
```
|
||||
# Assuming you are in jerry-mbedos folder.
|
||||
make -C jerryscript/targets/os/mbedos MBED_OS_DIR=${PWD}/mbed-os flash
|
||||
```
|
||||
|
||||
#### 5. Connect to the device
|
||||
|
||||
The device should be visible as `/dev/ttyACM0` on the host.
|
||||
You can use `minicom` communication program with `115200` baud rate.
|
||||
|
||||
```sh
|
||||
sudo minicom --device=/dev/ttyACM0 --baud=115200
|
||||
```
|
||||
|
||||
Set `Add Carriage Ret` option in `minicom` by `CTRL-A -> Z -> U` key combinations.
|
||||
Press `RESET` on the board to get the output of JerryScript application:
|
||||
|
||||
```
|
||||
This test run the following script code: [print ('Hello, World!');]
|
||||
|
||||
Hello, World!
|
||||
```
|
||||
@@ -26,12 +26,16 @@
|
||||
#define JERRY_STANDALONE_EXIT_CODE_OK (0)
|
||||
#define JERRY_STANDALONE_EXIT_CODE_FAIL (1)
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
Serial device (USBTX, USBRX); // tx, rx
|
||||
device.baud (115200);
|
||||
#if MBED_MAJOR_VERSION == 5
|
||||
static Serial serial(USBTX, USBRX, 115200);
|
||||
#elif MBED_MAJOR_VERSION == 6
|
||||
static BufferedSerial serial(USBTX, USBRX, 115200);
|
||||
#else
|
||||
#error Unsupported Mbed OS version.
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
/* Initialize engine */
|
||||
jerry_init (JERRY_INIT_EMPTY);
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
### About
|
||||
|
||||
This folder contains files to run JerryScript on
|
||||
[STM32F4-Discovery board](https://www.st.com/en/evaluation-tools/stm32f4discovery.html) with
|
||||
[Mbed OS 5](https://os.mbed.com/).
|
||||
The document had been validated on Ubuntu 20.04 operating system.
|
||||
|
||||
#### 1. Setup the build environment
|
||||
|
||||
Clone the necessary projects into a `jerry-mbedos` directory.
|
||||
The latest tested working version of Mbed is `5.15`.
|
||||
|
||||
```sh
|
||||
mkdir jerry-mbedos && cd jerry-mbedos
|
||||
|
||||
git clone https://github.com/jerryscript-project/jerryscript.git
|
||||
git clone https://github.com/ARMmbed/mbed-os.git -b mbed-os-5.15
|
||||
```
|
||||
|
||||
The following directory structure has been created:
|
||||
|
||||
```
|
||||
jerry-mbedos
|
||||
+ jerryscript
|
||||
| + targets
|
||||
| + os
|
||||
| + mbedos5
|
||||
+ mbed-os
|
||||
```
|
||||
|
||||
#### 2. Install dependencies of the projects
|
||||
|
||||
```sh
|
||||
# Assuming you are in jerry-mbedos folder.
|
||||
jerryscript/tools/apt-get-install-deps.sh
|
||||
|
||||
sudo apt install stlink-tools
|
||||
pip install mbed-cli
|
||||
# Install Python dependencies of Mbed OS.
|
||||
pip install --user -r mbed-os/requirements.txt
|
||||
```
|
||||
|
||||
#### 4. Build Mbed OS (with JerryScript)
|
||||
|
||||
```
|
||||
# Assuming you are in jerry-mbedos folder.
|
||||
make -C jerryscript/targets/os/mbedos5 MBED_OS_DIR=${PWD}/mbed-os
|
||||
```
|
||||
|
||||
The created binary is a `mbed-os.bin` named file located in `jerryscript/build/mbed-os` folder.
|
||||
|
||||
#### 5. Flash
|
||||
|
||||
Connect Mini-USB for charging and flashing the device.
|
||||
|
||||
```
|
||||
# Assuming you are in jerry-riot folder.
|
||||
sudo st-flash write jerryscript/build/mbed-os/mbed-os.bin 0x8000000
|
||||
```
|
||||
|
||||
#### 6. Connect to the device
|
||||
|
||||
Use `USB To TTL Serial Converter` for serial communication. STM32F4-Discovery pins are mapped by Mbed OS as follows:
|
||||
|
||||
```
|
||||
STM32f4-Discovery PA2 pin is configured for TX.
|
||||
STM32f4-Discovery PA3 pin is configured for RX.
|
||||
```
|
||||
|
||||
* Connect `STM32f4-Discovery` **PA2** pin to **RX** pin of `USB To TTL Serial Converter`
|
||||
* Connect `STM32f4-Discovery` **PA3** pin to **TX** pin of `USB To TTL Serial Converter`
|
||||
* Connect `STM32f4-Discovery` **GND** pin to **GND** pin of `USB To TTL Serial Converter`
|
||||
|
||||
The device should be visible as `/dev/ttyUSB0`. Use `minicom` communication program with `115200`.
|
||||
|
||||
* In `minicom`, set `Add Carriage Ret` to `off` in by `CTRL-A -> Z -> U` key combinations.
|
||||
* In `minicom`, set `Hardware Flow Control` to `no` by `CTRL-A -> Z -> O -> Serial port setup -> F` key combinations.
|
||||
|
||||
```sh
|
||||
sudo minicom --device=/dev/ttyUSB0 --baud=115200
|
||||
```
|
||||
|
||||
Press `RESET` on the board to get the output of JerryScript application:
|
||||
|
||||
```
|
||||
This test run the following script code: [print ('Hello, World!');]
|
||||
|
||||
Hello, World!
|
||||
```
|
||||
Reference in New Issue
Block a user