Skip to content

Commit c9e9f8e

Browse files
authored
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 [email protected]
1 parent d00f481 commit c9e9f8e

File tree

9 files changed

+125
-117
lines changed

9 files changed

+125
-117
lines changed

.github/workflows/gh-actions.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ jobs:
225225
$RUNNER -q --jerry-tests --build-debug
226226
--buildoptions=--toolchain=cmake/toolchain_linux_aarch64.cmake,--linker-flag=-static
227227
228-
MbedOS5_K64F_Build_Test:
228+
MbedOS_K64F_Build_Test:
229229
runs-on: ubuntu-18.04 # needed due to ppa:team-gcc-arm-embedded/ppa
230230
steps:
231231
- uses: actions/checkout@v2
@@ -235,8 +235,8 @@ jobs:
235235
- run: sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa
236236
- run: sudo apt update
237237
- run: sudo apt install gcc-arm-embedded python3-setuptools mercurial
238-
- run: make -f ./targets/os/mbedos5/Makefile.travis install
239-
- run: make -f ./targets/os/mbedos5/Makefile.travis script
238+
- run: make -f ./targets/os/mbedos/Makefile.travis install
239+
- run: make -f ./targets/os/mbedos/Makefile.travis script
240240

241241
Zephyr_STM32F4_Build_Test:
242242
runs-on: ubuntu-latest
File renamed without changes.

targets/os/mbedos5/Makefile renamed to targets/os/mbedos/Makefile

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# default board: STM32F4-Discovery
16-
BOARD ?= DISCO_F407VG
15+
# default board: FRDM-K64F
16+
BOARD ?= K64F
1717

1818
# defult toolchain
1919
TOOLCHAIN ?= GCC_ARM
@@ -30,28 +30,44 @@ BUILD_DIR ?= $(JERRY_ROOT_DIR)/build/mbed-os
3030
# default jerry heap size (in KB)
3131
JERRY_HEAP_SIZE ?= 70
3232

33+
define MBED_CLI_FLAGS
34+
--clean
35+
--build $(BUILD_DIR)
36+
--source $(MBED_OS_DIR)
37+
--source $(JERRY_ROOT_DIR)
38+
--source $(JERRY_TARGET_DIR)
39+
--toolchain $(TOOLCHAIN)
40+
--target $(BOARD)
41+
--artifact-name mbedos
42+
--macro JERRY_GLOBAL_HEAP_SIZE=$(JERRY_HEAP_SIZE)
43+
endef
44+
3345
.PHONY: all
34-
all: .mbedignore-copy .mbed-build .mbedignore-remove
46+
all: .build
3547

3648
.PHONY: clean
37-
clean:
49+
clean: .mbedignore-remove
3850
rm -rf $(JERRY_ROOT_DIR)/build/mbed-os
3951

52+
.PHONY: flash
53+
flash: .mbed-set-flash-flag .build
54+
55+
.PHONY: .mbed-set-flash-flag
56+
.mbed-set-flash-flag:
57+
$(eval MBED_CLI_FLAGS += --flash)
58+
59+
.PHONY: .build
60+
.build: .mbedignore-copy .mbed-build .mbedignore-remove
61+
4062
.PHONY: .mbed-build
4163
.mbed-build:
4264
mbed config -G MBED_OS_DIR $(MBED_OS_DIR)
43-
mbed compile \
44-
--clean \
45-
--build $(BUILD_DIR) \
46-
--source $(MBED_OS_DIR) \
47-
--source $(JERRY_ROOT_DIR) \
48-
--source $(JERRY_TARGET_DIR) \
49-
--toolchain $(TOOLCHAIN) \
50-
--target $(BOARD) \
51-
--macro JERRY_GLOBAL_HEAP_SIZE=$(JERRY_HEAP_SIZE)
65+
mbed compile $(strip $(MBED_CLI_FLAGS))
5266

67+
.PHONY: .mbedignore-copy
5368
.mbedignore-copy:
54-
cp .mbedignore $(JERRY_ROOT_DIR)
69+
cp mbedignore.txt $(JERRY_ROOT_DIR)/.mbedignore
5570

71+
.PHONY: .mbedignore-remove
5672
.mbedignore-remove:
57-
rm $(JERRY_ROOT_DIR)/.mbedignore
73+
rm -f $(JERRY_ROOT_DIR)/.mbedignore

targets/os/mbedos5/Makefile.travis renamed to targets/os/mbedos/Makefile.travis

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ all:
1919
$(MAKE) script
2020

2121

22-
## Targets for installing build dependencies of the Mbed OS 5 JerryScript target.
22+
## Targets for installing build dependencies of the Mbed OS JerryScript target.
2323

