Skip to content

Commit

Permalink
Separating libesphttpd code
Browse files Browse the repository at this point in the history
  • Loading branch information
Spritetm committed Jun 10, 2015
1 parent 98304bc commit c35a585
Show file tree
Hide file tree
Showing 55 changed files with 57 additions and 1,087 deletions.
5 changes: 3 additions & 2 deletions .gitignore
@@ -1,9 +1,10 @@
build/
firmware/
espfs/mkespfsimage/*.o
espfs/mkespfsimage/mkespfsimage
webpages.espfs
libesphttpd.a
espfs/espfstest/*.o
espfs/espfstest/espfstest
*.DS_Store
html_compressed/
html_compressed/
libwebpages-espfs.a
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

121 changes: 54 additions & 67 deletions Makefile
@@ -1,13 +1,22 @@
#Position and maximum length of espfs in flash memory. This can be undefined. In this case
#the webpages will be linked in into the executable file. If this is defined, please do a
#'make htmlflash' to flash the espfs into the ESPs memory.
ESPFS_POS = 0x12000
ESPFS_SIZE = 0x2E000

# Directory the Makefile is in. Please don't include other Makefiles before this.
THISDIR:=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))

#Include httpd config from lower level, if it exists
-include ../esphttpdconfig.mk


#Default options. If you want to change them, please create ../esphttpdconfig.mk with the options you want in it.
GZIP_COMPRESSION ?= no
COMPRESS_W_YUI ?= no
YUI-COMPRESSOR ?= /usr/bin/yui-compressor
USE_HEATSHRINK ?= yes



# Output directors to store intermediate compiled files
# relative to the project directory
BUILD_BASE = build
FW_BASE = firmware

# Base directory for the compiler. Needs a / at the end; if not set it'll use the tools that are in
# the PATH.
Expand All @@ -16,64 +25,42 @@ XTENSA_TOOLS_ROOT ?=
# base directory of the ESP8266 SDK package, absolute
SDK_BASE ?= /opt/Espressif/ESP8266_SDK

#Esptool.py path and port
ESPTOOL ?= esptool.py
ESPPORT ?= /dev/ttyUSB0
#ESPDELAY indicates seconds to wait between flashing the two binary images
ESPDELAY ?= 3
ESPBAUD ?= 460800


# name for the target project
TARGET = httpd
LIB = libesphttpd.a

# which modules (subdirectories) of the project to include in compiling
MODULES = user
EXTRA_INCDIR = include libesphttpd/include
MODULES = espfs core util
EXTRA_INCDIR = ./include \
. \
lib/heatshrink/

# libraries used in this project, mainly provided by the SDK
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

# linker flags used to generate the main object file
LDFLAGS = -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static

# linker script used for the above linkier step
LD_SCRIPT = eagle.app.v6.ld

# various paths from the SDK used in this project
SDK_LIBDIR = lib
SDK_LDDIR = ld
SDK_INCDIR = include include/json
SDK_INCDIR = include

# select which tools to use as compiler, librarian and linker
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

####
#### no user configurable options below here
####
SRC_DIR := $(MODULES)
BUILD_DIR := $(addprefix $(BUILD_BASE)/,$(MODULES))

SDK_LIBDIR := $(addprefix $(SDK_BASE)/,$(SDK_LIBDIR))
SDK_INCDIR := $(addprefix -I$(SDK_BASE)/,$(SDK_INCDIR))

SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.c))
OBJ := $(patsubst %.c,$(BUILD_BASE)/%.o,$(SRC))
LIBS := $(addprefix -l,$(LIBS))
APP_AR := $(addprefix $(BUILD_BASE)/,$(TARGET)_app.a)
TARGET_OUT := $(addprefix $(BUILD_BASE)/,$(TARGET).out)

LD_SCRIPT := $(addprefix -T$(SDK_BASE)/$(SDK_LDDIR)/,$(LD_SCRIPT))

INCDIR := $(addprefix -I,$(SRC_DIR))
EXTRA_INCDIR := $(addprefix -I,$(EXTRA_INCDIR))
Expand All @@ -96,14 +83,6 @@ 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
#Hardcoded espfs location: Pass espfs position to rest of code
CFLAGS += -DESPFS_POS=$(ESPFS_POS) -DESPFS_SIZE=$(ESPFS_SIZE)
endif

vpath %.c $(SRC_DIR)

define compile-objects
Expand All @@ -112,23 +91,12 @@ $1/%.o: %.c
$(Q) $(CC) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS) -c $$< -o $$@
endef

.PHONY: all checkdirs clean libesphttpd

all: checkdirs $(TARGET_OUT) $(FW_BASE)
.PHONY: all checkdirs clean webpages.espfs

libesphttpd:
make -C libesphttpd
all: checkdirs $(LIB) webpages.espfs libwebpages-espfs.a

$(TARGET_OUT): $(APP_AR) libesphttpd
$(vecho) "LD $@"
$(Q) $(LD) -Llibesphttpd -L$(SDK_LIBDIR) $(LD_SCRIPT) $(LDFLAGS) -Wl,--start-group $(LIBS) $(APP_AR) -Wl,--end-group -o $@

$(FW_BASE): $(TARGET_OUT)
$(vecho) "FW $@"
$(Q) mkdir -p $@
$(Q) $(ESPTOOL) elf2image $(TARGET_OUT) --output $@/

$(APP_AR): $(OBJ)
$(LIB): $(OBJ)
$(vecho) "AR $@"
$(Q) $(AR) cru $@ $^

Expand All @@ -138,21 +106,40 @@ $(BUILD_DIR):
$(Q) mkdir -p $@


flash: $(TARGET_OUT) $(FW_BASE)
$(Q) $(ESPTOOL) --port $(ESPPORT) --baud $(ESPBAUD) write_flash 0x00000 $(FW_BASE)/0x00000.bin 0x40000 $(FW_BASE)/0x40000.bin
webpages.espfs: $(HTMLDIR) espfs/mkespfsimage/mkespfsimage
ifeq ("$(COMPRESS_W_YUI)","yes")
$(Q) rm -rf html_compressed;
$(Q) cp -r ../html html_compressed;
$(Q) echo "Compression assets with yui-compressor. This may take a while..."
$(Q) for file in `find html_compressed -type f -name "*.js"`; do $(YUI-COMPRESSOR) --type js $$file -o $$file; done
$(Q) for file in `find html_compressed -type f -name "*.css"`; do $(YUI-COMPRESSOR) --type css $$file -o $$file; done
$(Q) awk "BEGIN {printf \"YUI compression ratio was: %.2f%%\\n\", (`du -b -s html_compressed/ | sed 's/\([0-9]*\).*/\1/'`/`du -b -s ../html/ | sed 's/\([0-9]*\).*/\1/'`)*100}"
# mkespfsimage will compress html, css and js files with gzip by default if enabled
# override with -g cmdline parameter
$(Q) cd html_compressed; find | $(THISDIR)/espfs/mkespfsimage/mkespfsimage > $(THISDIR)/webpages.espfs; cd ..;
else
$(Q) cd ../html; find | $(THISDIR)/espfs/mkespfsimage/mkespfsimage > $(THISDIR)/webpages.espfs; cd ..
endif

