Skip to content

Commit d7f26c8

Browse files
committed
add target port: curie_bsp
JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang zidong.jiang@intel.com
1 parent d1b0b58 commit d7f26c8

File tree

17 files changed

+1111
-0
lines changed

17 files changed

+1111
-0
lines changed

targets/curie_bsp/README.md

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
###About Curie BSP port
2+
[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).
3+
4+
This folder contains necessary files to integrate JerryScript with Intel® Curie BSP, so that JavaScript can run on Arduino 101 board (AKA Genuino 101).
5+
6+
### How to build
7+
#### 1.Preface
8+
9+
Curie BSP only support Ubuntu GNU/Linux as host OS envirenment.
10+
11+
Necessary hardwares
12+
* [FlySwatter2 JTAG debugger](https://www.tincantools.com/wiki/Flyswatter2)
13+
* [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)
14+
* [USB to TTL Serial Cable](https://www.adafruit.com/products/954)
15+
16+
#### 2. Prepare Curie BSP
17+
18+
You can refer to a detailed document [Curie BSP](https://github.com/CurieBSP/main/releases). But, we summary the main steps below:
19+
20+
##### 1. Get repo:
21+
```
22+
mkdir ~/bin
23+
wget http://commondatastorage.googleapis.com/git-repo-downloads/repo -O ~/bin/repo
24+
chmod a+x ~/bin/repo
25+
```
26+
27+
##### 2. In ``~/.bashrc`` add:
28+
```
29+
PATH=$PATH:~/bin
30+
```
31+
32+
##### 3. Change the working directory to ``Curie_BSP``
33+
```
34+
cd <path to Curie_BSP>
35+
```
36+
37+
##### 4. Initialize your repo:
38+
```
39+
repo init -u https://github.com/CurieBSP/manifest
40+
```
41+
42+
##### 5. Download the sources files:
43+
```
44+
repo sync -j 5 -d
45+
```
46+
47+
##### 6. Get toolchain (compilation/debug):
48+
Download [issm-toolchain-linux-2016-05-12.tar.gz](https://software.intel.com/en-us/articles/issm-toolchain-only-download), and uncompress it.
49+
**TOOLCHAIN_DIR** environment variable needs to match the toolchain destination folder
50+
You can use the command:``export TOOLCHAIN_DIR='path to files of the toolchain'``
51+
52+
Or you can just uncompress the toolchain tarball and copy the contents (`licensing readme.txt tools version.txt`) into `wearable_device_sw/external/toolchain`.
53+
54+
##### 7. Get BLE firmware:
55+
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
56+
57+
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.
58+
59+
##### 8. Get tools to flash the device:
60+
[https://01.org/android-ia/downloads/intel-platform-flash-tool-lite](https://01.org/android-ia/downloads/intel-platform-flash-tool-lite)
61+
62+
##### 9. One timesetup:
63+
In the directory ``Curie_BSP``
64+
```
65+
make -C wearable_device_sw/projects/curie_bsp_jerry/ one_time_setup
66+
```
67+
68+
#### 3. Build JerryScript and Curie BSP
69+
##### 1. Generate makefiles
70+
Run the Python script ``setup.py`` in ``jerryscript/targets/curie_bsp/`` with the full path or relative path of the ``Curie_BSP``:
71+
```
72+
python setup.py <path of Curie_BSP>
73+
```
74+
75+
##### 2. In the directory ``Curie_BSP``
76+
```
77+
mkdir out && cd $_
78+
make -f ../wearable_device_sw/projects/curie_bsp_jerry/Makefile setup
79+
make image
80+
```
81+
82+
##### 3. Connect JTAG Debugger and TTL Serial Cable to Arduino 101 as below:
83+
![](./image/connect.png)
84+
85+
##### 4. Flash the firmware
86+
```
87+
make flash FLASH_CONFIG=jtag_full
88+
```
89+
90+
91+
#### 4. Serial terminal
92+
Assume the serial port is ``ttyUSB0`` in ``/dev`` directory, we can type command ``screen ttyUSB0 115200`` to open a serial terminal. We can test the JavaScript command (eg. print ('Hello World!');) through inputting ``js e print ('Hello World!');``.
93+
94+
After the board boot successfully, you should see something like this:
95+
```
96+
Quark SE ID 16 Rev 0 A0
97+
ARC Core state: 0000400
98+
BOOT TARGET: 0
99+
6135|QRK| CFW| INFO| GPIO service init in progress..
100+
6307|ARC|MAIN| INFO| BSP init done
101+
6315|ARC| CFW| INFO| ADC service init in progress..
102+
6315|ARC| CFW| INFO| GPIO service init in progress...
103+
6315|ARC| CFW| INFO| GPIO service init in progress...
104+
6315|ARC|MAIN| INFO| CFW init done
105+
```
106+
To test the JavaScript command, you should add characters ``js e `` to the beginning of the JavaScript command, like this:
107+
``js e print ('Hello World!');``
108+
109+
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.
110+
111+
You can see the result through the screen:
112+
```
113+
js e print ('Hello World!');js e 1 ACK
114+
Hello World!
115+
undefined
116+
js e 1 OK
117+
```
118+
119+
`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!')`.
575 KB
Loading

targets/curie_bsp/include/alloca.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/* Copyright 2016 Intel Corporation
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
#ifndef ALLOCA_H
17+
#define ALLOCA_H
18+
19+
#define alloca(size) __builtin_alloca(size)
20+
21+
#endif
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* Copyright 2016 Intel Corporation
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
#ifndef INTTYPES_H
16+
#define INTTYPES_H
17+
18+
#endif
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/* Copyright 2015-2016 Samsung Electronics Co., Ltd.
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
#ifndef JERRY_LIBC_DEFS_H
16+
#define JERRY_LIBC_DEFS_H
17+
18+
#include <stdint.h>
19+
#include <stdbool.h>
20+
#include <stddef.h>
21+
22+
/**
23+
* Attributes
24+
*/
25+
#define __attr_unused___ __attribute__((unused))
26+
#define __attr_used___ __attribute__((used))
27+
#define __attr_noreturn___ __attribute__((noreturn))
28+
#define __attr_noinline___ __attribute__((noinline))
29+
30+
#define RAND_MAX (0x7fffffffu)
31+
32+
void __attribute__ ((noreturn)) exit (int);
33+
void __attribute__ ((noreturn)) abort (void);
34+
int rand (void);
35+
void srand (unsigned int);
36+
37+
#endif /* !DEFS_H */

targets/curie_bsp/include/setjmp.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/* Copyright 2015-2016 Samsung Electronics Co., Ltd.
2+
* Copyright 2016 University of Szeged.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
#ifndef JERRY_LIBC_SETJMP_H
17+
#define JERRY_LIBC_SETJMP_H
18+
19+
#include <stdint.h>
20+
21+
typedef uint64_t jmp_buf[14];
22+
23+
extern int setjmp (jmp_buf env);
24+
extern void longjmp (jmp_buf env, int val);
25+
26+
#endif /* !JERRY_LIBC_SETJMP_H */
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
CONFIG_AUTO_SERVICE_INIT=y
2+
CONFIG_CFW_PROXY=y
3+
CONFIG_CFW_QUARK_SE_HELPERS=y
4+
CONFIG_LOG_SLAVE=y
5+
CONFIG_MEM_POOL_DEF_PATH="$(PROJECT_PATH)/arc"
6+
CONFIG_OS_ZEPHYR=y
7+
CONFIG_SERVICES_QUARK_SE_ADC_IMPL=y
8+
CONFIG_SERVICES_QUARK_SE_GPIO_IMPL=y
9+
CONFIG_SOC_GPIO_AON=y
10+
CONFIG_SOC_GPIO=y
11+
CONFIG_SS_ADC=y
12+
CONFIG_SS_GPIO=y
13+
CONFIG_TCMD_SLAVE=y
14+
CONFIG_TCMD=y
15+
CONFIG_ZEPHYR_BOARD="arduino_101_sss"
16+
CONFIG_CONSOLE_HANDLER_SHELL=y
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright (c) 2016, Intel Corporation. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions are met:
6+
*
7+
* 1. Redistributions of source code must retain the above copyright notice,
8+
* this list of conditions and the following disclaimer.
9+
*
10+
* 2. Redistributions in binary form must reproduce the above copyright notice,
11+
* this list of conditions and the following disclaimer in the documentation
12+
* and/or other materials provided with the distribution.
13+
*
14+
* 3. Neither the name of the copyright holder nor the names of its contributors
15+
* may be used to endorse or promote products derived from this software without
16+
* specific prior written permission.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28+
* POSSIBILITY OF SUCH DAMAGE.
29+
*/
30+
/* infra */
31+
#include "infra/log.h"
32+
#include "infra/bsp.h"
33+
#include "infra/xloop.h"
34+
#include "cfw/cfw.h"
35+
36+
static xloop_t loop;
37+
38+
void main (void)
39+
{
40+
T_QUEUE queue = bsp_init ();
41+
42+
pr_info (LOG_MODULE_MAIN, "BSP init done");
43+
44+
cfw_init (queue);
45+
pr_info (LOG_MODULE_MAIN, "CFW init done");
46+
47+
xloop_init_from_queue (&loop, queue);
48+
49+
xloop_run (&loop);
50+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Definition of the memory pools used by balloc/bfree:
3+
* DECLARE_MEMORY_POOL( <index>, <size>, <count>, <align> )
4+
* <index> : must start at 0 and be of consecutive values *
5+
* <size> : size in bytes of each block from the pool
6+
* <count> : number of blocks in the pool
7+
*
8+
* * Pool definitions must be sorted according the block size
9+
* value: pool with <index> 0 must have the smallest <size>.
10+
*/
11+
12+
DECLARE_MEMORY_POOL(0,8,32)
13+
DECLARE_MEMORY_POOL(1,16,32)
14+
DECLARE_MEMORY_POOL(2,32,48)
15+
DECLARE_MEMORY_POOL(3,64,16)
16+
DECLARE_MEMORY_POOL(4,96,24)
17+
DECLARE_MEMORY_POOL(5,128,6)
18+
DECLARE_MEMORY_POOL(6,256,5)
19+
DECLARE_MEMORY_POOL(7,512,1)
20+
21+
#undef DECLARE_MEMORY_POOL
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright (c) 2016, Intel Corporation. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions are met:
6+
*
7+
* 1. Redistributions of source code must retain the above copyright notice,
8+
* this list of conditions and the following disclaimer.
9+
*
10+
* 2. Redistributions in binary form must reproduce the above copyright notice,
11+
* this list of conditions and the following disclaimer in the documentation
12+
* and/or other materials provided with the distribution.
13+
*
14+
* 3. Neither the name of the copyright holder nor the names of its contributors
15+
* may be used to endorse or promote products derived from this software without
16+
* specific prior written permission.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28+
* POSSIBILITY OF SUCH DAMAGE.
29+
*/
30+
31+
/**
32+
* Allow project to override this partition scheme
33+
* The following variables are allowed to be defined:
34+
*
35+
* QUARK_START_PAGE the first page where the QUARK code is located
36+
* QUARK_NB_PAGE the number of pages reserved for the QUARK. The ARC gets the
37+
* remaining pages (out of 148).
38+
*/
39+
#define QUARK_NB_PAGE 125
40+
#include "machine/soc/intel/quark_se/quark_se_mapping.h"

0 commit comments

Comments
 (0)