Skip to content

add target port: curie_bsp #1234

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 120 additions & 0 deletions targets/curie_bsp/README.md
Original file line number Diff line number Diff line change
@@ -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:
![](./image/connect.png)

##### 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!')`.
Binary file added targets/curie_bsp/image/connect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions targets/curie_bsp/include/alloca.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* 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 ALLOCA_H
#define ALLOCA_H

#define alloca(size) __builtin_alloca(size)

#endif /* !ALLOCA_H */
18 changes: 18 additions & 0 deletions targets/curie_bsp/include/inttypes.h
Original file line number Diff line number Diff line change
@@ -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 changes: 25 additions & 0 deletions targets/curie_bsp/include/setjmp.h
Original file line number Diff line number Diff line change
@@ -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 changes: 16 additions & 0 deletions targets/curie_bsp/jerry_app/arc/defconfig
Original file line number Diff line number Diff line change
@@ -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 changes: 35 additions & 0 deletions targets/curie_bsp/jerry_app/arc/main.c
Original file line number Diff line number Diff line change
@@ -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 changes: 36 additions & 0 deletions targets/curie_bsp/jerry_app/arc/memory_pool_list.def
Original file line number Diff line number Diff line change
@@ -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.
*/

/*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

License block missing.

* 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 changes: 30 additions & 0 deletions targets/curie_bsp/jerry_app/include/project_mapping.h
Original file line number Diff line number Diff line change
@@ -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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this file a special header? I don't see it included from anywhere. Moreover, it's not guarded by ifdef/define/endif preprocessor directives (which is usually bad practice for headers).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is a special header which is included by CurieBSP's bootloader.


#endif /* !PROJECT_MAPPING_H */
35 changes: 35 additions & 0 deletions targets/curie_bsp/jerry_app/quark/defconfig
Original file line number Diff line number Diff line change
@@ -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
Loading