mirror of
https://github.com/google/pebble.git
synced 2025-05-20 10:24:58 +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
56
third_party/jerryscript/targets/esp8266/LICENSE
vendored
Normal file
56
third_party/jerryscript/targets/esp8266/LICENSE
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
|
||||
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.
|
||||
|
||||
================================================================================
|
||||
|
||||
ESPRSSIF MIT License
|
||||
|
||||
Copyright (c) 2015 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
|
||||
|
||||
Permission is hereby granted for use on ESPRESSIF SYSTEMS ESP8266 only, in which case,
|
||||
it is free of charge, to any person obtaining a copy of this software and associated
|
||||
documentation files (the ¡°Software¡±), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
||||
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
|
||||
is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or
|
||||
substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED ¡°AS IS¡±, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
ÀÖöÎ MIT Ðí¿ÉÖ¤
|
||||
|
||||
°æÈ¨ (c) 2015 <ÀÖöÎÐÅÏ¢¿Æ¼¼£¨ÉϺ££©ÓÐÏÞ¹«Ë¾>
|
||||
|
||||
¸ÃÐí¿ÉÖ¤ÊÚȨ½öÏÞÓÚÀÖöÎÐÅÏ¢¿Æ¼¼ ESP8266 ²úÆ·µÄÓ¦Óÿª·¢¡£ÔÚ´ËÇé¿öÏ£¬¸ÃÐí¿ÉÖ¤Ãâ·ÑÊÚȨÈκλñµÃ¸Ã
|
||||
Èí¼þ¼°ÆäÏà¹ØÎĵµ£¨Í³³ÆÎª¡°Èí¼þ¡±£©µÄÈËÎÞÏÞÖÆµØ¾Óª¸ÃÈí¼þ£¬°üÀ¨ÎÞÏÞÖÆµÄʹÓᢸ´ÖÆ¡¢Ð޸ġ¢ºÏ²¢¡¢
|
||||
³ö°æ·¢ÐС¢É¢²¼¡¢ÔÙÊÚȨ¡¢¼°··ÊÛÈí¼þ¼°Èí¼þ¸±±¾µÄȨÀû¡£±»ÊÚȨÈËÔÚÏíÊÜÕâЩȨÀûµÄͬʱ£¬Ðè·þ´ÓÏÂÃæ
|
||||
µÄÌõ¼þ£º
|
||||
|
||||
ÔÚÈí¼þºÍÈí¼þµÄËùÓи±±¾Öж¼±ØÐë°üº¬ÒÔÉϵİæÈ¨ÉùÃ÷ºÍÊÚȨÉùÃ÷¡£
|
||||
|
||||
¸ÃÈí¼þ°´±¾À´µÄÑù×ÓÌṩ£¬Ã»ÓÐÈκÎÃ÷È·»ò°µº¬µÄµ£±££¬°üÀ¨µ«²»½öÏÞÓÚ¹ØÓÚÊÔÏúÐÔ¡¢ÊʺÏÄ³Ò»ÌØ¶¨ÓÃ;
|
||||
ºÍ·ÇÇÖȨµÄ±£Ö¤¡£×÷ÕߺͰæÈ¨³ÖÓÐÈËÔÚÈκÎÇé¿öϾù²»¾ÍÓÉÈí¼þ»òÈí¼þʹÓÃÒýÆðµÄÒÔºÏͬÐÎʽ¡¢ÃñÊÂÇÖȨ
|
||||
»òÆäËü·½Ê½Ìá³öµÄÈκÎË÷Åâ¡¢Ë𺦻òÆäËüÔðÈθºÔð¡£
|
||||
|
||||
|
||||
|
||||
|
146
third_party/jerryscript/targets/esp8266/Makefile
vendored
Normal file
146
third_party/jerryscript/targets/esp8266/Makefile
vendored
Normal file
|
@ -0,0 +1,146 @@
|
|||
# Copyright 2015-2016 Samsung Electronics Co., Ltd.
|
||||
#
|
||||
# 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.
|
||||
|
||||
#############################################################
|
||||
# Required variables for each makefile
|
||||
# Discard this section from all parent makefiles
|
||||
# Expected variables (with automatic defaults):
|
||||
# CSRCS (all "C" files in the dir)
|
||||
# SUBDIRS (all subdirs with a Makefile)
|
||||
# GEN_LIBS - list of libs to be generated ()
|
||||
# GEN_IMAGES - list of object file images to be generated ()
|
||||
# GEN_BINS - list of binaries to be generated ()
|
||||
# COMPONENTS_xxx - a list of libs/objs in the form
|
||||
# subdir/lib to be extracted and rolled up into
|
||||
# a generated lib/image xxx.a ()
|
||||
#
|
||||
# Tabsize : 8
|
||||
#
|
||||
TARGET = eagle
|
||||
FLAVOR = release
|
||||
#FLAVOR = debug
|
||||
|
||||
#EXTRA_CCFLAGS += -u
|
||||
|
||||
ifndef PDIR # {
|
||||
GEN_IMAGES= eagle.app.v6.out
|
||||
GEN_BINS= eagle.app.v6.bin
|
||||
SPECIAL_MKTARGETS=$(APP_MKTARGETS)
|
||||
SUBDIRS= user
|
||||
endif # } PDIR
|
||||
|
||||
LDDIR = $(SDK_PATH)/ld
|
||||
|
||||
CCFLAGS += -Os
|
||||
#CCFLAGS += -O0
|
||||
|
||||
TARGET_LDFLAGS = \
|
||||
-nostdlib \
|
||||
-Wl,-EL \
|
||||
--longcalls \
|
||||
--text-section-literals
|
||||
|
||||
ifeq ($(FLAVOR),debug)
|
||||
TARGET_LDFLAGS += -O0
|
||||
endif
|
||||
|
||||
ifeq ($(FLAVOR),release)
|
||||
TARGET_LDFLAGS += -Os
|
||||
endif
|
||||
|
||||
COMPONENTS_eagle.app.v6 = \
|
||||
user/libuser.a \
|
||||
|
||||
|
||||
LINKFLAGS_eagle.app.v6 = \
|
||||
-L$(SDK_PATH)/lib \
|
||||
-Wl,--gc-sections \
|
||||
-Wl,-Map,output.map \
|
||||
-nostdlib \
|
||||
-T$(LD_FILE) \
|
||||
-Wl,--no-check-sections \
|
||||
-u call_user_start \
|
||||
-Wl,-static \
|
||||
-Wl,--start-group \
|
||||
-lminic \
|
||||
-lgcc \
|
||||
-lhal \
|
||||
-lphy \
|
||||
-lpp \
|
||||
-lnet80211 \
|
||||
-lwpa \
|
||||
-lmain \
|
||||
-lfreertos \
|
||||
-llwip \
|
||||
-L./libs \
|
||||
-ljerrycore \
|
||||
-ljerryentry \
|
||||
-ljerrylibm \
|
||||
$(DEP_LIBS_eagle.app.v6) \
|
||||
./libs/lib_a-setjmp.o \
|
||||
-Wl,--end-group
|
||||
|
||||
|
||||
DEPENDS_eagle.app.v6 = \
|
||||
$(LD_FILE) \
|
||||
$(LDDIR)/eagle.rom.addr.v6.ld \
|
||||
./source/jerry_targetjs.h \
|
||||
./libs/libjerrylibm.a \
|
||||
./libs/libjerrycore.a \
|
||||
./libs/libjerryentry.a
|
||||
|
||||
|
||||
#############################################################
|
||||
# Configuration i.e. compile options etc.
|
||||
# Target specific stuff (defines etc.) goes in here!
|
||||
# Generally values applying to a tree are captured in the
|
||||
# makefile at its root level - these are then overridden
|
||||
# for a subtree within the makefile rooted therein
|
||||
#
|
||||
|
||||
#UNIVERSAL_TARGET_DEFINES = \
|
||||
|
||||
# Other potential configuration flags include:
|
||||
# -DTXRX_TXBUF_DEBUG
|
||||
# -DTXRX_RXBUF_DEBUG
|
||||
# -DWLAN_CONFIG_CCX
|
||||
CONFIGURATION_DEFINES = -DICACHE_FLASH
|
||||
|
||||
DEFINES += \
|
||||
$(UNIVERSAL_TARGET_DEFINES) \
|
||||
$(CONFIGURATION_DEFINES)
|
||||
|
||||
DDEFINES += \
|
||||
$(UNIVERSAL_TARGET_DEFINES) \
|
||||
$(CONFIGURATION_DEFINES)
|
||||
|
||||
|
||||
#############################################################
|
||||
# Recursion Magic - Don't touch this!!
|
||||
#
|
||||
# Each subtree potentially has an include directory
|
||||
# corresponding to the common APIs applicable to modules
|
||||
# rooted at that subtree. Accordingly, the INCLUDE PATH
|
||||
# of a module can only contain the include directories up
|
||||
# its parent path, and not its siblings
|
||||
#
|
||||
# Required for each makefile to inherit from the parent
|
||||
#
|
||||
|
||||
INCLUDES := $(INCLUDES) -I $(PDIR)include -I $(PDIR)source
|
||||
sinclude $(SDK_PATH)/Makefile
|
||||
|
||||
.PHONY: FORCE
|
||||
|
||||
FORCE:
|
125
third_party/jerryscript/targets/esp8266/Makefile.esp8266
vendored
Normal file
125
third_party/jerryscript/targets/esp8266/Makefile.esp8266
vendored
Normal file
|
@ -0,0 +1,125 @@
|
|||
# Copyright 2015-2016 Samsung Electronics Co., Ltd.
|
||||
#
|
||||
# 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.
|
||||
|
||||
# use TAB-8
|
||||
|
||||
CURDIR = `pwd`
|
||||
ESP_SDK_PATH ?= $(SDK_PATH)
|
||||
ESP_INC = $(ESP_SDK_PATH)/extra_include
|
||||
ESP_INC2 = $(ESP_SDK_PATH)/include
|
||||
ESP_LIB = $(ESP_SDK_PATH)/lib
|
||||
TYPE = release
|
||||
INTERM = build/obj-esp8266
|
||||
OUTPUT = build/bin/$(TYPE).esp8266
|
||||
SRCPATH = targets/esp8266/source
|
||||
COPYTARGET = targets/esp8266/libs
|
||||
USBDEVICE ?= /dev/ttyUSB0
|
||||
JERRYHEAP ?= 20
|
||||
ESPTOOL ?= /opt/Espressif/esptool-py/esptool.py
|
||||
|
||||
# compile flags
|
||||
ESP_CFLAGS := -D__TARGET_ESP8266 -D__attr_always_inline___=
|
||||
|
||||
MFORCE32 = `xtensa-lx106-elf-gcc --help=target | grep mforce-l32`
|
||||
|
||||
ifneq ($(MFORCE32),)
|
||||
# Your compiler supports the -mforce-l32 flag which means that
|
||||
# constants can be placed in ROM to free additional RAM
|
||||
ESP_CFLAGS += -DJERRY_CONST_DATA="__attribute__((aligned(4))) __attribute__((section(\".irom.text\")))"
|
||||
endif
|
||||
|
||||
ESP_CFLAGS += -Wl,-EL -fno-inline-functions
|
||||
ESP_CFLAGS += -ffunction-sections -fdata-sections
|
||||
ESP_CFLAGS += -mlongcalls -mtext-section-literals -mno-serialize-volatile
|
||||
ifneq ($(MFORCE32),)
|
||||
ESP_CFLAGS += -mforce-l32
|
||||
endif
|
||||
|
||||
# include path
|
||||
ESP_LIBS_INC :=$(CURDIR)/targets/esp8266/include
|
||||
ESP_LIBS_INC :=$(ESP_LIBS_INC);$(ESP_INC2)
|
||||
ESP_LIBS_INC :=$(ESP_LIBS_INC);$(ESP_INC2)/espressif
|
||||
ESP_LIBS_INC :=$(ESP_LIBS_INC);$(ESP_INC2)/freertos
|
||||
ESP_LIBS_INC :=$(ESP_LIBS_INC);$(ESP_INC2)/json
|
||||
ESP_LIBS_INC :=$(ESP_LIBS_INC);$(ESP_INC2)/lwip
|
||||
ESP_LIBS_INC :=$(ESP_LIBS_INC);$(ESP_INC2)/ssl
|
||||
|
||||
# jerry related source files
|
||||
JERRY_BUILD_FILES := $(SRCPATH)/jerry_extapi.c
|
||||
JERRY_BUILD_FILES := $(JERRY_BUILD_FILES);$(SRCPATH)/jerry_run.c
|
||||
|
||||
|
||||
.PHONY: jerry js2c mkbin check-env flash clean
|
||||
|
||||
|
||||
all: check-env jerry js2c mkbin
|
||||
|
||||
|
||||
jerry:
|
||||
mkdir -p $(INTERM)
|
||||
mkdir -p $(OUTPUT)
|
||||
mkdir -p $(COPYTARGET)
|
||||
cmake -B$(INTERM) -H./ \
|
||||
-DENABLE_LTO=OFF \
|
||||
-DENABLE_VALGRIND=OFF \
|
||||
-DCMAKE_TOOLCHAIN_FILE=build/configs/toolchain_external.cmake \
|
||||
-DEXTERNAL_CMAKE_SYSTEM_PROCESSOR=xtensia-lx106 \
|
||||
-DEXTERNAL_CMAKE_C_COMPILER=xtensa-lx106-elf-gcc \
|
||||
-DEXTERNAL_CMAKE_C_COMPILER_ID=GNU \
|
||||
-DEXTERNAL_BUILD_ENTRY_FILE="$(JERRY_BUILD_FILES)" \
|
||||
-DEXTERNAL_COMPILE_FLAGS="$(ESP_CFLAGS)" \
|
||||
-DEXTERNAL_LIBC_INTERFACE="$(ESP_INC)" \
|
||||
-DEXTERNAL_LIBS_INTERFACE="$(ESP_LIBS_INC)" \
|
||||
-DEXTERNAL_MEM_HEAP_SIZE_KB=$(JERRYHEAP)
|
||||
|
||||
make -C $(INTERM) $(TYPE).external
|
||||
cp `cat $(INTERM)/$(TYPE).external/list` $(OUTPUT)/.
|
||||
cp $(OUTPUT)/lib$(TYPE).jerry-core.a $(COPYTARGET)/libjerrycore.a
|
||||
cp $(OUTPUT)/lib$(TYPE).jerry-libm.lib.a $(COPYTARGET)/libjerrylibm.a
|
||||
cp $(INTERM)/lib$(TYPE).external-entry.a $(OUTPUT)/.
|
||||
cp $(OUTPUT)/lib$(TYPE).external-entry.a $(COPYTARGET)/libjerryentry.a
|
||||
|
||||
|
||||
js2c:
|
||||
cd targets/esp8266; ../tools/js2c.py
|
||||
|
||||
|
||||
mkbin:
|
||||
cd targets/esp8266; \
|
||||
make clean; \
|
||||
BOOT=new APP=1 SPI_SPEED=40 SPI_MODE=QIO SPI_SIZE_MAP=3 make; \
|
||||
BOOT=new APP=2 SPI_SPEED=40 SPI_MODE=QIO SPI_SIZE_MAP=3 make
|
||||
|
||||
|
||||
check-env:
|
||||
ifndef SDK_PATH
|
||||
$(error SDK_PATH is undefined for ESP8266)
|
||||
endif
|
||||
ifndef BIN_PATH
|
||||
$(error BIN_PATH is undefined for ESP8266)
|
||||
endif
|
||||
|
||||
|
||||
flash:
|
||||
$(ESPTOOL) --port $(USBDEVICE) write_flash \
|
||||
0x00000 $(SDK_PATH)/bin/"boot_v1.4(b1).bin" \
|
||||
0x01000 $(BIN_PATH)/upgrade/user1.2048.new.3.bin \
|
||||
0x81000 $(BIN_PATH)/upgrade/user2.2048.new.3.bin \
|
||||
0x1FC000 $(SDK_PATH)/bin/esp_init_data_default.bin \
|
||||
0x1FE000 $(SDK_PATH)/bin/blank.bin
|
||||
|
||||
|
||||
clean:
|
||||
rm -rf $(INTERM)
|
||||
rm -rf $(OUTPUT)
|
75
third_party/jerryscript/targets/esp8266/docs/ESP-PATCHFORJERRYSCRIPT.md
vendored
Normal file
75
third_party/jerryscript/targets/esp8266/docs/ESP-PATCHFORJERRYSCRIPT.md
vendored
Normal file
|
@ -0,0 +1,75 @@
|
|||
#### Apply patch to ESP8266 SDK
|
||||
|
||||
As `iram` is quite small to fit all the codes but linker tries to put it there.
|
||||
To force JerryScript codes to be placed at the `irom` section,
|
||||
need to change the order and tell the linker as below;
|
||||
|
||||
```
|
||||
diff --git a/ld/eagle.app.v6.common.ld b/ld/eagle.app.v6.common.ld
|
||||
index caf8e32..dadaceb 100644
|
||||
--- a/ld/eagle.app.v6.common.ld
|
||||
+++ b/ld/eagle.app.v6.common.ld
|
||||
@@ -151,6 +151,21 @@ SECTIONS
|
||||
} >dram0_0_seg :dram0_0_bss_phdr
|
||||
/* __stack = 0x3ffc8000; */
|
||||
|
||||
+ .irom0.text : ALIGN(4)
|
||||
+ {
|
||||
+ _irom0_text_start = ABSOLUTE(.);
|
||||
+ *(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text)
|
||||
+ *(.literal.* .text.*)
|
||||
+ _irom0_text_end = ABSOLUTE(.);
|
||||
+
|
||||
+ _jerry_text_start = ABSOLUTE(.);
|
||||
+ *\libjerryentry.a:*(.text*)
|
||||
+ *\libjerrycore.a:*(.text*)
|
||||
+ *\libjerrylibm.a:*(.text*)
|
||||
+ _jerry_text_end = ABSOLUTE(.);
|
||||
+
|
||||
+ } >irom0_0_seg :irom0_0_phdr
|
||||
+
|
||||
.text : ALIGN(4)
|
||||
{
|
||||
_stext = .;
|
||||
@@ -199,13 +214,6 @@ SECTIONS
|
||||
_lit4_end = ABSOLUTE(.);
|
||||
} >iram1_0_seg :iram1_0_phdr
|
||||
|
||||
- .irom0.text : ALIGN(4)
|
||||
- {
|
||||
- _irom0_text_start = ABSOLUTE(.);
|
||||
- *(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom.text)
|
||||
- *(.literal.* .text.*)
|
||||
- _irom0_text_end = ABSOLUTE(.);
|
||||
- } >irom0_0_seg :irom0_0_phdr
|
||||
}
|
||||
|
||||
/* get ROM code address */
|
||||
diff --git a/ld/eagle.app.v6.ld b/ld/eagle.app.v6.ld
|
||||
index 3e7ec1b..4a9ab5b 100644
|
||||
--- a/ld/eagle.app.v6.ld
|
||||
+++ b/ld/eagle.app.v6.ld
|
||||
@@ -26,7 +26,7 @@ MEMORY
|
||||
dport0_0_seg : org = 0x3FF00000, len = 0x10
|
||||
dram0_0_seg : org = 0x3FFE8000, len = 0x14000
|
||||
iram1_0_seg : org = 0x40100000, len = 0x8000
|
||||
- irom0_0_seg : org = 0x40240000, len = 0x3C000
|
||||
+ irom0_0_seg : org = 0x40240000, len = 0xB0000
|
||||
}
|
||||
|
||||
INCLUDE "../ld/eagle.app.v6.common.ld"
|
||||
```
|
||||
|
||||
Second file is to modify `irom` size so that it can hold all the codes and data.
|
||||
This can be done by giving another `SPI_SIZE_MAP`.
|
||||
For now, I'll use this manual modification.
|
||||
|
||||
|
||||
#### Need to get setjmp / longjmp
|
||||
|
||||
Extract and copy from the SDK.
|
||||
|
||||
```
|
||||
cd ~/harmony/jerryscript/targets/esp8266/libs
|
||||
ar -xv $SDK_PATH/lib/libcirom.a lib_a-setjmp.o
|
||||
```
|
150
third_party/jerryscript/targets/esp8266/docs/ESP-PREREQUISITES.md
vendored
Normal file
150
third_party/jerryscript/targets/esp8266/docs/ESP-PREREQUISITES.md
vendored
Normal file
|
@ -0,0 +1,150 @@
|
|||
#### Preparation
|
||||
|
||||
##### Accessories
|
||||
|
||||
You need,
|
||||
* 3.3V power supply. You can use bread board power (+5V, +3.3V). I used LM317 like this;
|
||||
* Use [LM317](http://www.ti.com/lit/ds/symlink/lm317.pdf)
|
||||
* R1 = 330 Ohm, R2 = 545 Ohm (1K + 1.2K in parallel)
|
||||
* 5V 2A adaptor
|
||||
* USB to RS-232 Serial + RS-232 Serial to Digital or USB-to-RS232 TTL converter
|
||||
|
||||
#### Toolchain
|
||||
|
||||
Reference [Toolchain](https://github.com/esp8266/esp8266-wiki/wiki/Toolchain) page.
|
||||
|
||||
I've slightly changed the step to use SDK from Espressif official SDK
|
||||
(https://github.com/espressif/esp_iot_rtos_sdk)
|
||||
|
||||
##### Toolchain:
|
||||
|
||||
dependencies for x86
|
||||
```
|
||||
sudo apt-get install git autoconf build-essential gperf \
|
||||
bison flex texinfo libtool libncurses5-dev wget \
|
||||
gawk libc6-dev-i386 python-serial libexpat-dev
|
||||
sudo mkdir /opt/Espressif
|
||||
sudo chown $USER /opt/Espressif/
|
||||
```
|
||||
|
||||
dependencies for x64
|
||||
```
|
||||
sudo apt-get install git autoconf build-essential gperf \
|
||||
bison flex texinfo libtool libncurses5-dev wget \
|
||||
gawk libc6-dev-amd64 python-serial libexpat-dev
|
||||
sudo mkdir /opt/Espressif
|
||||
sudo chown $USER /opt/Espressif/
|
||||
```
|
||||
|
||||
crosstool-NG
|
||||
```
|
||||
cd /opt/Espressif
|
||||
git clone -b lx106-g++-1.21.0 git://github.com/jcmvbkbc/crosstool-NG.git
|
||||
cd crosstool-NG
|
||||
./bootstrap && ./configure --prefix=`pwd` && make && make install
|
||||
./ct-ng xtensa-lx106-elf
|
||||
./ct-ng build
|
||||
```
|
||||
add path to environment file such as `.profile`
|
||||
```
|
||||
PATH=$PWD/builds/xtensa-lx106-elf/bin:$PATH
|
||||
```
|
||||
|
||||
##### Espressif SDK: use Espressif official
|
||||
|
||||
```
|
||||
cd /opt/Esprissif
|
||||
git clone https://github.com/espressif/ESP8266_RTOS_SDK.git ESP8266_RTOS_SDK.git
|
||||
ln -s ESP8266_RTOS_SDK.git ESP8266_SDK
|
||||
cd ESP8266_SDK
|
||||
git checkout -b jerry a2b413ad2996450fe2f173b6afab243f6e1249aa
|
||||
```
|
||||
|
||||
We use SDK 1.2.0 version which has stdlib.h and others. Latest 1.3.0 version,
|
||||
as of writing this document, doesn't have it.
|
||||
(If anyone knows how to use latest version, please add an issue or send a PR.)
|
||||
|
||||
|
||||
set two environment variables such as in .profile
|
||||
```
|
||||
export SDK_PATH=/opt/Espressif/ESP8266_SDK
|
||||
export BIN_PATH=(to output folder path)
|
||||
```
|
||||
|
||||
##### Xtensa libraries and headers:
|
||||
```
|
||||
cd /opt/Espressif/ESP8266_SDK
|
||||
wget -O lib/libhal.a https://github.com/esp8266/esp8266-wiki/raw/master/libs/libhal.a
|
||||
```
|
||||
|
||||
##### ESP image tool
|
||||
```
|
||||
cd /opt/Espressif
|
||||
wget -O esptool_0.0.2-1_i386.deb https://github.com/esp8266/esp8266-wiki/raw/master/deb/esptool_0.0.2-1_i386.deb
|
||||
sudo dpkg -i esptool_0.0.2-1_i386.deb
|
||||
```
|
||||
|
||||
##### ESP upload tool
|
||||
```
|
||||
cd /opt/Espressif
|
||||
git clone https://github.com/themadinventor/esptool esptool-py
|
||||
sudo ln -s $PWD/esptool-py/esptool.py crosstool-NG/builds/xtensa-lx106-elf/bin/esptool.py
|
||||
```
|
||||
|
||||
#### Test writing with Blinky example
|
||||
|
||||
##### Get the source
|
||||
|
||||
found one example that works with SDK V1.2 (which is based on FreeRTOS, as of writing)
|
||||
|
||||
* https://github.com/mattcallow/esp8266-sdk/tree/master/rtos_apps/01blinky
|
||||
|
||||
|
||||
##### Compile
|
||||
|
||||
Read `2A-ESP8266__IOT_SDK_User_Manual_EN` document in
|
||||
[this](http://bbs.espressif.com/viewtopic.php?f=51&t=1024) link.
|
||||
|
||||
It's configured 2048KB flash
|
||||
```
|
||||
BOOT=new APP=1 SPI_SPEED=80 SPI_MODE=QIO SPI_SIZE_MAP=5 make
|
||||
BOOT=new APP=2 SPI_SPEED=80 SPI_MODE=QIO SPI_SIZE_MAP=5 make
|
||||
```
|
||||
|
||||
or old way... this works not sure this is ok.
|
||||
```
|
||||
make BOOT=new APP=0 SPI_SPEED=80 SPI_MODE=QIO SPI_SIZE_MAP=2
|
||||
```
|
||||
|
||||
##### Flashing
|
||||
|
||||
* power off ESP8266 board
|
||||
* connect GPIO0 to GND, connect GPIO2 to VCC
|
||||
* power on
|
||||
* write
|
||||
|
||||
```
|
||||
sudo /opt/Espressif/esptool-py/esptool.py \
|
||||
--port /dev/ttyUSB0 write_flash \
|
||||
0x00000 $SDK_PATH/bin/"boot_v1.4(b1).bin" \
|
||||
0x01000 $BIN_PATH/upgrade/user1.2048.new.5.bin \
|
||||
0x101000 $BIN_PATH/upgrade/user2.2048.new.5.bin \
|
||||
0x3FE000 $SDK_PATH/bin/blank.bin \
|
||||
0x3FC000 $SDK_PATH/bin/esp_init_data_default.bin
|
||||
```
|
||||
_change `/dev/ttyUSB1` to whatever you have._
|
||||
|
||||
or the old way...this works not sure this is ok.
|
||||
```
|
||||
cd $BIN_PATH
|
||||
sudo /opt/Espressif/esptool-py/esptool.py \
|
||||
--port /dev/ttyUSB0 write_flash \
|
||||
0x00000 eagle.flash.bin 0x40000 eagle.irom0text.bin
|
||||
```
|
||||
|
||||
* power off
|
||||
* disconnect GPIO0 so that it is floating
|
||||
* connect GPIO2 with serial of 470 Ohm + LED and to GND
|
||||
* power On
|
||||
|
||||
LED should blink on and off every second
|
165
third_party/jerryscript/targets/esp8266/gen_misc.sh
vendored
Normal file
165
third_party/jerryscript/targets/esp8266/gen_misc.sh
vendored
Normal file
|
@ -0,0 +1,165 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo "gen_misc.sh version 20150826"
|
||||
echo ""
|
||||
|
||||
if [ $SDK_PATH ]; then
|
||||
echo "SDK_PATH:"
|
||||
echo "$SDK_PATH"
|
||||
echo ""
|
||||
else
|
||||
echo "ERROR: Please export SDK_PATH firstly, exit!!!"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ $BIN_PATH ]; then
|
||||
echo "BIN_PATH:"
|
||||
echo "$BIN_PATH"
|
||||
echo ""
|
||||
else
|
||||
echo "ERROR: Please export BIN_PATH firstly, exit!!!"
|
||||
exit
|
||||
fi
|
||||
|
||||
echo "Please check SDK_PATH & BIN_PATH, enter (Y/y) to continue:"
|
||||
read input
|
||||
|
||||
if [[ $input != Y ]] && [[ $input != y ]]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
echo "Please follow below steps(1-5) to generate specific bin(s):"
|
||||
echo "STEP 1: use boot_v1.2+ by default"
|
||||
boot=new
|
||||
|
||||
echo "boot mode: $boot"
|
||||
echo ""
|
||||
|
||||
echo "STEP 2: choose bin generate(0=eagle.flash.bin+eagle.irom0text.bin, 1=user1.bin, 2=user2.bin)"
|
||||
echo "enter (0/1/2, default 0):"
|
||||
read input
|
||||
|
||||
if [ -z "$input" ]; then
|
||||
if [ $boot != none ]; then
|
||||
boot=none
|
||||
echo "ignore boot"
|
||||
fi
|
||||
app=0
|
||||
echo "generate bin: eagle.flash.bin+eagle.irom0text.bin"
|
||||
elif [ $input == 1 ]; then
|
||||
if [ $boot == none ]; then
|
||||
app=0
|
||||
echo "choose no boot before"
|
||||
echo "generate bin: eagle.flash.bin+eagle.irom0text.bin"
|
||||
else
|
||||
app=1
|
||||
echo "generate bin: user1.bin"
|
||||
fi
|
||||
elif [ $input == 2 ]; then
|
||||
if [ $boot == none ]; then
|
||||
app=0
|
||||
echo "choose no boot before"
|
||||
echo "generate bin: eagle.flash.bin+eagle.irom0text.bin"
|
||||
else
|
||||
app=2
|
||||
echo "generate bin: user2.bin"
|
||||
fi
|
||||
else
|
||||
if [ $boot != none ]; then
|
||||
boot=none
|
||||
echo "ignore boot"
|
||||
fi
|
||||
app=0
|
||||
echo "generate bin: eagle.flash.bin+eagle.irom0text.bin"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
echo "STEP 3: choose spi speed(0=20MHz, 1=26.7MHz, 2=40MHz, 3=80MHz)"
|
||||
echo "enter (0/1/2/3, default 2):"
|
||||
read input
|
||||
|
||||
if [ -z "$input" ]; then
|
||||
spi_speed=40
|
||||
elif [ $input == 0 ]; then
|
||||
spi_speed=20
|
||||
elif [ $input == 1 ]; then
|
||||
spi_speed=26.7
|
||||
elif [ $input == 3 ]; then
|
||||
spi_speed=80
|
||||
else
|
||||
spi_speed=40
|
||||
fi
|
||||
|
||||
echo "spi speed: $spi_speed MHz"
|
||||
echo ""
|
||||
|
||||
echo "STEP 4: choose spi mode(0=QIO, 1=QOUT, 2=DIO, 3=DOUT)"
|
||||
echo "enter (0/1/2/3, default 0):"
|
||||
read input
|
||||
|
||||
if [ -z "$input" ]; then
|
||||
spi_mode=QIO
|
||||
elif [ $input == 1 ]; then
|
||||
spi_mode=QOUT
|
||||
elif [ $input == 2 ]; then
|
||||
spi_mode=DIO
|
||||
elif [ $input == 3 ]; then
|
||||
spi_mode=DOUT
|
||||
else
|
||||
spi_mode=QIO
|
||||
fi
|
||||
|
||||
echo "spi mode: $spi_mode"
|
||||
echo ""
|
||||
|
||||
echo "STEP 5: choose spi size and map"
|
||||
echo " 0= 512KB( 256KB+ 256KB)"
|
||||
echo " 2=1024KB( 512KB+ 512KB)"
|
||||
echo " 3=2048KB( 512KB+ 512KB)"
|
||||
echo " 4=4096KB( 512KB+ 512KB)"
|
||||
echo " 5=2048KB(1024KB+1024KB)"
|
||||
echo " 6=4096KB(1024KB+1024KB)"
|
||||
echo "enter (0/2/3/4/5/6, default 0):"
|
||||
read input
|
||||
|
||||
if [ -z "$input" ]; then
|
||||
spi_size_map=0
|
||||
echo "spi size: 512KB"
|
||||
echo "spi ota map: 256KB + 256KB"
|
||||
elif [ $input == 2 ]; then
|
||||
spi_size_map=2
|
||||
echo "spi size: 1024KB"
|
||||
echo "spi ota map: 512KB + 512KB"
|
||||
elif [ $input == 3 ]; then
|
||||
spi_size_map=3
|
||||
echo "spi size: 2048KB"
|
||||
echo "spi ota map: 512KB + 512KB"
|
||||
elif [ $input == 4 ]; then
|
||||
spi_size_map=4
|
||||
echo "spi size: 4096KB"
|
||||
echo "spi ota map: 512KB + 512KB"
|
||||
elif [ $input == 5 ]; then
|
||||
spi_size_map=5
|
||||
echo "spi size: 2048KB"
|
||||
echo "spi ota map: 1024KB + 1024KB"
|
||||
elif [ $input == 6 ]; then
|
||||
spi_size_map=6
|
||||
echo "spi size: 4096KB"
|
||||
echo "spi ota map: 1024KB + 1024KB"
|
||||
else
|
||||
spi_size_map=0
|
||||
echo "spi size: 512KB"
|
||||
echo "spi ota map: 256KB + 256KB"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
echo "start..."
|
||||
echo ""
|
||||
|
||||
make clean
|
||||
|
||||
make BOOT=$boot APP=$app SPI_SPEED=$spi_speed SPI_MODE=$spi_mode SPI_SIZE_MAP=$spi_size_map
|
151
third_party/jerryscript/targets/esp8266/include/esp8266_gpio.h
vendored
Normal file
151
third_party/jerryscript/targets/esp8266/include/esp8266_gpio.h
vendored
Normal file
|
@ -0,0 +1,151 @@
|
|||
/* Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014 -2016 Espressif System
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __ESP82666_GPIO_H__
|
||||
#define __ESP82666_GPIO_H__
|
||||
|
||||
#define GPIO_Pin_0 (BIT(0)) /* Pin 0 selected */
|
||||
#define GPIO_Pin_1 (BIT(1)) /* Pin 1 selected */
|
||||
#define GPIO_Pin_2 (BIT(2)) /* Pin 2 selected */
|
||||
#define GPIO_Pin_3 (BIT(3)) /* Pin 3 selected */
|
||||
#define GPIO_Pin_4 (BIT(4)) /* Pin 4 selected */
|
||||
#define GPIO_Pin_5 (BIT(5)) /* Pin 5 selected */
|
||||
#define GPIO_Pin_6 (BIT(6)) /* Pin 6 selected */
|
||||
#define GPIO_Pin_7 (BIT(7)) /* Pin 7 selected */
|
||||
#define GPIO_Pin_8 (BIT(8)) /* Pin 8 selected */
|
||||
#define GPIO_Pin_9 (BIT(9)) /* Pin 9 selected */
|
||||
#define GPIO_Pin_10 (BIT(10)) /* Pin 10 selected */
|
||||
#define GPIO_Pin_11 (BIT(11)) /* Pin 11 selected */
|
||||
#define GPIO_Pin_12 (BIT(12)) /* Pin 12 selected */
|
||||
#define GPIO_Pin_13 (BIT(13)) /* Pin 13 selected */
|
||||
#define GPIO_Pin_14 (BIT(14)) /* Pin 14 selected */
|
||||
#define GPIO_Pin_15 (BIT(15)) /* Pin 15 selected */
|
||||
#define GPIO_Pin_All (0xFFFF) /* All pins selected */
|
||||
|
||||
#define GPIO_PIN_REG_0 PERIPHS_IO_MUX_GPIO0_U
|
||||
#define GPIO_PIN_REG_1 PERIPHS_IO_MUX_U0TXD_U
|
||||
#define GPIO_PIN_REG_2 PERIPHS_IO_MUX_GPIO2_U
|
||||
#define GPIO_PIN_REG_3 PERIPHS_IO_MUX_U0RXD_U
|
||||
#define GPIO_PIN_REG_4 PERIPHS_IO_MUX_GPIO4_U
|
||||
#define GPIO_PIN_REG_5 PERIPHS_IO_MUX_GPIO5_U
|
||||
#define GPIO_PIN_REG_6 PERIPHS_IO_MUX_SD_CLK_U
|
||||
#define GPIO_PIN_REG_7 PERIPHS_IO_MUX_SD_DATA0_U
|
||||
#define GPIO_PIN_REG_8 PERIPHS_IO_MUX_SD_DATA1_U
|
||||
#define GPIO_PIN_REG_9 PERIPHS_IO_MUX_SD_DATA2_U
|
||||
#define GPIO_PIN_REG_10 PERIPHS_IO_MUX_SD_DATA3_U
|
||||
#define GPIO_PIN_REG_11 PERIPHS_IO_MUX_SD_CMD_U
|
||||
#define GPIO_PIN_REG_12 PERIPHS_IO_MUX_MTDI_U
|
||||
#define GPIO_PIN_REG_13 PERIPHS_IO_MUX_MTCK_U
|
||||
#define GPIO_PIN_REG_14 PERIPHS_IO_MUX_MTMS_U
|
||||
#define GPIO_PIN_REG_15 PERIPHS_IO_MUX_MTDO_U
|
||||
|
||||
#define GPIO_PIN_REG(i) \
|
||||
(i==0) ? GPIO_PIN_REG_0: \
|
||||
(i==1) ? GPIO_PIN_REG_1: \
|
||||
(i==2) ? GPIO_PIN_REG_2: \
|
||||
(i==3) ? GPIO_PIN_REG_3: \
|
||||
(i==4) ? GPIO_PIN_REG_4: \
|
||||
(i==5) ? GPIO_PIN_REG_5: \
|
||||
(i==6) ? GPIO_PIN_REG_6: \
|
||||
(i==7) ? GPIO_PIN_REG_7: \
|
||||
(i==8) ? GPIO_PIN_REG_8: \
|
||||
(i==9) ? GPIO_PIN_REG_9: \
|
||||
(i==10)? GPIO_PIN_REG_10: \
|
||||
(i==11)? GPIO_PIN_REG_11: \
|
||||
(i==12)? GPIO_PIN_REG_12: \
|
||||
(i==13)? GPIO_PIN_REG_13: \
|
||||
(i==14)? GPIO_PIN_REG_14: \
|
||||
GPIO_PIN_REG_15
|
||||
|
||||
#define GPIO_PIN_ADDR(i) (GPIO_PIN0_ADDRESS + i*4)
|
||||
|
||||
#define GPIO_ID_IS_PIN_REGISTER(reg_id) ((reg_id >= GPIO_ID_PIN0) && (reg_id <= GPIO_ID_PIN(GPIO_PIN_COUNT-1)))
|
||||
|
||||
#define GPIO_REGID_TO_PINIDX(reg_id) ((reg_id) - GPIO_ID_PIN0)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GPIO_PIN_INTR_DISABLE = 0,
|
||||
GPIO_PIN_INTR_POSEDGE = 1,
|
||||
GPIO_PIN_INTR_NEGEDGE = 2,
|
||||
GPIO_PIN_INTR_ANYEGDE = 3,
|
||||
GPIO_PIN_INTR_LOLEVEL = 4,
|
||||
GPIO_PIN_INTR_HILEVEL = 5
|
||||
} GPIO_INT_TYPE;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GPIO_Mode_Input = 0x0,
|
||||
GPIO_Mode_Out_OD,
|
||||
GPIO_Mode_Output ,
|
||||
GPIO_Mode_Sigma_Delta
|
||||
} GPIOMode_TypeDef;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GPIO_PullUp_DIS = 0x0,
|
||||
GPIO_PullUp_EN = 0x1
|
||||
} GPIO_Pullup_IF;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16 GPIO_Pin;
|
||||
GPIOMode_TypeDef GPIO_Mode;
|
||||
GPIO_Pullup_IF GPIO_Pullup;
|
||||
GPIO_INT_TYPE GPIO_IntrType;
|
||||
} GPIO_ConfigTypeDef;
|
||||
|
||||
#define GPIO_OUTPUT_SET(gpio_no, bit_value) gpio_output_conf (bit_value<<gpio_no, \
|
||||
((~bit_value)&0x01)<<gpio_no, 1<<gpio_no, 0)
|
||||
|
||||
#define GPIO_OUTPUT(gpio_bits, bit_value) do { \
|
||||
if (bit_value) { gpio_output_conf (gpio_bits, 0, gpio_bits, 0); } \
|
||||
else { gpio_output_conf(0, gpio_bits, gpio_bits, 0); } \
|
||||
} while (0)
|
||||
|
||||
#define GPIO_DIS_OUTPUT(gpio_no) gpio_output_conf (0, 0, 0, 1 << gpio_no)
|
||||
#define GPIO_AS_INPUT(gpio_bits) gpio_output_conf (0, 0, 0, gpio_bits)
|
||||
#define GPIO_AS_OUTPUT(gpio_bits) gpio_output_conf (0, 0, gpio_bits, 0)
|
||||
#define GPIO_INPUT_GET(gpio_no) ((gpio_input_get () >> gpio_no)&BIT0)
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
void gpio16_output_conf (void);
|
||||
void gpio16_output_set (uint8 value);
|
||||
void gpio16_input_conf (void);
|
||||
uint8 gpio16_input_get (void);
|
||||
|
||||
void gpio_output_conf (uint32 set_mask, uint32 clear_mask, uint32 enable_mask, uint32 disable_mask);
|
||||
void gpio_intr_handler_register (void *fn);
|
||||
void gpio_pin_wakeup_enable (uint32 i, GPIO_INT_TYPE intr_state);
|
||||
void gpio_pin_wakeup_disable ();
|
||||
void gpio_pin_intr_state_set (uint32 i, GPIO_INT_TYPE intr_state);
|
||||
uint32 gpio_input_get (void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
48
third_party/jerryscript/targets/esp8266/include/esp8266_uart.h
vendored
Normal file
48
third_party/jerryscript/targets/esp8266/include/esp8266_uart.h
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014 -2016 Espressif System
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __ESP8266_UART_H__
|
||||
#define __ESP8266_UART_H__
|
||||
|
||||
typedef enum {
|
||||
UART0 = 0x0,
|
||||
UART1 = 0x1,
|
||||
} UART_Port;
|
||||
|
||||
typedef enum {
|
||||
BIT_RATE_300 = 300,
|
||||
BIT_RATE_600 = 600,
|
||||
BIT_RATE_1200 = 1200,
|
||||
BIT_RATE_2400 = 2400,
|
||||
BIT_RATE_4800 = 4800,
|
||||
BIT_RATE_9600 = 9600,
|
||||
BIT_RATE_19200 = 19200,
|
||||
BIT_RATE_38400 = 38400,
|
||||
BIT_RATE_57600 = 57600,
|
||||
BIT_RATE_74880 = 74880,
|
||||
BIT_RATE_115200 = 115200,
|
||||
BIT_RATE_230400 = 230400,
|
||||
BIT_RATE_460800 = 460800,
|
||||
BIT_RATE_921600 = 921600,
|
||||
BIT_RATE_1843200 = 1843200,
|
||||
BIT_RATE_3686400 = 3686400,
|
||||
} UART_BautRate;
|
||||
|
||||
#endif
|
35
third_party/jerryscript/targets/esp8266/include/jerry_extapi.h
vendored
Normal file
35
third_party/jerryscript/targets/esp8266/include/jerry_extapi.h
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
/* Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* 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 __JERRY_EXTAPI_H__
|
||||
#define __JERRY_EXTAPI_H__
|
||||
|
||||
#define JERRY_STANDALONE_EXIT_CODE_OK (0)
|
||||
#define JERRY_STANDALONE_EXIT_CODE_FAIL (1)
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
void js_register_functions (void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
34
third_party/jerryscript/targets/esp8266/include/jerry_run.h
vendored
Normal file
34
third_party/jerryscript/targets/esp8266/include/jerry_run.h
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
/* Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* 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 __JERRY_RUN_H__
|
||||
#define __JERRY_RUN_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
int js_entry (const char *source_p, const size_t source_size);
|
||||
int js_eval (const char *source_p, const size_t source_size);
|
||||
int js_loop (uint32_t ticknow);
|
||||
void js_exit (void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
33
third_party/jerryscript/targets/esp8266/include/native_esp8266.h
vendored
Normal file
33
third_party/jerryscript/targets/esp8266/include/native_esp8266.h
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
/* Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* 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 __NATIVE_ESP8266_H__
|
||||
#define __NATIVE_ESP8266_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
void native_gpio_dir (int, int);
|
||||
void native_gpio_set (int, int);
|
||||
int native_gpio_get (int);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
24
third_party/jerryscript/targets/esp8266/include/user_config.h
vendored
Normal file
24
third_party/jerryscript/targets/esp8266/include/user_config.h
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
/* Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* 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 __USER_CONFIG_H__
|
||||
#define __USER_CONFIG_H__
|
||||
|
||||
|
||||
/* number of stack items, x4 for bytes */
|
||||
#define JERRY_STACK_SIZE 2000
|
||||
|
||||
|
||||
#endif
|
15
third_party/jerryscript/targets/esp8266/js/blink.js
vendored
Normal file
15
third_party/jerryscript/targets/esp8266/js/blink.js
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
var check = 1;
|
||||
|
||||
function blink() {
|
||||
var inp = gpio_get(0);
|
||||
var blk = (check > 8) ? 1 - inp : inp;
|
||||
gpio_set(2, blk);
|
||||
check = check >= 10 ? 1 : check+1;
|
||||
}
|
||||
|
||||
// GPIO 0 as input
|
||||
// GPIO 2 as output
|
||||
gpio_dir(0, 0);
|
||||
gpio_dir(2, 1);
|
||||
|
||||
print("blink js OK");
|
4
third_party/jerryscript/targets/esp8266/js/main.js
vendored
Normal file
4
third_party/jerryscript/targets/esp8266/js/main.js
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
function sysloop(ticknow) {
|
||||
blink();
|
||||
};
|
||||
print("main js OK");
|
113
third_party/jerryscript/targets/esp8266/readme.md
vendored
Normal file
113
third_party/jerryscript/targets/esp8266/readme.md
vendored
Normal file
|
@ -0,0 +1,113 @@
|
|||
### About
|
||||
|
||||
Files in this folder (embedding/esp8266) are copied from
|
||||
`examples/project_template` of `esp_iot_rtos_sdk` and modified for JerryScript.
|
||||
You can view online from
|
||||
[this](https://github.com/espressif/esp_iot_rtos_sdk/tree/master/examples/project_template) page.
|
||||
|
||||
|
||||
### How to build JerryScript for ESP8266
|
||||
|
||||
#### 1. SDK
|
||||
|
||||
Follow [this](./docs/ESP-PREREQUISITES.md) page to setup build environment
|
||||
|
||||
|
||||
#### 2. Patch ESP-SDK for JerryScript
|
||||
|
||||
Follow [this](./docs/ESP-PATCHFORJERRYSCRIPT.md) page to patch for JerryScript building.
|
||||
Below is a summary after SDK patch is applied.
|
||||
|
||||
#### 3. Building JerryScript
|
||||
|
||||
```
|
||||
cd ~/harmony/jerryscript
|
||||
# clean build
|
||||
make -f ./targets/esp8266/Makefile.esp8266 clean
|
||||
# or just normal build
|
||||
make -f ./targets/esp8266/Makefile.esp8266
|
||||
```
|
||||
|
||||
Output files should be placed at $BIN_PATH
|
||||
|
||||
#### 4. Flashing for ESP8266 ESP-01 board (WiFi Module)
|
||||
|
||||
Steps are for `ESP8266 ESP-01(WiFi)` board. Others may vary.
|
||||
Refer http://www.esp8266.com/wiki/doku.php?id=esp8266-module-family page.
|
||||
|
||||
##### 4.1 GPIO0 and GPIO2
|
||||
|
||||
Before flashing you need to follow the steps.
|
||||
|
||||
1. Power off ESP8266
|
||||
2. Connect GPIO0 to GND and GPIO2 to VCC
|
||||
3. Power on ESP8266
|
||||
4. Flash
|
||||
|
||||
##### 4.2 Flashing
|
||||
|
||||
```
|
||||
make -f ./targets/esp8266/Makefile.esp8266 flash
|
||||
```
|
||||
|
||||
Default USB device is `/dev/ttyUSB0`. If you have different one, give with `USBDEVICE`, like;
|
||||
|
||||
```
|
||||
USBDEVICE=/dev/ttyUSB1 make -f ./targets/esp8266/Makefile.esp8266 flash
|
||||
```
|
||||
|
||||
|
||||
### 5. Running
|
||||
|
||||
1. Power off
|
||||
2. Disonnect(float) both GPIO0 and GPIO2
|
||||
3. Power on
|
||||
|
||||
Sample program here works with LED and a SW with below connection.
|
||||
* Connect GPIO2 to a LED > 4K resistor > GND
|
||||
* Connect GPIO0 between VCC > 4K resistor and GND
|
||||
|
||||
If GPIO0 is High then LED is turned on longer. If L vice versa.
|
||||
|
||||
### 6. Optimizing initial RAM usage (ESP8266 specific)
|
||||
The existing open source gcc compiler with Xtensa support stores const(ants) in
|
||||
the same limited RAM where our code needs to run.
|
||||
|
||||
It is possible to force the compiler to 1)store a constant into ROM and also 2) read it from there thus saving 1.1) RAM.
|
||||
It will require two things though:
|
||||
1. To add the attribute JERRY_CONST_DATA to your constant. For example
|
||||
|
||||
```C
|
||||
static const lit_magic_size_t lit_magic_string_sizes[] =
|
||||
```
|
||||
|
||||
can be modified to
|
||||
|
||||
```C
|
||||
static const lit_magic_size_t lit_magic_string_sizes[] JERRY_CONST_DATA =
|
||||
```
|
||||
|
||||
That is already done to some constants in jerry-core.
|
||||
|
||||
1.1) Below is a short list:
|
||||
|
||||
|
||||
Bytes | Name
|
||||
-------- | ---------
|
||||
928 | magic_strings$2428
|
||||
610 | vm_decode_table
|
||||
424 | unicode_letter_interv_sps
|
||||
235 | cbc_flags
|
||||
232 | lit_magic_string_sizes
|
||||
212 | unicode_letter_interv_len
|
||||
196 | unicode_non_letter_ident_
|
||||
112 | unicode_letter_chars
|
||||
|
||||
Which frees 2949 bytes in RAM.
|
||||
|
||||
2. To compile your code with compiler that supports the `-mforce-l32` parameter. You can check if your compiler is
|
||||
supporting that parameter by calling:
|
||||
```bash
|
||||
xtensa-lx106-elf-gcc --help=target | grep mforce-l32
|
||||
```
|
||||
If the command above does not provide a result then you will need to upgrade your compiler.
|
202
third_party/jerryscript/targets/esp8266/source/jerry_extapi.c
vendored
Normal file
202
third_party/jerryscript/targets/esp8266/source/jerry_extapi.c
vendored
Normal file
|
@ -0,0 +1,202 @@
|
|||
/* Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* 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 <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "jerry-core/jerry-api.h"
|
||||
#include "jerry_extapi.h"
|
||||
|
||||
#include "native_esp8266.h"
|
||||
|
||||
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(A,B) ((A)<(B)?(A):(B))
|
||||
#endif
|
||||
|
||||
|
||||
#define __UNSED__ __attribute__((unused))
|
||||
|
||||
#define DELCARE_HANDLER(NAME) \
|
||||
static jerry_value_t \
|
||||
NAME ## _handler (const jerry_value_t function_obj_val __UNSED__, \
|
||||
const jerry_value_t this_val __UNSED__, \
|
||||
const jerry_value_t args_p[], \
|
||||
const jerry_length_t args_cnt)
|
||||
|
||||
#define REGISTER_HANDLER(NAME) \
|
||||
register_native_function ( # NAME, NAME ## _handler)
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
DELCARE_HANDLER(assert) {
|
||||
if (args_cnt == 1
|
||||
&& jerry_value_is_boolean (args_p[0])
|
||||
&& jerry_get_boolean_value (args_p[0]))
|
||||
{
|
||||
printf (">> Jerry assert true\r\n");
|
||||
return jerry_create_boolean (true);
|
||||
}
|
||||
printf ("Script assertion failed\n");
|
||||
exit (JERRY_STANDALONE_EXIT_CODE_FAIL);
|
||||
return jerry_create_boolean (false);
|
||||
}
|
||||
|
||||
|
||||
DELCARE_HANDLER(print) {
|
||||
jerry_length_t cc;
|
||||
|
||||
if (args_cnt)
|
||||
{
|
||||
printf(">> print(%d) :", (int) args_cnt);
|
||||
for (cc=0; cc<args_cnt; cc++)
|
||||
{
|
||||
if (jerry_value_is_string (args_p[cc]))
|
||||
{
|
||||
char *buffer;
|
||||
jerry_size_t size = jerry_get_string_size (args_p[0]);
|
||||
buffer = (char *) malloc(size + 1);
|
||||
|
||||
if(!buffer)
|
||||
{
|
||||
// not enough memory for this string.
|
||||
printf("[<too-long-string>]");
|
||||
continue;
|
||||
}
|
||||
|
||||
jerry_string_to_char_buffer (args_p[cc],
|
||||
(jerry_char_t *) buffer,
|
||||
size);
|
||||
*(buffer + size) = 0;
|
||||
printf("[%s] ", buffer);
|
||||
free (buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf ("(%d) ", args_p[cc]);
|
||||
}
|
||||
}
|
||||
printf ("\r\n");
|
||||
}
|
||||
return jerry_create_boolean (true);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
DELCARE_HANDLER(gpio_dir) {
|
||||
int port, value;
|
||||
if (args_cnt < 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
port = (int) jerry_get_number_value (args_p[0]);
|
||||
value = (int) jerry_get_number_value (args_p[1]);
|
||||
|
||||
native_gpio_dir (port, value);
|
||||
|
||||
return jerry_create_boolean (true);
|
||||
} /* gpio_dir_handler */
|
||||
|
||||
DELCARE_HANDLER(gpio_set) {
|
||||
int port, value;
|
||||
if (args_cnt < 2)
|
||||
{
|
||||
return jerry_create_boolean (false);
|
||||
}
|
||||
|
||||
port = (int) jerry_get_number_value (args_p[0]);
|
||||
value = (int) jerry_get_number_value (args_p[1]);
|
||||
|
||||
native_gpio_set (port, value);
|
||||
|
||||
return jerry_create_boolean (true);
|
||||
} /* gpio_dir_handler */
|
||||
|
||||
|
||||
DELCARE_HANDLER(gpio_get) {
|
||||
int port, value;
|
||||
if (args_cnt < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
port = (int) jerry_get_number_value (args_p[0]);
|
||||
|
||||
value = native_gpio_get (port) ? 1 : 0;
|
||||
|
||||
return jerry_create_number ((double) value);
|
||||
} /* gpio_dir_handler */
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
static bool
|
||||
register_native_function (const char* name,
|
||||
jerry_external_handler_t handler)
|
||||
{
|
||||
jerry_value_t global_obj_val;
|
||||
jerry_value_t reg_func_val;
|
||||
jerry_value_t prop_name_val;
|
||||
jerry_value_t res;
|
||||
bool bok;
|
||||
|
||||
global_obj_val = jerry_get_global_object ();
|
||||
reg_func_val = jerry_create_external_function (handler);
|
||||
bok = true;
|
||||
|
||||
if (!(jerry_value_is_function (reg_func_val)
|
||||
&& jerry_value_is_constructor (reg_func_val)))
|
||||
{
|
||||
printf ("!!! create_external_function failed !!!\r\n");
|
||||
jerry_release_value (reg_func_val);
|
||||
jerry_release_value (global_obj_val);
|
||||
return false;
|
||||
}
|
||||
|
||||
prop_name_val = jerry_create_string ((const jerry_char_t *) name);
|
||||
res = jerry_set_property (global_obj_val, prop_name_val, reg_func_val);
|
||||
|
||||
if (jerry_value_has_error_flag (res))
|
||||
{
|
||||
bok = false;
|
||||
}
|
||||
|
||||
jerry_release_value (res);
|
||||
jerry_release_value (prop_name_val);
|
||||
jerry_release_value (reg_func_val);
|
||||
jerry_release_value (global_obj_val);
|
||||
|
||||
if (!bok)
|
||||
{
|
||||
printf ("!!! register_native_function failed: [%s]\r\n", name);
|
||||
}
|
||||
|
||||
return bok;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
void js_register_functions (void)
|
||||
{
|
||||
REGISTER_HANDLER(assert);
|
||||
REGISTER_HANDLER(print);
|
||||
REGISTER_HANDLER(gpio_dir);
|
||||
REGISTER_HANDLER(gpio_set);
|
||||
REGISTER_HANDLER(gpio_get);
|
||||
}
|
119
third_party/jerryscript/targets/esp8266/source/jerry_run.c
vendored
Normal file
119
third_party/jerryscript/targets/esp8266/source/jerry_run.c
vendored
Normal file
|
@ -0,0 +1,119 @@
|
|||
/* Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* 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 <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "jerry-core/jerry-api.h"
|
||||
#include "jerry_extapi.h"
|
||||
#include "jerry_run.h"
|
||||
|
||||
|
||||
static const char* fn_sys_loop_name = "sysloop";
|
||||
jerry_value_t parsed_res;
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
int js_entry (const char *source_p, const size_t source_size)
|
||||
{
|
||||
const jerry_char_t *jerry_src = (const jerry_char_t *) source_p;
|
||||
int ret_code = 0; /* JERRY_COMPLETION_CODE_OK */
|
||||
jerry_init_flag_t flags = JERRY_INIT_EMPTY;
|
||||
|
||||
jerry_init (flags);
|
||||
|
||||
js_register_functions ();
|
||||
|
||||
parsed_res = jerry_parse ((jerry_char_t *) jerry_src, source_size, false);
|
||||
|
||||
if (jerry_value_has_error_flag (parsed_res))
|
||||
{
|
||||
printf ("Error: jerry_parse failed\r\n");
|
||||
ret_code = JERRY_ERROR_SYNTAX;
|
||||
}
|
||||
|
||||
return ret_code;
|
||||
}
|
||||
|
||||
int js_eval (const char *source_p, const size_t source_size)
|
||||
{
|
||||
int status = 0;
|
||||
jerry_value_t res;
|
||||
|
||||
res = jerry_eval ((jerry_char_t *) source_p,
|
||||
source_size,
|
||||
false);
|
||||
if (jerry_value_has_error_flag (res)) {
|
||||
status = -1;
|
||||
}
|
||||
|
||||
jerry_release_value (res);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
int js_loop (uint32_t ticknow)
|
||||
{
|
||||
jerry_value_t global_obj_val;
|
||||
jerry_value_t sysloop_func;
|
||||
jerry_value_t val_args[1];
|
||||
uint16_t val_argv;
|
||||
jerry_value_t res;
|
||||
jerry_value_t prop_name_val;
|
||||
int ret_code = 0;
|
||||
|
||||
global_obj_val = jerry_get_global_object ();
|
||||
prop_name_val = jerry_create_string ((const jerry_char_t *) fn_sys_loop_name);
|
||||
sysloop_func = jerry_get_property (global_obj_val, prop_name_val);
|
||||
jerry_release_value (prop_name_val);
|
||||
|
||||
if (jerry_value_has_error_flag (sysloop_func)) {
|
||||
printf ("Error: '%s' not defined!!!\r\n", fn_sys_loop_name);
|
||||
jerry_release_value (sysloop_func);
|
||||
jerry_release_value (global_obj_val);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!jerry_value_is_function (sysloop_func)) {
|
||||
printf ("Error: '%s' is not a function!!!\r\n", fn_sys_loop_name);
|
||||
jerry_release_value (sysloop_func);
|
||||
jerry_release_value (global_obj_val);
|
||||
return -2;
|
||||
}
|
||||
|
||||
val_argv = 1;
|
||||
val_args[0] = jerry_create_number (ticknow);
|
||||
|
||||
res = jerry_call_function (sysloop_func,
|
||||
global_obj_val,
|
||||
val_args,
|
||||
val_argv);
|
||||
|
||||
if (jerry_value_has_error_flag (res)) {
|
||||
ret_code = -3;
|
||||
}
|
||||
|
||||
jerry_release_value (res);
|
||||
jerry_release_value (sysloop_func);
|
||||
jerry_release_value (global_obj_val);
|
||||
|
||||
return ret_code;
|
||||
}
|
||||
|
||||
void js_exit (void)
|
||||
{
|
||||
jerry_cleanup ();
|
||||
}
|
43
third_party/jerryscript/targets/esp8266/user/Makefile
vendored
Normal file
43
third_party/jerryscript/targets/esp8266/user/Makefile
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
|
||||
#############################################################
|
||||
# Required variables for each makefile
|
||||
# Discard this section from all parent makefiles
|
||||
# Expected variables (with automatic defaults):
|
||||
# CSRCS (all "C" files in the dir)
|
||||
# SUBDIRS (all subdirs with a Makefile)
|
||||
# GEN_LIBS - list of libs to be generated ()
|
||||
# GEN_IMAGES - list of images to be generated ()
|
||||
# COMPONENTS_xxx - a list of libs/objs in the form
|
||||
# subdir/lib to be extracted and rolled up into
|
||||
# a generated lib/image xxx.a ()
|
||||
#
|
||||
ifndef PDIR
|
||||
GEN_LIBS = libuser.a
|
||||
endif
|
||||
|
||||
|
||||
#############################################################
|
||||
# Configuration i.e. compile options etc.
|
||||
# Target specific stuff (defines etc.) goes in here!
|
||||
# Generally values applying to a tree are captured in the
|
||||
# makefile at its root level - these are then overridden
|
||||
# for a subtree within the makefile rooted therein
|
||||
#
|
||||
#DEFINES +=
|
||||
|
||||
#############################################################
|
||||
# Recursion Magic - Don't touch this!!
|
||||
#
|
||||
# Each subtree potentially has an include directory
|
||||
# corresponding to the common APIs applicable to modules
|
||||
# rooted at that subtree. Accordingly, the INCLUDE PATH
|
||||
# of a module can only contain the include directories up
|
||||
# its parent path, and not its siblings
|
||||
#
|
||||
# Required for each makefile to inherit from the parent
|
||||
#
|
||||
|
||||
INCLUDES := $(INCLUDES) -I $(PDIR)include
|
||||
INCLUDES += -I ./ -I ../include -I../../../
|
||||
sinclude $(PDIR)Makefile
|
||||
|
94
third_party/jerryscript/targets/esp8266/user/jerry_port.c
vendored
Normal file
94
third_party/jerryscript/targets/esp8266/user/jerry_port.c
vendored
Normal file
|
@ -0,0 +1,94 @@
|
|||
/* Copyright 2014-2016 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* 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 "esp_common.h"
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "jerry-core/jerry-port.h"
|
||||
|
||||
/**
|
||||
* Provide console message implementation for the engine.
|
||||
*/
|
||||
void
|
||||
jerry_port_console (const char *format, /**< format string */
|
||||
...) /**< parameters */
|
||||
{
|
||||
va_list args;
|
||||
va_start (args, format);
|
||||
/* TODO, uncomment when vprint link is ok */
|
||||
/* vfprintf (stdout, format, args); */
|
||||
va_end (args);
|
||||
} /* jerry_port_console */
|
||||
|
||||
/**
|
||||
* Provide log message implementation for the engine.
|
||||
*/
|
||||
void
|
||||
jerry_port_log (jerry_log_level_t level, /**< log level */
|
||||
const char *format, /**< format string */
|
||||
...) /**< parameters */
|
||||
{
|
||||
(void) level; /* ignore log level */
|
||||
|
||||
va_list args;
|
||||
va_start (args, format);
|
||||
/* TODO, uncomment when vprint link is ok */
|
||||
/* vprintf (stderr, format, args); */
|
||||
va_end (args);
|
||||
} /* jerry_port_log */
|
||||
|
||||
|
||||
/** exit - cause normal process termination */
|
||||
void exit (int status)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
}
|
||||
} /* exit */
|
||||
|
||||
/** abort - cause abnormal process termination */
|
||||
void abort (void)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
}
|
||||
} /* abort */
|
||||
|
||||
/**
|
||||
* fwrite
|
||||
*
|
||||
* @return number of bytes written
|
||||
*/
|
||||
size_t
|
||||
fwrite (const void *ptr, /**< data to write */
|
||||
size_t size, /**< size of elements to write */
|
||||
size_t nmemb, /**< number of elements */
|
||||
FILE *stream) /**< stream pointer */
|
||||
{
|
||||
return size * nmemb;
|
||||
} /* fwrite */
|
||||
|
||||
/**
|
||||
* This function can get the time as well as a timezone.
|
||||
*
|
||||
* @return 0 if success, -1 otherwise
|
||||
*/
|
||||
int
|
||||
gettimeofday (void *tp, /**< struct timeval */
|
||||
void *tzp) /**< struct timezone */
|
||||
{
|
||||
return -1;
|
||||
} /* gettimeofday */
|
50
third_party/jerryscript/targets/esp8266/user/native_esp8266.c
vendored
Normal file
50
third_party/jerryscript/targets/esp8266/user/native_esp8266.c
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
/* Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* Copyright 2013-2014 Espressif Systems (Wuxi)
|
||||
*
|
||||
* FileName: user_main.c
|
||||
*
|
||||
* Description: entry file of user application
|
||||
*
|
||||
* Modification history:
|
||||
* 2014/12/1, v1.0 create this file.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "esp_common.h"
|
||||
|
||||
#include "user_config.h"
|
||||
#include "esp8266_gpio.h"
|
||||
|
||||
|
||||
void native_gpio_dir(int port, int value) {
|
||||
if (value) {
|
||||
GPIO_AS_OUTPUT(1 << port);
|
||||
}
|
||||
else {
|
||||
GPIO_AS_INPUT(1 << port);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void native_gpio_set(int port, int value) {
|
||||
GPIO_OUTPUT_SET(port, value);
|
||||
}
|
||||
|
||||
|
||||
int native_gpio_get(int port) {
|
||||
return GPIO_INPUT_GET(port);
|
||||
}
|
39
third_party/jerryscript/targets/esp8266/user/user_gpio.c
vendored
Normal file
39
third_party/jerryscript/targets/esp8266/user/user_gpio.c
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
/* Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014 -2016 Espressif System
|
||||
*
|
||||
*/
|
||||
|
||||
#include "esp_common.h"
|
||||
|
||||
#include "esp8266_gpio.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void gpio_output_conf(uint32 set_mask, uint32 clear_mask, uint32 enable_mask,
|
||||
uint32 disable_mask) {
|
||||
GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, set_mask);
|
||||
GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, clear_mask);
|
||||
GPIO_REG_WRITE(GPIO_ENABLE_W1TS_ADDRESS, enable_mask);
|
||||
GPIO_REG_WRITE(GPIO_ENABLE_W1TC_ADDRESS, disable_mask);
|
||||
}
|
||||
|
||||
|
||||
uint32 gpio_input_get(void) {
|
||||
return GPIO_REG_READ(GPIO_IN_ADDRESS);
|
||||
}
|
111
third_party/jerryscript/targets/esp8266/user/user_main.c
vendored
Normal file
111
third_party/jerryscript/targets/esp8266/user/user_main.c
vendored
Normal file
|
@ -0,0 +1,111 @@
|
|||
/* Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* Copyright 2013-2014 Espressif Systems (Wuxi)
|
||||
*
|
||||
* FileName: user_main.c
|
||||
*
|
||||
* Description: entry file of user application
|
||||
*
|
||||
* Modification history:
|
||||
* 2014/12/1, v1.0 create this file.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "esp_common.h"
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
|
||||
#include "user_config.h"
|
||||
#include "esp8266_uart.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void show_free_mem(int idx) {
|
||||
size_t res = xPortGetFreeHeapSize();
|
||||
printf("dbg free memory(%d): %d\r\n", idx, res);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "jerry_targetjs.h"
|
||||
|
||||
|
||||
static int jerry_task_init(void) {
|
||||
int retcode;
|
||||
int src;
|
||||
|
||||
DECLARE_JS_CODES;
|
||||
|
||||
/* run main.js */
|
||||
show_free_mem(2);
|
||||
retcode = js_entry(js_codes[0].source, js_codes[0].length);
|
||||
if (retcode != 0) {
|
||||
printf("js_entry failed code(%d) [%s]\r\n", retcode, js_codes[0].name);
|
||||
return -1;
|
||||
}
|
||||
/* run rest of the js files */
|
||||
show_free_mem(3);
|
||||
for (src=1; js_codes[src].source; src++) {
|
||||
retcode = js_eval(js_codes[src].source, js_codes[src].length);
|
||||
if (retcode != 0) {
|
||||
printf("js_eval failed code(%d) [%s]\r\n", retcode, js_codes[src].name);
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
show_free_mem(4);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void jerry_task(void *pvParameters) {
|
||||
const portTickType xDelay = 100 / portTICK_RATE_MS;
|
||||
uint32_t ticknow = 0;
|
||||
|
||||
if (jerry_task_init() == 0) {
|
||||
for (;;) {
|
||||
vTaskDelay(xDelay);
|
||||
js_loop(ticknow);
|
||||
if (!ticknow) {
|
||||
show_free_mem(5);
|
||||
}
|
||||
ticknow++;
|
||||
}
|
||||
}
|
||||
js_exit();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* This is entry point for user code
|
||||
*/
|
||||
void ICACHE_FLASH_ATTR user_init(void)
|
||||
{
|
||||
uart_div_modify(UART0, UART_CLK_FREQ / (BIT_RATE_115200));
|
||||
|
||||
show_free_mem(0);
|
||||
wifi_softap_dhcps_stop();
|
||||
show_free_mem(1);
|
||||
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0); // GPIO 0
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2); // GPIO 2
|
||||
|
||||
xTaskCreate(jerry_task, "jerry", JERRY_STACK_SIZE, NULL, 2, NULL);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue