Added option to link webpages into the main binary
This commit is contained in:
@@ -20,9 +20,10 @@ ESPDELAY ?= 3
|
||||
ESPBAUD ?= 460800
|
||||
|
||||
#Position and maximum length of espfs in flash memory
|
||||
ESPFS_POS = 0x12000
|
||||
ESPFS_SIZE = 0x2E000
|
||||
|
||||
#This can be undefined. In this case the webpages will be linked in into the
|
||||
#file.
|
||||
#ESPFS_POS = 0x12000
|
||||
#ESPFS_SIZE = 0x2E000
|
||||
|
||||
|
||||
# name for the target project
|
||||
@@ -35,12 +36,14 @@ MODULES = user
|
||||
EXTRA_INCDIR = include libesphttpd/include
|
||||
|
||||
# libraries used in this project, mainly provided by the SDK
|
||||
LIBS = c gcc hal phy pp net80211 wpa main lwip esphttpd
|
||||
LIBS = c gcc hal phy pp net80211 wpa main lwip
|
||||
#Add in esphttpd lib
|
||||
LIBS += esphttpd
|
||||
|
||||
# compiler flags using during compilation of source files
|
||||
CFLAGS = -Os -ggdb -std=c99 -Werror -Wpointer-arith -Wundef -Wall -Wl,-EL -fno-inline-functions \
|
||||
-nostdlib -mlongcalls -mtext-section-literals -D__ets__ -DICACHE_FLASH -D_STDINT_H \
|
||||
-Wno-address -DESPFS_POS=$(ESPFS_POS) -DESPFS_SIZE=$(ESPFS_SIZE)
|
||||
-Wno-address
|
||||
|
||||
# linker flags used to generate the main object file
|
||||
LDFLAGS = -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static
|
||||
@@ -97,6 +100,14 @@ ifeq ("$(USE_HEATSHRINK)","yes")
|
||||
CFLAGS += -DESPFS_HEATSHRINK
|
||||
endif
|
||||
|
||||
ifeq ("$(ESPFS_POS)","")
|
||||
#No hardcoded espfs position: link it in with the binaries.
|
||||
LIBS += -lwebpages-espfs
|
||||
else
|
||||
#Pass espfs position to rest of code
|
||||
CFLAGS += -DESPFS_POS=$(ESPFS_POS) -DESPFS_SIZE=$(ESPFS_SIZE)
|
||||
endif
|
||||
|
||||
vpath %.c $(SRC_DIR)
|
||||
|
||||
define compile-objects
|
||||
|
||||
@@ -7,3 +7,4 @@ espfs/espfstest/*.o
|
||||
espfs/espfstest/espfstest
|
||||
*.DS_Store
|
||||
html_compressed/
|
||||
libwebpages-espfs.a
|
||||
+11
-1
@@ -50,6 +50,7 @@ SDK_INCDIR = include include/json
|
||||
CC := $(XTENSA_TOOLS_ROOT)xtensa-lx106-elf-gcc
|
||||
AR := $(XTENSA_TOOLS_ROOT)xtensa-lx106-elf-ar
|
||||
LD := $(XTENSA_TOOLS_ROOT)xtensa-lx106-elf-gcc
|
||||
OBJCOPY := $(XTENSA_TOOLS_ROOT)xtensa-lx106-elf-objcopy
|
||||
|
||||
|
||||
|
||||
@@ -95,7 +96,7 @@ endef
|
||||
|
||||
.PHONY: all checkdirs clean webpages.espfs
|
||||
|
||||
all: checkdirs $(LIB) webpages.espfs
|
||||
all: checkdirs $(LIB) webpages.espfs libwebpages-espfs.a
|
||||
|
||||
|
||||
$(LIB): $(OBJ)
|
||||
@@ -124,8 +125,17 @@ else
|
||||
$(Q) cd ../html; find | $(THISDIR)/espfs/mkespfsimage/mkespfsimage > $(THISDIR)/webpages.espfs; cd ..
|
||||
endif
|
||||
|
||||
libwebpages-espfs.a: webpages.espfs
|
||||
$(Q) $(OBJCOPY) -I binary -O elf32-xtensa-le -B xtensa --rename-section .data=.irom0.literal \
|
||||
--redefine-sym _binary_webpages_espfs_start=webpages_espfs_start \
|
||||
--redefine-sym _binary_webpages_espfs_end=webpages_espfs_end \
|
||||
--redefine-sym _binary_webpages_espfs_size=webpages_espfs_size \
|
||||
webpages.espfs build/webpages.espfs.o
|
||||
$(Q) $(AR) cru $@ build/webpages.espfs.o
|
||||
|
||||
espfs/mkespfsimage/mkespfsimage: espfs/mkespfsimage/
|
||||
$(Q) $(MAKE) -C espfs/mkespfsimage USE_HEATSHRINK="$(USE_HEATSHRINK)" GZIP_COMPRESSION="$(GZIP_COMPRESSION)"
|
||||
$(Q) $(AR) cru $@ $^
|
||||
|
||||
clean:
|
||||
$(Q) rm -f $(LIB)
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
extern char webpages_espfs_start[];
|
||||
extern char webpages_espfs_end[];
|
||||
extern int webpages_espfs_size;
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "auth.h"
|
||||
#include "espfs.h"
|
||||
#include "captdns.h"
|
||||
#include "webpages-espfs.h"
|
||||
|
||||
//The example can print out the heap use every 3 seconds. You can use this to catch memory leaks.
|
||||
//#define SHOW_HEAP_USE
|
||||
@@ -105,7 +106,11 @@ void user_init(void) {
|
||||
|
||||
// 0x40200000 is the base address for spi flash memory mapping, ESPFS_POS is the position
|
||||
// where image is written in flash that is defined in Makefile.
|
||||
#ifdef ESPFS_POS
|
||||
espFsInit((void*)(0x40200000 + ESPFS_POS));
|
||||
#else
|
||||
espFsInit((void*)(webpages_espfs_start));
|
||||
#endif
|
||||
httpdInit(builtInUrls, 80);
|
||||
#ifdef SHOW_HEAP_USE
|
||||
os_timer_disarm(&prHeapTimer);
|
||||
|
||||
Reference in New Issue
Block a user