mirror of
https://github.com/google/pebble.git
synced 2025-06-28 03:36:16 +00:00
Import of the watch repository from Pebble
This commit is contained in:
commit
3b92768480
10334 changed files with 2564465 additions and 0 deletions
120
third_party/jerryscript/targets/curie_bsp/README.md
vendored
Normal file
120
third_party/jerryscript/targets/curie_bsp/README.md
vendored
Normal file
|
@ -0,0 +1,120 @@
|
|||
### About Curie BSP port
|
||||
[Intel® Curie BSP](https://github.com/CurieBSP/main/blob/master/README.rst) is the SDK that will help you developing software on Curie based boards, for example with the [Arduino 101 board (AKA Genuino 101)](https://www.arduino.cc/en/Main/ArduinoBoard101).
|
||||
|
||||
This folder contains necessary files to integrate JerryScript with Intel® Curie BSP, so that JavaScript can run on Arduino 101 board (AKA Genuino 101).
|
||||
|
||||
### How to build
|
||||
#### 1. Preface
|
||||
|
||||
Curie BSP only support Ubuntu GNU/Linux as host OS envirenment.
|
||||
|
||||
Necessary hardwares
|
||||
* [FlySwatter2 JTAG debugger](https://www.tincantools.com/wiki/Flyswatter2)
|
||||
* [ARM-JTAG-20-10](https://www.amazon.com/PACK-ARM-JTAG-20-10-Micro-JTAG-adapter/dp/B010ATK9OC/ref=sr_1_1?ie=UTF8&qid=1469635131&sr=8-1&keywords=ARM+Micro+JTAG+Connector)
|
||||
* [USB to TTL Serial Cable](https://www.adafruit.com/products/954)
|
||||
|
||||
#### 2. Prepare Curie BSP
|
||||
|
||||
You can refer to a detailed document [Curie BSP](https://github.com/CurieBSP/main/releases). But, we summary the main steps below:
|
||||
|
||||
##### 1. Get repo:
|
||||
```
|
||||
mkdir ~/bin
|
||||
wget http://commondatastorage.googleapis.com/git-repo-downloads/repo -O ~/bin/repo
|
||||
chmod a+x ~/bin/repo
|
||||
```
|
||||
|
||||
##### 2. In ``~/.bashrc`` add:
|
||||
```
|
||||
PATH=$PATH:~/bin
|
||||
```
|
||||
|
||||
##### 3. Create your directory for CurieBSP (eg. Curie_BSP):
|
||||
```
|
||||
mkdir Curie_BSP && cd $_
|
||||
```
|
||||
|
||||
##### 4. Initialize your repo:
|
||||
```
|
||||
repo init -u https://github.com/CurieBSP/manifest
|
||||
```
|
||||
|
||||
##### 5. Download the sources files:
|
||||
```
|
||||
repo sync -j 5 -d
|
||||
```
|
||||
|
||||
##### 6. Get toolchain (compilation/debug):
|
||||
Download [issm-toolchain-linux-2016-05-12.tar.gz](https://software.intel.com/en-us/articles/issm-toolchain-only-download), and uncompress it.
|
||||
**TOOLCHAIN_DIR** environment variable needs to match the toolchain destination folder
|
||||
You can use the command:``export TOOLCHAIN_DIR='path to files of the toolchain'``
|
||||
|
||||
Or you can just uncompress the toolchain tarball and copy the contents (`licensing readme.txt tools version.txt`) into `wearable_device_sw/external/toolchain`.
|
||||
|
||||
##### 7. Get BLE firmware:
|
||||
Download [curie-ble-v3.1.1.tar.gz]( https://registrationcenter.intel.com/en/forms/?productid=2783) and uncompress the retrieved package into ``wearable_device_sw/packages`` folder
|
||||
|
||||
You will first register in the web page. Then you will receive an email where is a download link. Click the link in the mail, choose the `curie-ble-v3.1.1.tar.gz (118 KB)` and download.
|
||||
|
||||
##### 8. Get tools to flash the device:
|
||||
[https://01.org/android-ia/downloads/intel-platform-flash-tool-lite](https://01.org/android-ia/downloads/intel-platform-flash-tool-lite)
|
||||
|
||||
|
||||
#### 3. Build JerryScript and Curie BSP
|
||||
##### 1. Generate makefiles
|
||||
Run the Python script ``setup.py`` in ``jerryscript/targets/curie_bsp/`` with the full path or relative path of the ``Curie_BSP``:
|
||||
```
|
||||
python setup.py <path of Curie_BSP>
|
||||
```
|
||||
|
||||
##### 2. One time setup. It will check/download/install the necessary tools, and must be run only once.
|
||||
In the directory ``Curie_BSP``
|
||||
```
|
||||
make -C wearable_device_sw/projects/curie_bsp_jerry/ one_time_setup
|
||||
```
|
||||
|
||||
##### 3. In the directory ``Curie_BSP``
|
||||
```
|
||||
mkdir out && cd $_
|
||||
make -f ../wearable_device_sw/projects/curie_bsp_jerry/Makefile setup
|
||||
make image
|
||||
```
|
||||
|
||||
##### 4. Connect JTAG Debugger and TTL Serial Cable to Arduino 101 as below:
|
||||

|
||||
|
||||
##### 5. Flash the firmware
|
||||
```
|
||||
make flash FLASH_CONFIG=jtag_full
|
||||
```
|
||||
|
||||
|
||||
#### 4. Serial terminal
|
||||
Assume the serial port is ``ttyUSB0`` in ``/dev`` directory, we can type command ``screen ttyUSB0 115200`` to open a serial terminal.
|
||||
|
||||
After the board boot successfully, you should see something like this:
|
||||
```
|
||||
Quark SE ID 16 Rev 0 A0
|
||||
ARC Core state: 0000400
|
||||
BOOT TARGET: 0
|
||||
6135|QRK| CFW| INFO| GPIO service init in progress..
|
||||
6307|ARC|MAIN| INFO| BSP init done
|
||||
6315|ARC| CFW| INFO| ADC service init in progress..
|
||||
6315|ARC| CFW| INFO| GPIO service init in progress...
|
||||
6315|ARC| CFW| INFO| GPIO service init in progress...
|
||||
6315|ARC|MAIN| INFO| CFW init done
|
||||
```
|
||||
To test the JavaScript command, you should add characters ``js e `` to the beginning of the JavaScript command, like this:
|
||||
``js e print ('Hello World!');``
|
||||
|
||||
It is the uart command format of Curie BSP. `js` is cmd group, `e` is cmd name, which is short for eval, and `print ('Hello World!');` is the cmd parameters, which is the JavaScript code we want to run.
|
||||
|
||||
You can see the result through the screen:
|
||||
```
|
||||
js e print ('Hello World!');js e 1 ACK
|
||||
Hello World!
|
||||
undefined
|
||||
js e 1 OK
|
||||
```
|
||||
|
||||
`js e 1 ACK` and `js e 1 OK` are debug info of Curie BSP uart commands, which mean it receive and execute the command sucessfully. `Hello World!` is the printed content. `undefined` is the return value of the statement `print ('Hello World!')`.
|
BIN
third_party/jerryscript/targets/curie_bsp/image/connect.png
vendored
Normal file
BIN
third_party/jerryscript/targets/curie_bsp/image/connect.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 575 KiB |
18
third_party/jerryscript/targets/curie_bsp/include/inttypes.h
vendored
Normal file
18
third_party/jerryscript/targets/curie_bsp/include/inttypes.h
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
/* Copyright 2016 Intel Corporation
|
||||
*
|
||||
* 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 INTTYPES_H
|
||||
#define INTTYPES_H
|
||||
|
||||
#endif /* !INTTYPES_H */
|
25
third_party/jerryscript/targets/curie_bsp/include/setjmp.h
vendored
Normal file
25
third_party/jerryscript/targets/curie_bsp/include/setjmp.h
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
/* Copyright 2016 Intel Corporation
|
||||
*
|
||||
* 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 SETJMP_H
|
||||
#define SETJMP_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef uint64_t jmp_buf[14];
|
||||
|
||||
extern int setjmp (jmp_buf env);
|
||||
extern void longjmp (jmp_buf env, int val);
|
||||
|
||||
#endif /* !SETJMP_H */
|
16
third_party/jerryscript/targets/curie_bsp/jerry_app/arc/defconfig
vendored
Normal file
16
third_party/jerryscript/targets/curie_bsp/jerry_app/arc/defconfig
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
CONFIG_AUTO_SERVICE_INIT=y
|
||||
CONFIG_CFW_PROXY=y
|
||||
CONFIG_CFW_QUARK_SE_HELPERS=y
|
||||
CONFIG_LOG_SLAVE=y
|
||||
CONFIG_MEM_POOL_DEF_PATH="$(PROJECT_PATH)/arc"
|
||||
CONFIG_OS_ZEPHYR=y
|
||||
CONFIG_SERVICES_QUARK_SE_ADC_IMPL=y
|
||||
CONFIG_SERVICES_QUARK_SE_GPIO_IMPL=y
|
||||
CONFIG_SOC_GPIO_AON=y
|
||||
CONFIG_SOC_GPIO=y
|
||||
CONFIG_SS_ADC=y
|
||||
CONFIG_SS_GPIO=y
|
||||
CONFIG_TCMD_SLAVE=y
|
||||
CONFIG_TCMD=y
|
||||
CONFIG_ZEPHYR_BOARD="arduino_101_sss"
|
||||
CONFIG_CONSOLE_HANDLER_SHELL=y
|
35
third_party/jerryscript/targets/curie_bsp/jerry_app/arc/main.c
vendored
Normal file
35
third_party/jerryscript/targets/curie_bsp/jerry_app/arc/main.c
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
/* Copyright 2016 Intel Corporation
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
/* infra */
|
||||
#include "infra/log.h"
|
||||
#include "infra/bsp.h"
|
||||
#include "infra/xloop.h"
|
||||
#include "cfw/cfw.h"
|
||||
|
||||
static xloop_t loop;
|
||||
|
||||
void main (void)
|
||||
{
|
||||
T_QUEUE queue = bsp_init ();
|
||||
|
||||
pr_info (LOG_MODULE_MAIN, "BSP init done");
|
||||
|
||||
cfw_init (queue);
|
||||
pr_info (LOG_MODULE_MAIN, "CFW init done");
|
||||
|
||||
xloop_init_from_queue (&loop, queue);
|
||||
|
||||
xloop_run (&loop);
|
||||
}
|
36
third_party/jerryscript/targets/curie_bsp/jerry_app/arc/memory_pool_list.def
vendored
Normal file
36
third_party/jerryscript/targets/curie_bsp/jerry_app/arc/memory_pool_list.def
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
/* Copyright 2016 Intel Corporation
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Definition of the memory pools used by balloc/bfree:
|
||||
* DECLARE_MEMORY_POOL( <index>, <size>, <count>, <align> )
|
||||
* <index> : must start at 0 and be of consecutive values *
|
||||
* <size> : size in bytes of each block from the pool
|
||||
* <count> : number of blocks in the pool
|
||||
*
|
||||
* * Pool definitions must be sorted according the block size
|
||||
* value: pool with <index> 0 must have the smallest <size>.
|
||||
*/
|
||||
|
||||
DECLARE_MEMORY_POOL(0,8,32)
|
||||
DECLARE_MEMORY_POOL(1,16,32)
|
||||
DECLARE_MEMORY_POOL(2,32,48)
|
||||
DECLARE_MEMORY_POOL(3,64,16)
|
||||
DECLARE_MEMORY_POOL(4,96,24)
|
||||
DECLARE_MEMORY_POOL(5,128,6)
|
||||
DECLARE_MEMORY_POOL(6,256,5)
|
||||
DECLARE_MEMORY_POOL(7,512,1)
|
||||
|
||||
#undef DECLARE_MEMORY_POOL
|
30
third_party/jerryscript/targets/curie_bsp/jerry_app/include/project_mapping.h
vendored
Normal file
30
third_party/jerryscript/targets/curie_bsp/jerry_app/include/project_mapping.h
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* Copyright 2016 Intel Corporation
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Allow project to override this partition scheme
|
||||
* The following variables are allowed to be defined:
|
||||
*
|
||||
* QUARK_START_PAGE the first page where the QUARK code is located
|
||||
* QUARK_NB_PAGE the number of pages reserved for the QUARK. The ARC gets the
|
||||
* remaining pages (out of 148).
|
||||
*/
|
||||
#ifndef PROJECT_MAPPING_H
|
||||
#define PROJECT_MAPPING_H
|
||||
|
||||
#define QUARK_NB_PAGE 125
|
||||
#include "machine/soc/intel/quark_se/quark_se_mapping.h"
|
||||
|
||||
#endif /* !PROJECT_MAPPING_H */
|
35
third_party/jerryscript/targets/curie_bsp/jerry_app/quark/defconfig
vendored
Normal file
35
third_party/jerryscript/targets/curie_bsp/jerry_app/quark/defconfig
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
CONFIG_AUTO_SERVICE_INIT=y
|
||||
CONFIG_CFW_QUARK_SE_HELPERS=y
|
||||
CONFIG_CONSOLE_MANAGER=y
|
||||
CONFIG_DEBUG_PANIC_TCMD=y
|
||||
CONFIG_FACTORY_DATA_WRITE=y
|
||||
CONFIG_FACTORY_DATA=y
|
||||
CONFIG_INTEL_QRK_AON_PT=y
|
||||
CONFIG_INTEL_QRK_RTC=y
|
||||
CONFIG_INTEL_QRK_SPI=y
|
||||
CONFIG_INTEL_QRK_WDT=y
|
||||
CONFIG_LOG_CBUFFER_SIZE=2048
|
||||
CONFIG_LOG_CBUFFER=y
|
||||
CONFIG_MEMORY_POOLS_BALLOC_STATISTICS=y
|
||||
CONFIG_MEMORY_POOLS_BALLOC_TRACK_OWNER=y
|
||||
CONFIG_MEM_POOL_DEF_PATH="$(PROJECT_PATH)/quark"
|
||||
CONFIG_OS_ZEPHYR=y
|
||||
CONFIG_PANIC_ON_BUS_ERROR=y
|
||||
CONFIG_QUARK_SE_PROPERTIES_STORAGE=y
|
||||
CONFIG_QUARK=y
|
||||
CONFIG_SERVICES_QUARK_SE_ADC=y
|
||||
CONFIG_SERVICES_QUARK_SE_GPIO_IMPL=y
|
||||
CONFIG_SERVICES_QUARK_SE_GPIO=y
|
||||
CONFIG_SOC_FLASH=y
|
||||
CONFIG_SOC_GPIO_32=y
|
||||
CONFIG_SOC_GPIO=y
|
||||
CONFIG_SOC_ROM=y
|
||||
CONFIG_SPI_FLASH_W25Q16DV=y
|
||||
CONFIG_STORAGE_TASK=y
|
||||
CONFIG_TCMD_CONSOLE=y
|
||||
CONFIG_TCMD_MASTER=y
|
||||
CONFIG_TCMD=y
|
||||
CONFIG_UART_NS16550=y
|
||||
CONFIG_UART_PM_NS16550=y
|
||||
CONFIG_ZEPHYR_BOARD="arduino_101"
|
||||
CONFIG_CONSOLE_HANDLER_SHELL=y
|
167
third_party/jerryscript/targets/curie_bsp/jerry_app/quark/main.c
vendored
Normal file
167
third_party/jerryscript/targets/curie_bsp/jerry_app/quark/main.c
vendored
Normal file
|
@ -0,0 +1,167 @@
|
|||
/* Copyright 2016 Intel Corporation
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Infra */
|
||||
#include "infra/bsp.h"
|
||||
#include "infra/reboot.h"
|
||||
#include "infra/log.h"
|
||||
#include "infra/time.h"
|
||||
#include "infra/system_events.h"
|
||||
#include "infra/tcmd/handler.h"
|
||||
|
||||
#include "cfw/cfw.h"
|
||||
/* Watchdog helper */
|
||||
#include "infra/wdt_helper.h"
|
||||
|
||||
#include "jerry-api.h"
|
||||
#include "string.h"
|
||||
#include "jerry-port.h"
|
||||
|
||||
#include "zephyr.h"
|
||||
#include "microkernel/task.h"
|
||||
#include "os/os.h"
|
||||
|
||||
static T_QUEUE queue;
|
||||
|
||||
jerry_value_t print_function;
|
||||
|
||||
void jerry_resolve_error (jerry_value_t ret_value)
|
||||
{
|
||||
if (jerry_value_has_error_flag (ret_value))
|
||||
{
|
||||
jerry_value_clear_error_flag (&ret_value);
|
||||
jerry_value_t err_str_val = jerry_value_to_string (ret_value);
|
||||
jerry_size_t err_str_size = jerry_get_string_size (err_str_val);
|
||||
jerry_char_t *err_str_buf = (jerry_char_t *) balloc (err_str_size, NULL);
|
||||
jerry_size_t sz = jerry_string_to_char_buffer (err_str_val, err_str_buf, err_str_size);
|
||||
err_str_buf[sz] = 0;
|
||||
jerry_port_console ("Script Error: unhandled exception: %s\n", err_str_buf);
|
||||
bfree(err_str_buf);
|
||||
jerry_release_value (err_str_val);
|
||||
}
|
||||
}
|
||||
|
||||
void help ()
|
||||
{
|
||||
jerry_port_console ("Usage:\n");
|
||||
jerry_port_console ("js e 'JavaScript Command'\n");
|
||||
jerry_port_console ("eg. js e print ('Hello World');\n");
|
||||
}
|
||||
|
||||
void eval_jerry_script (int argc, char *argv[], struct tcmd_handler_ctx *ctx)
|
||||
{
|
||||
if (argc < 3)
|
||||
{
|
||||
TCMD_RSP_ERROR (ctx, NULL);
|
||||
help ();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
OS_ERR_TYPE err;
|
||||
size_t str_total_length = 0;
|
||||
size_t *str_lens = (size_t *) balloc ((argc - 2) * sizeof(size_t), &err);
|
||||
if (str_lens == NULL || err != E_OS_OK)
|
||||
{
|
||||
jerry_port_console ("%s: allocate memory failed!", __func__);
|
||||
TCMD_RSP_ERROR (ctx, NULL);
|
||||
return;
|
||||
}
|
||||
for (int i = 2; i < argc; ++i)
|
||||
{
|
||||
str_lens[i - 2] = strlen (argv[i]);
|
||||
str_total_length += str_lens[i - 2] + 1;
|
||||
}
|
||||
err = E_OS_OK;
|
||||
char *buffer = (char *) balloc (str_total_length, &err);
|
||||
if (buffer == NULL || err != E_OS_OK)
|
||||
{
|
||||
jerry_port_console ("%s: allocate memory failed!", __func__);
|
||||
TCMD_RSP_ERROR (ctx, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
char *p = buffer;
|
||||
for (int i = 2; i < argc; ++i)
|
||||
{
|
||||
for (int j =0; j < str_lens[i - 2]; ++j)
|
||||
{
|
||||
*p = argv[i][j];
|
||||
++p;
|
||||
}
|
||||
*p = ' ';
|
||||
++p;
|
||||
}
|
||||
*p = '\0';
|
||||
|
||||
jerry_value_t eval_ret = jerry_eval (buffer, str_total_length - 1, false);
|
||||
|
||||
if (jerry_value_has_error_flag (eval_ret))
|
||||
{
|
||||
jerry_resolve_error (eval_ret);
|
||||
TCMD_RSP_ERROR (ctx, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
jerry_value_t args[] = {eval_ret};
|
||||
jerry_value_t ret_val_print = jerry_call_function (print_function,
|
||||
jerry_create_undefined (),
|
||||
args,
|
||||
1);
|
||||
jerry_release_value (ret_val_print);
|
||||
TCMD_RSP_FINAL (ctx, NULL);
|
||||
}
|
||||
jerry_release_value (eval_ret);
|
||||
bfree (buffer);
|
||||
bfree (str_lens);
|
||||
}
|
||||
}
|
||||
|
||||
void jerry_start ()
|
||||
{
|
||||
jerry_init (JERRY_INIT_EMPTY);
|
||||
jerry_value_t global_obj_val = jerry_get_global_object ();
|
||||
jerry_value_t print_func_name_val = jerry_create_string ((jerry_char_t *) "print");
|
||||
print_function = jerry_get_property (global_obj_val, print_func_name_val);
|
||||
jerry_release_value (print_func_name_val);
|
||||
jerry_release_value (global_obj_val);
|
||||
}
|
||||
|
||||
/* Application main entry point */
|
||||
void main_task (void *param)
|
||||
{
|
||||
/* Init BSP (also init BSP on ARC core) */
|
||||
queue = bsp_init ();
|
||||
/* start Quark watchdog */
|
||||
wdt_start (WDT_MAX_TIMEOUT_MS);
|
||||
/* Init the CFW */
|
||||
cfw_init (queue);
|
||||
jerry_start ();
|
||||
/* Loop to process message queue */
|
||||
while (1)
|
||||
{
|
||||
OS_ERR_TYPE err = E_OS_OK;
|
||||
/* Process message with a given timeout */
|
||||
queue_process_message_wait (queue, 5000, &err);
|
||||
/* Acknowledge the system watchdog to prevent panic and reset */
|
||||
wdt_keepalive ();
|
||||
}
|
||||
}
|
||||
|
||||
DECLARE_TEST_COMMAND (js, e, eval_jerry_script);
|
36
third_party/jerryscript/targets/curie_bsp/jerry_app/quark/memory_pool_list.def
vendored
Normal file
36
third_party/jerryscript/targets/curie_bsp/jerry_app/quark/memory_pool_list.def
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
/* Copyright 2016 Intel Corporation
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Definition of the memory pools used by balloc/bfree:
|
||||
* DECLARE_MEMORY_POOL( <index>, <size>, <count>, <align> )
|
||||
* <index> : must start at 0 and be of consecutive values *
|
||||
* <size> : size in bytes of each block from the pool
|
||||
* <count> : number of blocks in the pool
|
||||
*
|
||||
* * Pool definitions must be sorted according the block size
|
||||
* value: pool with <index> 0 must have the smallest <size>.
|
||||
*/
|
||||
|
||||
DECLARE_MEMORY_POOL(0,8,32)
|
||||
DECLARE_MEMORY_POOL(1,16,64)
|
||||
DECLARE_MEMORY_POOL(2,32,64)
|
||||
DECLARE_MEMORY_POOL(3,64,48)
|
||||
DECLARE_MEMORY_POOL(4,128,8)
|
||||
DECLARE_MEMORY_POOL(5,256,4)
|
||||
DECLARE_MEMORY_POOL(6,512,3)
|
||||
DECLARE_MEMORY_POOL(7,4096,1)
|
||||
|
||||
#undef DECLARE_MEMORY_POOL
|
252
third_party/jerryscript/targets/curie_bsp/setup.py
vendored
Executable file
252
third_party/jerryscript/targets/curie_bsp/setup.py
vendored
Executable file
|
@ -0,0 +1,252 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# Copyright 2016 Intel Corporation
|
||||
# Copyright 2016 Samsung Electronics Co., Ltd.
|
||||
# Copyright 2016 University of Szeged
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
import fnmatch
|
||||
import os
|
||||
|
||||
def build_soft_links(project_path, jerry_path):
|
||||
""" Creates soft links into the @project_path. """
|
||||
|
||||
if not os.path.exists(project_path):
|
||||
os.makedirs(project_path)
|
||||
|
||||
links = [
|
||||
{ # arc
|
||||
'src': os.path.join('targets', 'curie_bsp', 'jerry_app', 'arc'),
|
||||
'link_name': 'arc'
|
||||
},
|
||||
{ # include
|
||||
'src': os.path.join('targets', 'curie_bsp', 'jerry_app', 'include'),
|
||||
'link_name': 'include'
|
||||
},
|
||||
{ # quark
|
||||
'src': os.path.join('targets', 'curie_bsp', 'jerry_app', 'quark'),
|
||||
'link_name': 'quark'
|
||||
},
|
||||
{ # quark/jerryscript
|
||||
'src': jerry_path,
|
||||
'link_name': os.path.join('quark', 'jerryscript')
|
||||
}
|
||||
]
|
||||
|
||||
for link in links:
|
||||
src = os.path.join(jerry_path, link['src'])
|
||||
link_name = os.path.join(project_path, link['link_name'])
|
||||
if not os.path.islink(link_name):
|
||||
os.symlink(src, link_name)
|
||||
print("Created symlink '{link_name}' -> '{src}'".format(src=src, link_name=link_name))
|
||||
|
||||
|
||||
def find_sources(root_dir, sub_dir):
|
||||
"""
|
||||
Find .c and .S files inside the @root_dir/@sub_dir directory.
|
||||
Note: the returned paths will be relative to the @root_dir directory.
|
||||
"""
|
||||
src_dir = os.path.join(root_dir, sub_dir)
|
||||
|
||||
matches = []
|
||||
for root, dirnames, filenames in os.walk(src_dir):
|
||||
for filename in fnmatch.filter(filenames, '*.[c|S]'):
|
||||
file_path = os.path.join(root, filename)
|
||||
relative_path = os.path.relpath(file_path, root_dir)
|
||||
matches.append(relative_path)
|
||||
|
||||
return matches
|
||||
|
||||
|
||||
def build_jerry_data(jerry_path):
|
||||
"""
|
||||
Build up a dictionary which contains the following items:
|
||||
- sources: list of JerryScript sources which should be built.
|
||||
- dirs: list of JerryScript dirs used.
|
||||
- cflags: CFLAGS for the build.
|
||||
"""
|
||||
jerry_sources = []
|
||||
jerry_dirs = set()
|
||||
for sub_dir in ['jerry-core', 'jerry-libm', os.path.join('targets', 'curie_bsp', 'source')]:
|
||||
for file in find_sources(os.path.normpath(jerry_path), sub_dir):
|
||||
path = os.path.join('jerryscript', file)
|
||||
jerry_sources.append(path)
|
||||
jerry_dirs.add(os.path.split(path)[0])
|
||||
|
||||
jerry_cflags = [
|
||||
'-DCONFIG_MEM_HEAP_AREA_SIZE=10*1024',
|
||||
'-DJERRY_NDEBUG',
|
||||
'-DJERRY_DISABLE_HEAVY_DEBUG',
|
||||
'-DCONFIG_DISABLE_NUMBER_BUILTIN',
|
||||
'-DCONFIG_DISABLE_STRING_BUILTIN',
|
||||
'-DCONFIG_DISABLE_BOOLEAN_BUILTIN',
|
||||
#'-DCONFIG_DISABLE_ERROR_BUILTINS',
|
||||
'-DCONFIG_DISABLE_ARRAY_BUILTIN',
|
||||
'-DCONFIG_DISABLE_MATH_BUILTIN',
|
||||
'-DCONFIG_DISABLE_JSON_BUILTIN',
|
||||
'-DCONFIG_DISABLE_DATE_BUILTIN',
|
||||
'-DCONFIG_DISABLE_REGEXP_BUILTIN',
|
||||
'-DCONFIG_DISABLE_ANNEXB_BUILTIN',
|
||||
'-DCONFIG_ECMA_LCACHE_DISABLE',
|
||||
'-DCONFIG_ECMA_PROPERTY_HASHMAP_DISABLE',
|
||||
]
|
||||
|
||||
return {
|
||||
'sources': jerry_sources,
|
||||
'dirs': jerry_dirs,
|
||||
'cflags': jerry_cflags,
|
||||
}
|
||||
|
||||
|
||||
def write_file(path, content):
|
||||
""" Writes @content into the file at specified by the @path. """
|
||||
norm_path = os.path.normpath(path)
|
||||
with open(norm_path, "w+") as f:
|
||||
f.write(content)
|
||||
print("Wrote file '{0}'".format(norm_path))
|
||||
|
||||
|
||||
def build_obj_y(source_list):
|
||||
"""
|
||||
Build obj-y additions from the @source_list.
|
||||
Note: the input sources should have their file extensions.
|
||||
"""
|
||||
return '\n'.join(['obj-y += {0}.o'.format(os.path.splitext(fname)[0]) for fname in source_list])
|
||||
|
||||
|
||||
def build_cflags_y(cflags_list):
|
||||
"""
|
||||
Build cflags-y additions from the @cflags_list.
|
||||
Note: the input sources should have their file extensions.
|
||||
"""
|
||||
return '\n'.join(['cflags-y += {0}'.format(cflag) for cflag in cflags_list])
|
||||
|
||||
|
||||
def build_mkdir(dir_list):
|
||||
""" Build mkdir calls for each dir in the @dir_list. """
|
||||
return '\n'.join(['\t$(AT)mkdir -p {0}'.format(os.path.join('$(OUT_SRC)', path)) for path in dir_list])
|
||||
|
||||
|
||||
def create_root_kbuild(project_path):
|
||||
""" Creates @project_path/Kbuild.mk file. """
|
||||
|
||||
root_kbuild_path = os.path.join(project_path, 'Kbuild.mk')
|
||||
root_kbuild_content = '''
|
||||
obj-$(CONFIG_QUARK_SE_ARC) += arc/
|
||||
obj-$(CONFIG_QUARK_SE_QUARK) += quark/
|
||||
'''
|
||||
write_file(root_kbuild_path, root_kbuild_content)
|
||||
|
||||
|
||||
def create_root_makefile(project_path):
|
||||
""" Creates @project_path/Makefile file. """
|
||||
|
||||
root_makefile_path = os.path.join(project_path, 'Makefile')
|
||||
root_makefile_content = '''
|
||||
THIS_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
T := $(abspath $(THIS_DIR)/../..)
|
||||
PROJECT := {project_name}
|
||||
BOARD := curie_101
|
||||
ifeq ($(filter curie_101, $(BOARD)),)
|
||||
$(error The curie jerry sample application can only run on the curie_101 Board)
|
||||
endif
|
||||
BUILDVARIANT ?= debug
|
||||
quark_DEFCONFIG = $(PROJECT_PATH)/quark/defconfig
|
||||
arc_DEFCONFIG = $(PROJECT_PATH)/arc/defconfig
|
||||
|
||||
# Optional: set the default version
|
||||
VERSION_MAJOR := 1
|
||||
VERSION_MINOR := 0
|
||||
VERSION_PATCH := 0
|
||||
include $(T)/build/project.mk
|
||||
'''.format(project_name=project_name)
|
||||
|
||||
write_file(root_makefile_path, root_makefile_content)
|
||||
|
||||
|
||||
def create_arc_kbuild(project_path):
|
||||
""" Creates @project_path/arc/Kbuild.mk file. """
|
||||
|
||||
arc_path = os.path.join(project_path, 'arc')
|
||||
arc_kbuild_path = os.path.join(arc_path, 'Kbuild.mk')
|
||||
arc_sources = find_sources(arc_path, '.')
|
||||
arc_kbuild_content = build_obj_y(arc_sources)
|
||||
|
||||
write_file(arc_kbuild_path, arc_kbuild_content)
|
||||
|
||||
|
||||
def create_quark_kbuild(project_path, jerry_path):
|
||||
""" Creates @project_path/quark/Kbuild.mk file. """
|
||||
quark_kbuild_path = os.path.join(project_path, 'quark', 'Kbuild.mk')
|
||||
|
||||
# Extract a few JerryScript related data
|
||||
jerry_data = build_jerry_data(jerry_path)
|
||||
jerry_objects = build_obj_y(jerry_data['sources'])
|
||||
jerry_defines = jerry_data['cflags']
|
||||
jerry_build_dirs = build_mkdir(jerry_data['dirs'])
|
||||
|
||||
quark_include_paths = [
|
||||
'include',
|
||||
'jerryscript',
|
||||
os.path.join('jerryscript', 'jerry-libm', 'include'),
|
||||
os.path.join('jerryscript', 'targets' ,'curie_bsp', 'include')
|
||||
] + list(jerry_data['dirs'])
|
||||
|
||||
quark_includes = [
|
||||
'-Wno-error',
|
||||
] + ['-I%s' % os.path.join(project_path, 'quark', path) for path in quark_include_paths]
|
||||
|
||||
quark_cflags = build_cflags_y(jerry_defines + quark_includes)
|
||||
|
||||
quark_kbuild_content = '''
|
||||
{cflags}
|
||||
|
||||
obj-y += main.o
|
||||
{objects}
|
||||
|
||||
build_dirs:
|
||||
{dirs}
|
||||
|
||||
$(OUT_SRC): build_dirs
|
||||
'''.format(objects=jerry_objects, cflags=quark_cflags, dirs=jerry_build_dirs)
|
||||
|
||||
write_file(quark_kbuild_path, quark_kbuild_content)
|
||||
|
||||
|
||||
def main(curie_path, project_name, jerry_path):
|
||||
project_path = os.path.join(curie_path, 'wearable_device_sw', 'projects', project_name)
|
||||
|
||||
build_soft_links(project_path, jerry_path)
|
||||
|
||||
create_root_kbuild(project_path)
|
||||
create_root_makefile(project_path)
|
||||
create_arc_kbuild(project_path)
|
||||
create_quark_kbuild(project_path, jerry_path)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
print('Usage:')
|
||||
print('{script_name} [full or relative path of Curie_BSP]'.format(script_name=sys.argv[0]))
|
||||
sys.exit(1)
|
||||
|
||||
project_name = 'curie_bsp_jerry'
|
||||
|
||||
file_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
jerry_path = os.path.join(file_dir, "..", "..")
|
||||
curie_path = os.path.join(os.getcwd(), sys.argv[1])
|
||||
|
||||
main(curie_path, project_name, jerry_path)
|
93
third_party/jerryscript/targets/curie_bsp/source/curie-bsp-port.c
vendored
Normal file
93
third_party/jerryscript/targets/curie_bsp/source/curie-bsp-port.c
vendored
Normal file
|
@ -0,0 +1,93 @@
|
|||
/* Copyright 2016 Intel Corporation
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <infra/time.h>
|
||||
#include <misc/printk.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include "jerry-port.h"
|
||||
|
||||
/**
|
||||
* Provide console message implementation for the engine.
|
||||
* Curie BSP implementation
|
||||
*/
|
||||
void
|
||||
jerry_port_console (const char *format, /**< format string */
|
||||
...) /**< parameters */
|
||||
{
|
||||
char buf[256];
|
||||
int length = 0;
|
||||
va_list args;
|
||||
va_start (args, format);
|
||||
length = vsnprintf (buf, 256, format, args);
|
||||
buf[length] = '\0';
|
||||
printk ("%s", buf);
|
||||
va_end (args);
|
||||
} /* jerry_port_console */
|
||||
|
||||
/**
|
||||
* Provide log message implementation for the engine.
|
||||
* Curie BSP implementation
|
||||
*/
|
||||
void
|
||||
jerry_port_log (jerry_log_level_t level, /**< log level */
|
||||
const char *format, /**< format string */
|
||||
...) /**< parameters */
|
||||
{
|
||||
if (level <= JERRY_LOG_LEVEL_ERROR)
|
||||
{
|
||||
char buf[256];
|
||||
int length = 0;
|
||||
va_list args;
|
||||
va_start (args, format);
|
||||
length = vsnprintf (buf, 256, format, args);
|
||||
buf[length] = '\0';
|
||||
printk ("%s", buf);
|
||||
va_end (args);
|
||||
}
|
||||
} /* jerry_port_log */
|
||||
|
||||
/**
|
||||
* Curie BSP implementation of jerry_port_fatal.
|
||||
*/
|
||||
void jerry_port_fatal (jerry_fatal_code_t code)
|
||||
{
|
||||
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Jerry Fatal Error!\n");
|
||||
while (true);
|
||||
} /* jerry_port_fatal */
|
||||
|
||||
/**
|
||||
* Curie BSP implementation of jerry_port_get_time_zone.
|
||||
*/
|
||||
bool jerry_port_get_time_zone (jerry_time_zone_t *tz_p)
|
||||
{
|
||||
//EMPTY implementation
|
||||
tz_p->offset = 0;
|
||||
tz_p->daylight_saving_time = 0;
|
||||
|
||||
return true;
|
||||
} /* jerry_port_get_time_zone */
|
||||
|
||||
/**
|
||||
* Curie BSP implementation of jerry_port_get_current_time.
|
||||
*/
|
||||
double jerry_port_get_current_time ()
|
||||
{
|
||||
uint32_t uptime_ms = get_uptime_ms ();
|
||||
uint32_t epoch_time = uptime_to_epoch (uptime_ms);
|
||||
|
||||
return ((double) epoch_time) * 1000.0;
|
||||
} /* jerry_port_get_current_time */
|
78
third_party/jerryscript/targets/curie_bsp/source/setjmp.S
vendored
Normal file
78
third_party/jerryscript/targets/curie_bsp/source/setjmp.S
vendored
Normal file
|
@ -0,0 +1,78 @@
|
|||
/* Copyright 2014-2016 Samsung Electronics Co., Ltd.
|
||||
* Copyright 2016 Intel Corporation
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
.macro func _name
|
||||
.global \_name
|
||||
.type \_name, %function
|
||||
\_name:
|
||||
.endm
|
||||
.macro endfunc _name
|
||||
.size \_name, .-\_name
|
||||
.endm
|
||||
|
||||
/**
|
||||
* setjmp (jmp_buf env)
|
||||
*
|
||||
* See also:
|
||||
* longjmp
|
||||
*
|
||||
* @return 0 - if returns from direct call,
|
||||
* nonzero - if returns after longjmp.
|
||||
*/
|
||||
func setjmp
|
||||
mov %eax,(%eax);
|
||||
mov %ebx,0x4(%eax);
|
||||
mov %ecx,0x8(%eax);
|
||||
mov %edx,0xc(%eax);
|
||||
mov %esi,0x10(%eax);
|
||||
mov %edi,0x14(%eax);
|
||||
mov %ebp,0x18(%eax);
|
||||
mov %esp,0x1c(%eax);
|
||||
push %edx;
|
||||
mov 0x4(%esp),%edx;
|
||||
mov %edx,0x20(%eax);
|
||||
pop %edx;
|
||||
xor %eax,%eax;
|
||||
ret
|
||||
endfunc setjmp
|
||||
|
||||
/**
|
||||
* longjmp (jmp_buf env, int val)
|
||||
*
|
||||
* Note:
|
||||
* if val is not 0, then it would be returned from setjmp,
|
||||
* otherwise - 0 would be returned.
|
||||
*
|
||||
* See also:
|
||||
* setjmp
|
||||
*/
|
||||
func longjmp
|
||||
test %edx, %edx;
|
||||
jne . + 0x3;
|
||||
inc %edx;
|
||||
mov 0x4(%eax),%ebx;
|
||||
mov 0x8(%eax),%ecx;
|
||||
mov 0x10(%eax),%esi;
|
||||
mov 0x14(%eax),%edi;
|
||||
mov 0x18(%eax),%ebp;
|
||||
mov 0x1c(%eax),%esp;
|
||||
push %edx;
|
||||
mov 0x20(%eax),%edx;
|
||||
mov %edx,0x4(%esp);
|
||||
mov 0xc(%eax),%edx;
|
||||
pop %eax;
|
||||
ret
|
||||
endfunc longjmp
|
Loading…
Add table
Add a link
Reference in a new issue