Permalink
Please
sign in to comment.
Browse files
Initial support for mbed OS 5.1 (#1318)
- Wrappers for mbed I/O drivers - Makefile for automating build process - Script to generate pin definitions from mbed OS source tree - Updates to js2c to enable building without a main.js file JerryScript-DCO-1.0-Signed-off-by: Matthew Else Matthew.Else@arm.com
- Loading branch information
Showing
with
2,427 additions
and 10 deletions.
- +1 −1 .gitignore
- +8 −0 targets/mbedos5/.gitignore
- +89 −0 targets/mbedos5/Makefile
- +75 −0 targets/mbedos5/README.md
- +22 −0 targets/mbedos5/jerryscript-mbed/jerryscript-mbed-drivers/DigitalOut-js.h
- +22 −0 targets/mbedos5/jerryscript-mbed/jerryscript-mbed-drivers/I2C-js.h
- +22 −0 targets/mbedos5/jerryscript-mbed/jerryscript-mbed-drivers/InterruptIn-js.h
- +23 −0 targets/mbedos5/jerryscript-mbed/jerryscript-mbed-drivers/assert-js.h
- +23 −0 targets/mbedos5/jerryscript-mbed/jerryscript-mbed-drivers/gc-js.h
- +36 −0 targets/mbedos5/jerryscript-mbed/jerryscript-mbed-drivers/lib_drivers.h
- +22 −0 targets/mbedos5/jerryscript-mbed/jerryscript-mbed-drivers/setInterval-js.h
- +22 −0 targets/mbedos5/jerryscript-mbed/jerryscript-mbed-drivers/setTimeout-js.h
- +131 −0 targets/mbedos5/jerryscript-mbed/jerryscript-mbed-drivers/source/DigitalOut.cpp
- +270 −0 targets/mbedos5/jerryscript-mbed/jerryscript-mbed-drivers/source/I2C.cpp
- +218 −0 targets/mbedos5/jerryscript-mbed/jerryscript-mbed-drivers/source/InterruptIn.cpp
- +34 −0 targets/mbedos5/jerryscript-mbed/jerryscript-mbed-drivers/source/assert.cpp
- +25 −0 targets/mbedos5/jerryscript-mbed/jerryscript-mbed-drivers/source/gc.cpp
- +36 −0 targets/mbedos5/jerryscript-mbed/jerryscript-mbed-drivers/source/setInterval.cpp
- +37 −0 targets/mbedos5/jerryscript-mbed/jerryscript-mbed-drivers/source/setTimeout.cpp
- +114 −0 targets/mbedos5/jerryscript-mbed/jerryscript-mbed-event-loop/BoundCallback.h
- +104 −0 targets/mbedos5/jerryscript-mbed/jerryscript-mbed-event-loop/EventLoop.h
- +27 −0 targets/mbedos5/jerryscript-mbed/jerryscript-mbed-event-loop/source/EventLoop.cpp
- +21 −0 targets/mbedos5/jerryscript-mbed/jerryscript-mbed-launcher/launcher.h
- +22 −0 targets/mbedos5/jerryscript-mbed/jerryscript-mbed-launcher/setup.h
- +90 −0 targets/mbedos5/jerryscript-mbed/jerryscript-mbed-launcher/source/launcher.cpp
- +49 −0 targets/mbedos5/jerryscript-mbed/jerryscript-mbed-launcher/source/setup.cpp
- +57 −0 targets/mbedos5/jerryscript-mbed/jerryscript-mbed-library-registry/registry.h
- +17 −0 targets/mbedos5/jerryscript-mbed/jerryscript-mbed-library-registry/source/registry.cpp
- +78 −0 targets/mbedos5/jerryscript-mbed/jerryscript-mbed-library-registry/source/wrap_tools.cpp
- +43 −0 targets/mbedos5/jerryscript-mbed/jerryscript-mbed-library-registry/wrap_tools.h
- +24 −0 targets/mbedos5/jerryscript-mbed/jerryscript-mbed-util/js_source.h
- +26 −0 targets/mbedos5/jerryscript-mbed/jerryscript-mbed-util/logging.h
- +93 −0 targets/mbedos5/jerryscript-mbed/jerryscript-mbed-util/wrappers.h
- +76 −0 targets/mbedos5/js/flash_leds.js
- +20 −0 targets/mbedos5/js/main.js
- +1 −0 targets/mbedos5/mbed-events.lib
- +1 −0 targets/mbedos5/mbed-os.lib
- +7 −0 targets/mbedos5/mbed_app.json
- +85 −0 targets/mbedos5/source/jerry_port_mbed.c
- +48 −0 targets/mbedos5/source/main.cpp
- +8 −0 targets/mbedos5/template-mbedignore.txt
- +31 −0 targets/mbedos5/tools/check_pins.sh
- +17 −0 targets/mbedos5/tools/cmsis.h
- +224 −0 targets/mbedos5/tools/generate_pins.py
- +4 −0 targets/mbedos5/tools/jshint.conf
- +3 −0 targets/mbedos5/tools/requirements.txt
- +21 −9 targets/tools/js2c.py
| @@ -0,0 +1,8 @@ | ||
| mbed-os | ||
| mbed-events | ||
| .build | ||
| .mbed | ||
| mbed_settings.py | ||
| js/pins.js | ||
| source/pins.cpp | ||
| source/jerry_targetjs.h |
| @@ -0,0 +1,89 @@ | ||
| # Copyright (c) 2016 ARM Limited | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| # USAGE: | ||
| # specify the board using the command line: | ||
| # make BOARD=[mbed board name] | ||
|
|
||
| BOARD=$(subst [mbed] ,,$(shell mbed target)) | ||
| HEAPSIZE=16 | ||
|
|
||
| DEBUG=0 | ||
| NO_JS=0 | ||
| MBED_VERBOSE=0 | ||
|
|
||
| MBED_CLI_FLAGS=-j0 --source . --source ../../ | ||
|
|
||
| EXTRA_SRC= | ||
|
|
||
| ifneq ($(EXTRA_SRC),) | ||
| EXTRA_SRC_MOD=--source $(subst :, --source ,$(EXTRA_SRC)) | ||
| MBED_CLI_FLAGS += $(EXTRA_SRC_MOD) | ||
| endif | ||
|
|
||
| EXTERN_BUILD_DIR= | ||
|
|
||
| ifneq ($(EXTERN_BUILD_DIR),) | ||
| MBED_CLI_FLAGS += --build $(EXTERN_BUILD_DIR) | ||
| endif | ||
|
|
||
| ifeq ($(DEBUG), 1) | ||
| MBED_CLI_FLAGS += -o debug-info | ||
| endif | ||
|
|
||
| ifeq ($(MBED_VERBOSE), 1) | ||
| MBED_CLI_FLAGS += -v | ||
| else ifeq ($(MBED_VERBOSE), 2) | ||
| MBED_CLI_FLAGS += -vv | ||
| endif | ||
|
|
||
| MBED_CLI_FLAGS += -D "CONFIG_MEM_HEAP_AREA_SIZE=(1024*$(HEAPSIZE))" | ||
| MBED_CLI_FLAGS += -t GCC_ARM | ||
|
|
||
| .PHONY: all js2c getlibs rebuild library | ||
| all: source/jerry_targetjs.h source/pins.cpp .mbed ../../.mbedignore | ||
| mbed target $(BOARD) | ||
| mbed compile $(MBED_CLI_FLAGS) | ||
|
|
||
| library: .mbed ../../.mbedignore | ||
| # delete encoded js code if it exists | ||
| rm -f source/jerry_targetjs.h | ||
| mbed target $(BOARD) | ||
| mbed compile $(MBED_CLI_FLAGS) --library | ||
|
|
||
| clean: | ||
| rm -rf .build/$(BOARD) | ||
|
|
||
| js2c: js/main.js js/flash_leds.js | ||
| python ../tools/js2c.py --ignore pins.js | ||
|
|
||
| source/pins.cpp: | ||
| python tools/generate_pins.py ${BOARD} | ||
|
|
||
| ifeq ($(NO_JS),0) | ||
| source/jerry_targetjs.h: js2c | ||
| else | ||
| source/jerry_targetjs.h: ; | ||
| endif | ||
|
|
||
| getlibs: .mbed | ||
|
|
||
| .mbed: | ||
| mbed config root . | ||
| mbed toolchain GCC_ARM | ||
| mbed target $(BOARD) | ||
| mbed deploy | ||
|
|
||
| ../../.mbedignore: | ||
| cp ./template-mbedignore.txt ../../.mbedignore |
| @@ -0,0 +1,75 @@ | ||
| # JerryScript with mbed OS 5 | ||
|
|
||
| TL;DR? jump straight to [quickstart](#quick-start) | ||
|
|
||
| ## Introduction | ||
|
|
||
| This directory contains the necessary code to build JerryScript for devices | ||
| capable of running mbed OS 5. It has been tested with the following boards | ||
| so far: | ||
|
|
||
| - [Nordic Semiconductor NRF52 Development Kit](https://developer.mbed.org/platforms/Nordic-nRF52-DK/) | ||
| - [NXP Freedom K64F](https://developer.mbed.org/platforms/FRDM-K64F/) | ||
| - [STM NUCLEO F401RE](https://developer.mbed.org/platforms/ST-Nucleo-F401RE/) | ||
| - [Silicon Labs EFM32 Giant Gecko](https://developer.mbed.org/platforms/EFM32-Giant-Gecko/) | ||
|
|
||
| ## Features | ||
|
|
||
| ### Peripheral Drivers | ||
|
|
||
| Peripheral Drivers are intended as a 1-to-1 mapping to mbed C++ APIs, with a few | ||
| differences (due to differences between JavaScript and C++ like lack of operator | ||
| overloading). | ||
|
|
||
| - [DigitalOut](https://docs.mbed.com/docs/mbed-os-api-reference/en/5.1/APIs/io/DigitalOut/) | ||
| - [InterruptIn](https://docs.mbed.com/docs/mbed-os-api-reference/en/5.1/APIs/io/InterruptIn/) | ||
| - [I2C](https://docs.mbed.com/docs/mbed-os-api-reference/en/5.1/APIs/interfaces/digital/I2C/) | ||
| - setInterval and setTimeout using [mbed-event](https://github.com/ARMmbed/mbed-events) | ||
|
|
||
| ## Dependencies | ||
|
|
||
| ### mbed CLI | ||
|
|
||
| mbed CLI is used as the build tool for mbed OS 5. You can find out how to install | ||
| it in the [official documentation](https://docs.mbed.com/docs/mbed-os-handbook/en/5.1/dev_tools/cli/#installing-mbed-cli). | ||
|
|
||
| ### arm-none-eabi-gcc | ||
|
|
||
| arm-none-eabi-gcc is the only currently tested compiler for jerryscript on mbed, | ||
| and instructions for building can be found as part of the mbed-cli installation | ||
| instructions above. | ||
|
|
||
| ### make | ||
|
|
||
| make is used to automate the process of fetching dependencies, and making sure that | ||
| mbed-cli is called with the correct arguments. | ||
|
|
||
| ### (optional) jshint | ||
|
|
||
| jshint is used to statically check your JavaScript code, as part of the build process. | ||
| This ensures that pins you are using in your code are available on your chosen target | ||
| platform. | ||
|
|
||
| ## Quick Start | ||
|
|
||
| Once you have all of your dependencies installed, you can build the project as follows: | ||
|
|
||
| ```bash | ||
| git clone https://github.com/Samsung/jerryscript | ||
| cd jerryscript/targets/mbedos5 | ||
| make getlibs | ||
| # NRF52 Development Kit: | ||
| make BOARD=NRF52_DK | ||
| # FRDM K64F | ||
| make BOARD=K64F | ||
| ``` | ||
|
|
||
| The produced file (in .build/**[BOARD]**/GCC_ARM) can then be uploaded to your board, and will | ||
| run when you press reset. | ||
|
|
||
| If you make a modification to main.js, you can simply rerun make, and it will remember your | ||
| previous choice of board: | ||
|
|
||
| ```bash | ||
| make | ||
| ``` |
| @@ -0,0 +1,22 @@ | ||
| /* Copyright (c) 2016 ARM Limited | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| #ifndef _JERRYSCRIPT_MBED_DRIVERS_DIGITALOUT_H | ||
| #define _JERRYSCRIPT_MBED_DRIVERS_DIGITALOUT_H | ||
|
|
||
| #include "jerryscript-mbed-library-registry/wrap_tools.h" | ||
|
|
||
| DECLARE_CLASS_CONSTRUCTOR(DigitalOut); | ||
|
|
||
| #endif // _JERRYSCRIPT_MBED_DRIVERS_DIGITALOUT_H |
| @@ -0,0 +1,22 @@ | ||
| /* Copyright (c) 2016 ARM Limited | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| #ifndef _JERRYSCRIPT_MBED_DRIVERS_I2C_H | ||
| #define _JERRYSCRIPT_MBED_DRIVERS_I2C_H | ||
|
|
||
| #include "jerryscript-mbed-library-registry/wrap_tools.h" | ||
|
|
||
| DECLARE_CLASS_CONSTRUCTOR(I2C); | ||
|
|
||
| #endif // _JERRYSCRIPT_MBED_DRIVERS_I2C_H |
| @@ -0,0 +1,22 @@ | ||
| /* Copyright (c) 2016 ARM Limited | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| #ifndef _JERRYSCRIPT_MBED_DRIVERS_INTERRUPTIN_H | ||
| #define _JERRYSCRIPT_MBED_DRIVERS_INTERRUPTIN_H | ||
|
|
||
| #include "jerryscript-mbed-library-registry/wrap_tools.h" | ||
|
|
||
| DECLARE_CLASS_CONSTRUCTOR(InterruptIn); | ||
|
|
||
| #endif // _JERRYSCRIPT_MBED_DRIVERS_INTERRUPTIN_H |
| @@ -0,0 +1,23 @@ | ||
| /* Copyright (c) 2016 ARM Limited | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| #ifndef _JERRYSCRIPT_MBED_DRIVERS_ASSERT_H | ||
| #define _JERRYSCRIPT_MBED_DRIVERS_ASSERT_H | ||
|
|
||
| #include "jerryscript-mbed-library-registry/wrap_tools.h" | ||
| #include "jerryscript-mbed-util/logging.h" | ||
|
|
||
| DECLARE_GLOBAL_FUNCTION(assert); | ||
|
|
||
| #endif // _JERRYSCRIPT_MBED_DRIVERS_ASSERT_H |
| @@ -0,0 +1,23 @@ | ||
| /* Copyright (c) 2016 ARM Limited | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| #ifndef _JERRYSCRIPT_MBED_DRIVERS_GC_H | ||
| #define _JERRYSCRIPT_MBED_DRIVERS_GC_H | ||
|
|
||
| #include "jerryscript-mbed-library-registry/wrap_tools.h" | ||
| #include "jerryscript-mbed-util/logging.h" | ||
|
|
||
| DECLARE_GLOBAL_FUNCTION(gc); | ||
|
|
||
| #endif // _JERRYSCRIPT_MBED_DRIVERS_GC_H |
| @@ -0,0 +1,36 @@ | ||
| /* Copyright (c) 2016 ARM Limited | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| #ifndef _JERRYSCRIPT_MBED_DRIVERS_LIB_DRIVERS_H | ||
| #define _JERRYSCRIPT_MBED_DRIVERS_LIB_DRIVERS_H | ||
|
|
||
| #include "jerryscript-mbed-drivers/InterruptIn-js.h" | ||
| #include "jerryscript-mbed-drivers/DigitalOut-js.h" | ||
| #include "jerryscript-mbed-drivers/setInterval-js.h" | ||
| #include "jerryscript-mbed-drivers/setTimeout-js.h" | ||
| #include "jerryscript-mbed-drivers/assert-js.h" | ||
| #include "jerryscript-mbed-drivers/I2C-js.h" | ||
| #include "jerryscript-mbed-drivers/gc-js.h" | ||
|
|
||
| DECLARE_JS_WRAPPER_REGISTRATION (base) { | ||
| REGISTER_GLOBAL_FUNCTION(assert); | ||
| REGISTER_GLOBAL_FUNCTION(gc); | ||
| REGISTER_GLOBAL_FUNCTION(setInterval); | ||
| REGISTER_GLOBAL_FUNCTION(setTimeout); | ||
| REGISTER_CLASS_CONSTRUCTOR(DigitalOut); | ||
| REGISTER_CLASS_CONSTRUCTOR(I2C); | ||
| REGISTER_CLASS_CONSTRUCTOR(InterruptIn); | ||
| } | ||
|
|
||
| #endif // _JERRYSCRIPT_MBED_DRIVERS_LIB_DRIVERS_H |
| @@ -0,0 +1,22 @@ | ||
| /* Copyright (c) 2016 ARM Limited | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| #ifndef _JERRYSCRIPT_MBED_DRIVERS_SET_INTERVAL_H | ||
| #define _JERRYSCRIPT_MBED_DRIVERS_SET_INTERVAL_H | ||
|
|
||
| #include "jerryscript-mbed-library-registry/wrap_tools.h" | ||
|
|
||
| DECLARE_GLOBAL_FUNCTION(setInterval); | ||
|
|
||
| #endif // _JERRYSCRIPT_MBED_DRIVERS_SET_INTERVAL_H |
| @@ -0,0 +1,22 @@ | ||
| /* Copyright (c) 2016 ARM Limited | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| #ifndef _JERRYSCRIPT_MBED_DRIVERS_SET_TIMEOUT_H | ||
| #define _JERRYSCRIPT_MBED_DRIVERS_SET_TIMEOUT_H | ||
|
|
||
| #include "jerryscript-mbed-library-registry/wrap_tools.h" | ||
|
|
||
| DECLARE_GLOBAL_FUNCTION(setTimeout); | ||
|
|
||
| #endif // _JERRYSCRIPT_MBED_DRIVERS_SET_TIMEOUT_H |
Oops, something went wrong.
0 comments on commit
454d3af