colorchord/embedded8266/Makefile

106 lines
3 KiB
Makefile
Raw Normal View History

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
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)))
FW_FILE_1 = 0x00000.bin
FW_FILE_2 = 0x40000.bin
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 \
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
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
FW_TOOL = $(ESP_ROOT)/../esptool-ck/esptool
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
2016-08-03 16:27:10 +02:00
CFLAGS = -mlongcalls -Os $(addprefix -I,$(INCL) $(call uniq, $(patsubst %/,%,$(dir $(SRCS))))) $(OPTS)
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
2016-08-03 16:27:10 +02:00
LINKFLAGS = $(LDFLAGS_CORE) -B$(XTLIB)
2016-08-03 16:27:10 +02:00
##########################################################################RULES
2016-08-03 16:27:10 +02:00
all : $(FW_FILE_1) $(FW_FILE_2)
2016-08-03 16:27:10 +02:00
$(FW_FILE_1): $(TARGET)
@echo "FW $@"
2016-08-03 16:27:10 +02:00
$(FW_TOOL) -eo $(TARGET) -bo $@ -bs .text -bs .data -bs .rodata -bc -ec
2016-08-03 16:27:10 +02:00
$(FW_FILE_2): $(TARGET)
@echo "FW $@"
2016-08-03 16:27:10 +02:00
$(FW_TOOL) -eo $(TARGET) -es .irom0.text $@ -ec
2016-08-03 16:27:10 +02:00
$(TARGET) : $(SRCS)
$(CC) $(CFLAGS) $^ $(LINKFLAGS) -o $@
# $(LD) $^ $(LDFLAGS) -o $@
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)
($(ESPTOOL_PY) --port $(PORT) write_flash 0x00000 0x00000.bin 0x40000 0x40000.bin)||(true)
else
$(error Error: Unknown chip '$(CHIP)')
endif
#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
#ESP variant.
burnweb : web/page.mpfs
($(ESPTOOL_PY) --port $(PORT) write_flash 0x10000 web/page.mpfs)||(true)
2015-07-29 07:54:49 +02:00
netburn : image.elf $(FW_FILE_1) $(FW_FILE_2)
web/execute_reflash $(IP) 0x00000.bin 0x40000.bin
clean :
2016-08-03 16:27:10 +02:00
$(RM) $(patsubst %.c,%.o,$(SRCS)) $(TARGET)
2016-08-03 16:27:10 +02:00
purge : clean
$(RM) $(FW_FILE_1) $(FW_FILE_2)