2424
install-mbedos:
25-
git clone https://github.com/ARMmbed/mbed-os.git ../mbed-os -b mbed-os-5.15
25+
git clone https://github.com/ARMmbed/mbed-os.git ../mbed-os -b mbed-os-6.15.0
2626

2727
# Deploy Mbed and install Mbed Python dependencies.
2828
install-mbedos-deps:
@@ -31,8 +31,8 @@ install-mbedos-deps:
3131

3232
install: install-mbedos install-mbedos-deps
3333

34-
## Targets for building Mbed OS 5 with JerryScript.
34+
## Targets for building Mbed OS with JerryScript.
3535

36-
# Build the firmware (Mbed OS 5 with JerryScript).
36+
# Build the firmware (Mbed OS with JerryScript).
3737
script:
38-
$(MAKE) -C targets/os/mbedos5 BOARD=K64F MBED_OS_DIR=$(realpath ../mbed-os)
38+
$(MAKE) -C targets/os/mbedos MBED_OS_DIR=$(realpath ../mbed-os)

targets/os/mbedos/README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
### About
2+
3+
This folder contains files to run JerryScript on
4+
[FRDM-K64F board](https://os.mbed.com/platforms/frdm-k64f/) with
5+
[Mbed OS](https://os.mbed.com/).
6+
The document had been validated on Ubuntu 20.04 operating system.
7+
8+
#### 1. Setup the build environment
9+
10+
Clone the necessary projects into a `jerry-mbedos` directory.
11+
The latest tested working version of Mbed is `mbed-os-6.15.0`.
12+
13+
```sh
14+
mkdir jerry-mbedos && cd jerry-mbedos
15+
16+
git clone https://github.com/jerryscript-project/jerryscript.git
17+
git clone https://github.com/ARMmbed/mbed-os.git -b mbed-os-6.15.0
18+
```
19+
20+
The following directory structure has been created:
21+
22+
```
23+
jerry-mbedos
24+
+ jerryscript
25+
| + targets
26+
| + os
27+
| + mbedos
28+
+ mbed-os
29+
```
30+
31+
#### 2. Install dependencies of the projects
32+
33+
```sh
34+
# Assuming you are in jerry-mbedos folder.
35+
jerryscript/tools/apt-get-install-deps.sh
36+
37+
sudo apt install stlink-tools
38+
pip install --user mbed-cli
39+
# Install Python dependencies of Mbed OS.
40+
pip install --user -r mbed-os/requirements.txt
41+
```
42+
43+
#### 3. Build Mbed OS (with JerryScript)
44+
45+
```
46+
# Assuming you are in jerry-mbedos folder.
47+
make -C jerryscript/targets/os/mbedos MBED_OS_DIR=${PWD}/mbed-os
48+
```
49+
50+
The created binary is a `mbedos.bin` named file located in `jerryscript/build/mbed-os` folder.
51+
52+
#### 4. Flash
53+
54+
Connect Micro-USB for charging and flashing the device.
55+
56+
```
57+
# Assuming you are in jerry-mbedos folder.
58+
make -C jerryscript/targets/os/mbedos MBED_OS_DIR=${PWD}/mbed-os flash
59+
```
60+
61+
#### 5. Connect to the device
62+
63+
The device should be visible as `/dev/ttyACM0` on the host.
64+
You can use `minicom` communication program with `115200` baud rate.
65+
66+
```sh
67+
sudo minicom --device=/dev/ttyACM0 --baud=115200
68+
```
69+
70+
Set `Add Carriage Ret` option in `minicom` by `CTRL-A -> Z -> U` key combinations.
71+
Press `RESET` on the board to get the output of JerryScript application:
72+
73+
```
74+
This test run the following script code: [print ('Hello, World!');]
75+
76+
Hello, World!
77+
```

targets/os/mbedos5/jerry-main.cpp renamed to targets/os/mbedos/jerry-main.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,16 @@
2626
#define JERRY_STANDALONE_EXIT_CODE_OK (0)
2727
#define JERRY_STANDALONE_EXIT_CODE_FAIL (1)
2828

29-
int
30-
main ()
31-
{
32-
Serial device (USBTX, USBRX); // tx, rx
33-
device.baud (115200);
29+
#if MBED_MAJOR_VERSION == 5
30+
static Serial serial(USBTX, USBRX, 115200);
31+
#elif MBED_MAJOR_VERSION == 6
32+
static BufferedSerial serial(USBTX, USBRX, 115200);
33+
#else
34+
#error Unsupported Mbed OS version.
35+
#endif
3436

37+
int main()
38+
{
3539
/* Initialize engine */
3640
jerry_init (JERRY_INIT_EMPTY);
3741

File renamed without changes.
File renamed without changes.

targets/os/mbedos5/README.md

Lines changed: 0 additions & 89 deletions
This file was deleted.

0 commit comments

Comments
 (0)