Merge pull request #13 from con-f-use/master

Clean Makefiles up and remove need for esptool-ck (binary esptool)
This commit is contained in:
CNLohr 2016-08-03 21:37:49 -04:00 committed by GitHub
commit 4ad69c4a49
3 changed files with 70 additions and 73 deletions

View file

@ -1,10 +1,29 @@
FW_FILE_1:=0x00000.bin
FW_FILE_2:=0x40000.bin
TARGET_OUT:=image.elf
all : $(TARGET_OUT) $(FW_FILE_1) $(FW_FILE_2)
###############################################################################
# USER OPTIONS
###############################################################################
CHIP ?= 8266
IP ?= 192.168.4.1
PORT ?= /dev/ttyUSB0
#PORT ?= /dev/ttyACM0
SRCS:=driver/uart.c \
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_FILE1 = image.elf-0x00000.bin
FW_FILE2 = image.elf-0x40000.bin
TARGET = image.elf
SRCS = \
driver/uart.c \
common/mystuff.c \
common/flash_rewriter.c \
common/http.c \
@ -20,72 +39,48 @@ SRCS:=driver/uart.c \
user/user_main.c \
common/commonservices.c
GCC_FOLDER:=~/esp8266/esp-open-sdk/xtensa-lx106-elf
ESPTOOL_PY:=~/esp8266/esptool/esptool.py
FW_TOOL:=~/esp8266/other/esptool/esptool
SDK:=/home/cnlohr/esp8266/esp_iot_sdk_v1.5.1
PORT:=/dev/ttyUSB0
#PORT:=/dev/ttyACM0
LIBS = main lwip ssl upgrade net80211 wpa net80211 phy lwip pp crypto
INCL = $(SDK)/include myclib include .
XTLIB:=$(SDK)/lib
XTGCCLIB:=$(GCC_FOLDER)/lib/gcc/xtensa-lx106-elf/4.8.2/libgcc.a
FOLDERPREFIX:=$(GCC_FOLDER)/bin
PREFIX:=$(FOLDERPREFIX)/xtensa-lx106-elf-
CC:=$(PREFIX)gcc
GCC_FOLDER = $(ESP_ROOT)/xtensa-lx106-elf
ESPTOOL_PY = $(ESP_ROOT)/esptool/esptool.py
SDK = $(ESP_ROOT)/sdk
CFLAGS:=-mlongcalls -I$(SDK)/include -Imyclib -Iinclude -Iuser -Os -I$(SDK)/include/ -I../embeddedcommon -I. -Icommon -DICACHE_FLASH
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
#-DFREQ==12500 seems to work well.
LDFLAGS_CORE:=\
-nostdlib \
-L$(XTLIB) \
-L$(XTGCCLIB) \
$(SDK)/lib/libmain.a \
$(SDK)/lib/liblwip.a \
$(SDK)/lib/libssl.a \
$(SDK)/lib/libupgrade.a \
$(SDK)/lib/libnet80211.a \
$(SDK)/lib/libwpa.a \
$(SDK)/lib/libnet80211.a \
$(SDK)/lib/libphy.a \
$(SDK)/lib/liblwip.a \
$(SDK)/lib/libpp.a \
$(SDK)/lib/libcrypto.a \
$(SDK)/lib/libmain.a \
$(XTGCCLIB) \
-T $(SDK)/ld/eagle.app.v6.ld \
-Wl,-Map,output.map \
CFLAGS = -mlongcalls -Os $(addprefix -I,$(INCL) $(call uniq, $(patsubst %/,%,$(dir $(SRCS))))) $(OPTS)
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
LINKFLAGS = $(LDFLAGS_CORE) -B$(XTLIB)
LINKFLAGS:= \
$(LDFLAGS_CORE) \
-B$(XTLIB)
##########################################################################RULES
#image.elf : $(OBJS)
# $(PREFIX)ld $^ $(LDFLAGS) -o $@
all : $(FW_FILE1) $(FW_FILE2)
$(TARGET_OUT) : $(SRCS)
$(PREFIX)gcc $(CFLAGS) $^ $(LINKFLAGS) -o $@
$(FW_FILE_1): $(TARGET_OUT)
$(FW_FILE1) $(FW_FILE2) : $(TARGET)
@echo "FW $@"
$(FW_TOOL) -eo $(TARGET_OUT) -bo $@ -bs .text -bs .data -bs .rodata -bc -ec
PATH=$(FOLDERPREFIX):$$PATH;$(ESPTOOL_PY) elf2image $(TARGET)
$(FW_FILE_2): $(TARGET_OUT)
@echo "FW $@"
$(FW_TOOL) -eo $(TARGET_OUT) -es .irom0.text $@ -ec
$(TARGET) : $(SRCS)
$(CC) $(CFLAGS) $^ $(LINKFLAGS) -o $@
ifeq ($(CHIP), 8285)
burn : $(FW_FILE_1) $(FW_FILE_2)
#($(ESPTOOL_PY) --port $(PORT) write_flash 0x00000 0x00000.bin 0x40000 0x40000.bin)||(true) #for '8266
($(ESPTOOL_PY) --port $(PORT) write_flash -fs 8m -fm dout 0x00000 0x00000.bin 0x40000 0x40000.bin)||(true) #for '8285
($(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 $(FW_FILE1) 0x40000 $(FW_FILE2))||(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
#0x10000. But, then it is limited to 180kB. You might need to do this if you have a 512kB
@ -94,14 +89,11 @@ burn : $(FW_FILE_1) $(FW_FILE_2)
burnweb : web/page.mpfs
($(ESPTOOL_PY) --port $(PORT) write_flash 0x10000 web/page.mpfs)||(true)
IP?=192.168.4.1
netburn : image.elf $(FW_FILE_1) $(FW_FILE_2)
web/execute_reflash $(IP) 0x00000.bin 0x40000.bin
netburn : $(FW_FILE1) $(FW_FILE2) web/execute_reflash
web/execute_reflash $(IP) $(FW_FILE1) $(FW_FILE2)
clean :
rm -rf user/*.o driver/*.o $(TARGET_OUT) $(FW_FILE_1) $(FW_FILE_2)
$(RM) $(patsubst %.c,%.o,$(SRCS)) $(TARGET)
purge : clean
$(RM) $(FW_FILE_1) $(FW_FILE_2)

View file

@ -1,23 +1,27 @@
all : execute_reflash page.mpfs push
IP ?= 192.168.4.1
.PHONY : all clean push
CFLAGS = -std=gnu99 -Wall -Wextra -O2 -march=native
all : execute_reflash page.mpfs push
mfsmaker : mfsmaker.c
gcc -o $@ $^
$(CC) $(CFLAGS) -o $@ $^
page.mpfs : mfsmaker page
# cat to_compress/*.js | gzip -9 > page/compressed.js.gz
./mfsmaker page page.mpfs
pushtodev : pushtodev.c
gcc -o $@ $^
$(CC) $(CFLAGS) -o $@ $^
execute_reflash : execute_reflash.c md5.c
gcc -o $@ $^
$(CC) $(CFLAGS) -o $@ $^
push : pushtodev page.mpfs
./pushtodev $(IP) 65536 page.mpfs
# ./pushtodev $(IP) 1048576 page.mpfs
clean :
rm -rf mfsmaker page.mpfs pushtodev execute_reflash
$(RM) mfsmaker page.mpfs pushtodev execute_reflash

View file

@ -4,6 +4,7 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <sys/time.h>
#include <sys/poll.h>