Makefile.esp8266 2.6 KB
Newer Older
1
# Copyright JS Foundation and other contributors, http://js.foundation
2 3 4 5 6 7 8 9 10 11 12 13 14 15
#
# 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.

CURDIR     = `pwd`
R
Robert Fancsik 已提交
16 17
ESP_LIB    = $(SDK_PATH)/lib
BUILD_DIR  = build/obj-esp8266
18 19 20
COPYTARGET = targets/esp8266/libs
USBDEVICE  ?= /dev/ttyUSB0
JERRYHEAP  ?= 20
21
ESPTOOL    ?= $(ESPTOOL_PATH)/esptool.py
22 23 24

# compile flags
ESP_CFLAGS := -D__TARGET_ESP8266 -D__attr_always_inline___=
25

R
Robert Fancsik 已提交
26
MFORCE32 = $(shell xtensa-lx106-elf-gcc --help=target | grep mforce-l32)
27 28

ifneq ($(MFORCE32),)
L
László Langó 已提交
29
    # Your compiler supports the -mforce-l32 flag which means that
30
    # constants can be placed in ROM to free additional RAM
31
    ESP_CFLAGS += -DJERRY_ATTR_CONST_DATA="__attribute__((aligned(4))) __attribute__((section(\".irom.text\")))"
R
Robert Fancsik 已提交
32
    ESP_CFLAGS += -mforce-l32
33 34
endif

35 36 37 38
ESP_CFLAGS += -Wl,-EL -fno-inline-functions
ESP_CFLAGS += -ffunction-sections -fdata-sections
ESP_CFLAGS += -mlongcalls -mtext-section-literals -mno-serialize-volatile

S
SaeHie Park 已提交
39
.PHONY: jerry js2c mkbin check-env flash clean
40

S
SaeHie Park 已提交
41
all: check-env jerry js2c mkbin
42 43

jerry:
R
Robert Fancsik 已提交
44
	mkdir -p $(BUILD_DIR)
45
	mkdir -p $(COPYTARGET)
R
Robert Fancsik 已提交
46
	cmake -B$(BUILD_DIR) -H./ \
47 48 49 50
	 -DCMAKE_SYSTEM_NAME=MCU \
	 -DCMAKE_SYSTEM_PROCESSOR=xtensia-lx106 \
	 -DCMAKE_C_COMPILER=xtensa-lx106-elf-gcc \
	 -DCMAKE_C_COMPILER_WORKS=TRUE \
51
	 -DENABLE_LTO=OFF \
52
	 -DENABLE_ALL_IN_ONE=ON \
R
Robert Fancsik 已提交
53
	 -DJERRY_CMDLINE=OFF \
54
	 -DEXTERNAL_COMPILE_FLAGS="$(ESP_CFLAGS)" \
55
	 -DJERRY_GLOBAL_HEAP_SIZE=$(JERRYHEAP)
56

R
Robert Fancsik 已提交
57 58 59
	make -C$(BUILD_DIR) jerry-core jerry-libm
	cp $(BUILD_DIR)/lib/libjerry-core.a $(COPYTARGET)/
	cp $(BUILD_DIR)/lib/libjerry-libm.a $(COPYTARGET)/
60 61

js2c:
R
Robert Fancsik 已提交
62
	tools/js2c.py --dest targets/esp8266/include --js-source targets/esp8266/js
63

S
SaeHie Park 已提交
64
mkbin:
R
Robert Fancsik 已提交
65 66
	make -Ctargets/esp8266 clean
	make -Ctargets/esp8266 BOOT=new APP=0 SPI_SPEED=40 SPI_MODE=DIO SPI_SIZE_MAP=4
67 68 69 70 71 72 73 74 75 76

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:
77
	$(ESPTOOL) --port $(USBDEVICE) write_flash \
R
Robert Fancsik 已提交
78 79 80
	0x00000 $(BIN_PATH)/eagle.flash.bin \
	0x20000 $(BIN_PATH)/eagle.irom0text.bin \
	0x3FC000 $(SDK_PATH)/bin/esp_init_data_default.bin
81

R
Robert Fancsik 已提交
82 83
erase_flash:
	$(ESPTOOL) --port $(USBDEVICE) erase_flash
84 85

clean:
R
Robert Fancsik 已提交
86
	rm -rf $(BUILD_DIR)