2016-08-03 16:27:10 +02:00
|
|
|
###############################################################################
|
|
|
|
# USER OPTIONS
|
|
|
|
###############################################################################
|
2015-07-27 09:34:00 +02:00
|
|
|
|
2016-08-03 16:27:10 +02:00
|
|
|
CHIP ?= 8266
|
|
|
|
IP ?= 192.168.4.1
|
|
|
|
PORT ?= /dev/ttyUSB0
|
|
|
|
#PORT ?= /dev/ttyACM0
|
2015-06-04 07:51:24 +02:00
|
|
|
|
2016-08-03 16:27:10 +02:00
|
|
|
ESP_ROOT ?= $(HOME)/esp8266/esp-open-sdk
|
|
|
|
GCC_VERS ?= 4.8.5
|
|
|
|
|
|
|
|
OPTS += -DICACHE_FLASH
|
|
|
|
#OPTS += -DFREQ=12500
|
|
|
|
|
|
|
|
###########################################################################VARS
|
|
|
|
|
|
|
|
.PHONY : all clean cleanall netburn burnweb burn
|
|
|
|
uniq = $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))
|
|
|
|
|
2016-08-03 20:29:44 +02:00
|
|
|
FW_FILE1 = image.elf-0x00000.bin
|
|
|
|
FW_FILE2 = image.elf-0x40000.bin
|
2016-08-03 16:27:10 +02:00
|
|
|
TARGET = image.elf
|
|
|
|
|
|
|
|
SRCS = \
|
|
|
|
driver/uart.c \
|
2015-07-29 07:54:49 +02:00
|
|
|
common/mystuff.c \
|
|
|
|
common/flash_rewriter.c \
|
|
|
|
common/http.c \
|
|
|
|
common/http_custom.c \
|
|
|
|
common/mfs.c \
|
2015-07-27 09:34:00 +02:00
|
|
|
user/ws2812_i2s.c \
|
|
|
|
user/hpatimer.c \
|
2015-08-03 07:19:11 +02:00
|
|
|
user/custom_commands.c \
|
2015-07-27 09:34:00 +02:00
|
|
|
driver/adc.c \
|
|
|
|
../embeddedcommon/DFT32.c \
|
|
|
|
../embeddedcommon/embeddednf.c \
|
|
|
|
../embeddedcommon/embeddedout.c \
|
2015-07-29 07:54:49 +02:00
|
|
|
user/user_main.c \
|
|
|
|
common/commonservices.c
|
2015-06-04 07:51:24 +02:00
|
|
|
|
2016-08-03 16:27:10 +02:00
|
|
|
LIBS = main lwip ssl upgrade net80211 wpa net80211 phy lwip pp crypto
|
|
|
|
INCL = $(SDK)/include myclib include .
|
2015-07-29 07:54:49 +02:00
|
|
|
|
2016-08-03 16:27:10 +02:00
|
|
|
GCC_FOLDER = $(ESP_ROOT)/xtensa-lx106-elf
|
|
|
|
ESPTOOL_PY = $(ESP_ROOT)/esptool/esptool.py
|
|
|
|
SDK = $(ESP_ROOT)/sdk
|
2015-07-29 07:54:49 +02:00
|
|
|
|
2016-08-03 16:27:10 +02:00
|
|
|
XTLIB = $(SDK)/lib
|
|
|
|
XTGCCLIB = $(GCC_FOLDER)/lib/gcc/xtensa-lx106-elf/$(GCC_VERS)/libgcc.a
|
|
|
|
PREFIX = $(GCC_FOLDER)/bin/xtensa-lx106-elf-
|
|
|
|
CC = $(PREFIX)gcc
|
|
|
|
LD = $(PREFIX)ld
|
2015-06-04 07:51:24 +02:00
|
|
|
|
2016-08-03 16:27:10 +02:00
|
|
|
CFLAGS = -mlongcalls -Os $(addprefix -I,$(INCL) $(call uniq, $(patsubst %/,%,$(dir $(SRCS))))) $(OPTS)
|
2015-06-04 07:51:24 +02:00
|
|
|
|
2016-08-03 16:27:10 +02:00
|
|
|
LDFLAGS_CORE = -nostdlib -L$(XTLIB) -L$(XTGCCLIB) \
|
|
|
|
$(addprefix $(SDK)/lib/lib,$(addsuffix .a,$(LIBS))) \
|
|
|
|
$(XTGCCLIB) -T $(SDK)/ld/eagle.app.v6.ld -Wl,-Map,output.map
|
|
|
|
# -flto -Wl,--relax -Wl,--gc-sections
|
2015-06-04 07:51:24 +02:00
|
|
|
|
2016-08-03 16:27:10 +02:00
|
|
|
LINKFLAGS = $(LDFLAGS_CORE) -B$(XTLIB)
|
2015-06-04 07:51:24 +02:00
|
|
|
|
2016-08-03 16:27:10 +02:00
|
|
|
##########################################################################RULES
|
2015-06-04 07:51:24 +02:00
|
|
|
|
2016-08-03 20:29:44 +02:00
|
|
|
all : $(FW_FILE1) $(FW_FILE2)
|
2015-06-04 07:51:24 +02:00
|
|
|
|
2016-08-03 20:29:44 +02:00
|
|
|
$(FW_FILE1) $(FW_FILE2) : $(TARGET)
|
2015-06-04 07:51:24 +02:00
|
|
|
@echo "FW $@"
|
2016-08-03 20:29:44 +02:00
|
|
|
PATH=$(FOLDERPREFIX):$$PATH;$(ESPTOOL_PY) elf2image $(TARGET)
|
2016-07-04 22:59:34 +02:00
|
|
|
|
2016-08-03 16:27:10 +02:00
|
|
|
$(TARGET) : $(SRCS)
|
|
|
|
$(CC) $(CFLAGS) $^ $(LINKFLAGS) -o $@
|
2015-06-04 07:51:24 +02:00
|
|
|
|
2016-08-03 16:27:10 +02:00
|
|
|
ifeq ($(CHIP), 8285)
|
|
|
|
burn : $(FW_FILE_1) $(FW_FILE_2)
|
|
|
|
($(ESPTOOL_PY) --port $(PORT) write_flash -fs 8m -fm dout 0x00000 0x00000.bin 0x40000 0x40000.bin)||(true)
|
|
|
|
else ifeq ($(CHIP), 8266)
|
|
|
|
burn : $(FW_FILE_1) $(FW_FILE_2)
|
2016-08-03 20:29:44 +02:00
|
|
|
($(ESPTOOL_PY) --port $(PORT) write_flash 0x00000 $(FW_FILE1) 0x40000 $(FW_FILE2))||(true)
|
2016-08-03 16:27:10 +02:00
|
|
|
else
|
|
|
|
$(error Error: Unknown chip '$(CHIP)')
|
|
|
|
endif
|
2015-06-04 07:51:24 +02:00
|
|
|
|
2015-08-28 08:36:36 +02:00
|
|
|
#If you have space, MFS should live at 0x100000, if you don't it can also live at
|
2016-08-03 16:27:10 +02:00
|
|
|
#0x10000. But, then it is limited to 180kB. You might need to do this if you have a 512kB
|
2015-08-28 08:36:36 +02:00
|
|
|
#ESP variant.
|
|
|
|
|
|
|
|
burnweb : web/page.mpfs
|
|
|
|
($(ESPTOOL_PY) --port $(PORT) write_flash 0x10000 web/page.mpfs)||(true)
|
|
|
|
|
2016-08-03 20:29:44 +02:00
|
|
|
netburn : $(FW_FILE1) $(FW_FILE2) web/execute_reflash
|
|
|
|
web/execute_reflash $(IP) $(FW_FILE1) $(FW_FILE2)
|
2015-07-29 07:54:49 +02:00
|
|
|
|
2015-06-04 07:51:24 +02:00
|
|
|
clean :
|
2016-08-03 16:27:10 +02:00
|
|
|
$(RM) $(patsubst %.c,%.o,$(SRCS)) $(TARGET)
|
2015-06-04 07:51:24 +02:00
|
|
|
|
2016-08-03 16:27:10 +02:00
|
|
|
purge : clean
|
|
|
|
$(RM) $(FW_FILE_1) $(FW_FILE_2)
|