blankflash:
$(Q) $(ESPTOOL) --port $(ESPPORT) --baud $(ESPBAUD) write_flash 0x7E000 $(SDK_BASE)/bin/blank.bin
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

htmlflash: libesphttpd
$(Q) if [ $$(stat -c '%s' libesphttpd/webpages.espfs) -gt $$(( $(ESPFS_SIZE) )) ]; then echo "webpages.espfs too big!"; false; fi
$(Q) $(ESPTOOL) --port $(ESPPORT) --baud $(ESPBAUD) write_flash $(ESPFS_POS) libesphttpd/webpages.espfs
espfs/mkespfsimage/mkespfsimage: espfs/mkespfsimage/
$(Q) $(MAKE) -C espfs/mkespfsimage USE_HEATSHRINK="$(USE_HEATSHRINK)" GZIP_COMPRESSION="$(GZIP_COMPRESSION)"

clean:
$(Q) make -C libesphttpd clean
$(Q) rm -f $(APP_AR)
$(Q) rm -f $(TARGET_OUT)
$(Q) rm -f $(LIB)
$(Q) find $(BUILD_BASE) -type f | xargs rm -f
$(Q) make -C espfs/mkespfsimage/ clean
$(Q) rm -rf $(FW_BASE)
$(Q) rm -f webpages.espfs
ifeq ("$(COMPRESS_W_YUI)","yes")
$(Q) rm -rf html_compressed
endif

$(foreach bdir,$(BUILD_DIR),$(eval $(call compile-objects,$(bdir))))
86 changes: 0 additions & 86 deletions README

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
28 changes: 0 additions & 28 deletions esphttpdconfig.mk

This file was deleted.

Binary file removed html/cats/cross-eyed-cat.jpg
Binary file not shown.
Binary file removed html/cats/junge-katze-iv.jpg
Binary file not shown.
Binary file removed html/cats/kitten-loves-toy.jpg
Binary file not shown.
25 changes: 0 additions & 25 deletions html/index.tpl

This file was deleted.

15 changes: 0 additions & 15 deletions html/led.tpl

This file was deleted.

17 changes: 0 additions & 17 deletions html/style.css

This file was deleted.

2 changes: 0 additions & 2 deletions html/wifi/140medley.min.js

This file was deleted.

0 comments on commit c35a585

Please sign in to comment.