Revive target: ESP8266

This patch updates ESP8266 build system and code base as well.
 - Removed unnecessary files.
 - Decreased code size.
 - Refactored jerry_{port, extapi, run}.c to make it more easy to handle.
 - Readme.md is updated as well which contains detailed step by step description about how to set up environment and use JerryScript.

Finally, it solves the related issue #1375.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
Robert Fancsik
2017-10-02 13:47:36 +02:00
committed by yichoi
parent bdcd2d8179
commit c3a9821171
18 changed files with 336 additions and 927 deletions
+25 -61
View File
@@ -12,17 +12,9 @@
# 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
ESP_LIB = $(SDK_PATH)/lib
BUILD_DIR = build/obj-esp8266
COPYTARGET = targets/esp8266/libs
USBDEVICE ?= /dev/ttyUSB0
JERRYHEAP ?= 20
@@ -31,76 +23,50 @@ 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`
MFORCE32 = $(shell 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\")))"
ESP_CFLAGS += -mforce-l32
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 $(BUILD_DIR)
mkdir -p $(COPYTARGET)
cmake -B$(INTERM) -H./ \
cmake -B$(BUILD_DIR) -H./ \
-DENABLE_LTO=OFF \
-DENABLE_VALGRIND=OFF \
-DCMAKE_TOOLCHAIN_FILE=build/configs/toolchain_external.cmake \
-DFEATURE_VALGRIND=OFF \
-DCMAKE_TOOLCHAIN_FILE=cmake/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)" \
-DJERRY_LIBC=OFF \
-DJERRY_LIBM=ON \
-DJERRY_CMDLINE=OFF \
-DENABLE_ALL_IN_ONE=ON \
-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
-DMEM_HEAP_SIZE_KB=$(JERRYHEAP)
make -C$(BUILD_DIR) jerry-core jerry-libm
cp $(BUILD_DIR)/lib/libjerry-core.a $(COPYTARGET)/
cp $(BUILD_DIR)/lib/libjerry-libm.a $(COPYTARGET)/
js2c:
cd targets/esp8266; ../../tools/js2c.py
tools/js2c.py --dest targets/esp8266/include --js-source targets/esp8266/js
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
make -Ctargets/esp8266 clean
make -Ctargets/esp8266 BOOT=new APP=0 SPI_SPEED=40 SPI_MODE=DIO SPI_SIZE_MAP=4
check-env:
ifndef SDK_PATH
@@ -110,16 +76,14 @@ 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
0x00000 $(BIN_PATH)/eagle.flash.bin \
0x20000 $(BIN_PATH)/eagle.irom0text.bin \
0x3FC000 $(SDK_PATH)/bin/esp_init_data_default.bin
erase_flash:
$(ESPTOOL) --port $(USBDEVICE) erase_flash
clean:
rm -rf $(INTERM)
rm -rf $(OUTPUT)
rm -rf $(BUILD_DIR)