• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright JS Foundation and other contributors, http://js.foundation
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
15CURDIR     = `pwd`
16ESP_LIB    = $(SDK_PATH)/lib
17BUILD_DIR  = build/obj-esp8266
18COPYTARGET = targets/esp8266/libs
19USBDEVICE  ?= /dev/ttyUSB0
20JERRYHEAP  ?= 20
21ESPTOOL    ?= $(ESPTOOL_PATH)/esptool.py
22
23# compile flags
24ESP_CFLAGS := -D__TARGET_ESP8266 -D__attr_always_inline___=
25
26MFORCE32 = $(shell xtensa-lx106-elf-gcc --help=target | grep mforce-l32)
27
28ifneq ($(MFORCE32),)
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\")))"
32    ESP_CFLAGS += -mforce-l32
33endif
34
35ESP_CFLAGS += -Wl,-EL -fno-inline-functions
36ESP_CFLAGS += -ffunction-sections -fdata-sections
37ESP_CFLAGS += -mlongcalls -mtext-section-literals -mno-serialize-volatile
38
39.PHONY: jerry js2c mkbin check-env flash clean
40
41all: check-env jerry js2c mkbin
42
43jerry:
44	mkdir -p $(BUILD_DIR)
45	mkdir -p $(COPYTARGET)
46	cmake -B$(BUILD_DIR) -H./ \
47	 -DCMAKE_SYSTEM_NAME=MCU \
48	 -DCMAKE_SYSTEM_PROCESSOR=xtensia-lx106 \
49	 -DCMAKE_C_COMPILER=xtensa-lx106-elf-gcc \
50	 -DCMAKE_C_COMPILER_WORKS=TRUE \
51	 -DENABLE_LTO=OFF \
52	 -DENABLE_ALL_IN_ONE=ON \
53	 -DJERRY_CMDLINE=OFF \
54	 -DEXTERNAL_COMPILE_FLAGS="$(ESP_CFLAGS)" \
55	 -DJERRY_GLOBAL_HEAP_SIZE=$(JERRYHEAP)
56
57	make -C$(BUILD_DIR) jerry-core jerry-libm
58	cp $(BUILD_DIR)/lib/libjerry-core.a $(COPYTARGET)/
59	cp $(BUILD_DIR)/lib/libjerry-libm.a $(COPYTARGET)/
60
61js2c:
62	tools/js2c.py --dest targets/esp8266/include --js-source targets/esp8266/js
63
64mkbin:
65	make -Ctargets/esp8266 clean
66	make -Ctargets/esp8266 BOOT=new APP=0 SPI_SPEED=40 SPI_MODE=DIO SPI_SIZE_MAP=4
67
68check-env:
69ifndef SDK_PATH
70	$(error SDK_PATH is undefined for ESP8266)
71endif
72ifndef BIN_PATH
73	$(error BIN_PATH is undefined for ESP8266)
74endif
75
76flash:
77	$(ESPTOOL) --port $(USBDEVICE) write_flash \
78	0x00000 $(BIN_PATH)/eagle.flash.bin \
79	0x20000 $(BIN_PATH)/eagle.irom0text.bin \
80	0x3FC000 $(SDK_PATH)/bin/esp_init_data_default.bin
81
82erase_flash:
83	$(ESPTOOL) --port $(USBDEVICE) erase_flash
84
85clean:
86	rm -rf $(BUILD_DIR)
87