moved espfs at end of irom0 resulting in single flash chunk

v0.9.0
Thorsten von Eicken 10 years ago
parent a016a27c0e
commit 5a85dae22a
  1. 41
      Makefile
  2. 0
      html/cats/cross-eyed-cat.jpg-
  3. 0
      html/cats/kitten-loves-toy.jpg-
  4. 4
      html/index.tpl
  5. 10
      user/cgiflash.c
  6. 9
      user/user_main.c

@ -27,10 +27,6 @@ YUI-COMPRESSOR ?= /usr/bin/yui-compressor
#any support in the browser. #any support in the browser.
USE_HEATSHRINK ?= yes USE_HEATSHRINK ?= yes
#Position and maximum length of espfs in flash memory
ESPFS_POS = 0x12000
ESPFS_SIZE = 0x2E000
# -------------- End of esphttpd config options ------------- # -------------- End of esphttpd config options -------------
@ -80,7 +76,7 @@ CFLAGS = -Os -ggdb -std=c99 -Werror -Wpointer-arith -Wundef -Wall -Wl,-EL -fno-
LDFLAGS = -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static LDFLAGS = -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static
# linker script used for the above linkier step # linker script used for the above linkier step
LD_SCRIPT = eagle.app.v6.ld LD_SCRIPT := eagle.esphttpd.v6.ld
# various paths from the SDK used in this project # various paths from the SDK used in this project
SDK_LIBDIR = lib SDK_LIBDIR = lib
@ -91,6 +87,8 @@ SDK_INCDIR = include include/json
CC := $(XTENSA_TOOLS_ROOT)xtensa-lx106-elf-gcc CC := $(XTENSA_TOOLS_ROOT)xtensa-lx106-elf-gcc
AR := $(XTENSA_TOOLS_ROOT)xtensa-lx106-elf-ar AR := $(XTENSA_TOOLS_ROOT)xtensa-lx106-elf-ar
LD := $(XTENSA_TOOLS_ROOT)xtensa-lx106-elf-gcc LD := $(XTENSA_TOOLS_ROOT)xtensa-lx106-elf-gcc
OBJCP := $(XTENSA_TOOLS_ROOT)xtensa-lx106-elf-objcopy
OBJDP := $(XTENSA_TOOLS_ROOT)xtensa-lx106-elf-objdump
#### ####
@ -100,15 +98,17 @@ SRC_DIR := $(MODULES)
BUILD_DIR := $(addprefix $(BUILD_BASE)/,$(MODULES)) BUILD_DIR := $(addprefix $(BUILD_BASE)/,$(MODULES))
SDK_LIBDIR := $(addprefix $(SDK_BASE)/,$(SDK_LIBDIR)) SDK_LIBDIR := $(addprefix $(SDK_BASE)/,$(SDK_LIBDIR))
SDK_LDDIR := $(addprefix $(SDK_BASE)/,$(SDK_LDDIR))
SDK_INCDIR := $(addprefix -I$(SDK_BASE)/,$(SDK_INCDIR)) SDK_INCDIR := $(addprefix -I$(SDK_BASE)/,$(SDK_INCDIR))
SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.c)) SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.c))
OBJ := $(patsubst %.c,$(BUILD_BASE)/%.o,$(SRC)) OBJ := $(patsubst %.c,$(BUILD_BASE)/%.o,$(SRC)) $(BUILD_BASE)/espfs_img.o
LIBS := $(addprefix -l,$(LIBS)) LIBS := $(addprefix -l,$(LIBS))
APP_AR := $(addprefix $(BUILD_BASE)/,$(TARGET)_app.a) APP_AR := $(addprefix $(BUILD_BASE)/,$(TARGET)_app.a)
TARGET_OUT := $(addprefix $(BUILD_BASE)/,$(TARGET).out) TARGET_OUT := $(addprefix $(BUILD_BASE)/,$(TARGET).out)
LD_SCRIPT := $(addprefix -T$(SDK_BASE)/$(SDK_LDDIR)/,$(LD_SCRIPT)) #LD_SCRIPT := $(addprefix -T$(SDK_BASE)/$(SDK_LDDIR)/,$(LD_SCRIPT))
LD_SCRIPT := -Tbuild/$(LD_SCRIPT)
INCDIR := $(addprefix -I,$(SRC_DIR)) INCDIR := $(addprefix -I,$(SRC_DIR))
EXTRA_INCDIR := $(addprefix -I,$(EXTRA_INCDIR)) EXTRA_INCDIR := $(addprefix -I,$(EXTRA_INCDIR))
@ -143,9 +143,10 @@ endef
all: checkdirs $(TARGET_OUT) $(FW_BASE) all: checkdirs $(TARGET_OUT) $(FW_BASE)
$(TARGET_OUT): $(APP_AR) $(TARGET_OUT): $(APP_AR) build/eagle.esphttpd.v6.ld
$(vecho) "LD $@" $(vecho) "LD $@"
$(Q) $(LD) -L$(SDK_LIBDIR) $(LD_SCRIPT) $(LDFLAGS) -Wl,--start-group $(LIBS) $(APP_AR) -Wl,--end-group -o $@ $(Q) $(LD) -L$(SDK_LIBDIR) $(LD_SCRIPT) $(LDFLAGS) -Wl,--start-group $(LIBS) $(APP_AR) -Wl,--end-group -o $@
$(Q) $(OBJDP) -x $(TARGET_OUT) | egrep espfs_img
$(FW_BASE): $(TARGET_OUT) $(FW_BASE): $(TARGET_OUT)
$(vecho) "FW $@" $(vecho) "FW $@"
@ -165,7 +166,7 @@ $(BUILD_DIR):
flash: $(TARGET_OUT) $(FW_BASE) flash: $(TARGET_OUT) $(FW_BASE)
$(Q) $(ESPTOOL) --port $(ESPPORT) --baud $(ESPBAUD) write_flash 0x00000 $(FW_BASE)/0x00000.bin 0x40000 $(FW_BASE)/0x40000.bin $(Q) $(ESPTOOL) --port $(ESPPORT) --baud $(ESPBAUD) write_flash 0x00000 $(FW_BASE)/0x00000.bin 0x40000 $(FW_BASE)/0x40000.bin
webpages.espfs: html/ html/wifi/ espfs/mkespfsimage/mkespfsimage $(BUILD_BASE)/espfs_img.o: html/ html/wifi/ espfs/mkespfsimage/mkespfsimage
ifeq ("$(COMPRESS_W_YUI)","yes") ifeq ("$(COMPRESS_W_YUI)","yes")
$(Q) rm -rf html_compressed; $(Q) rm -rf html_compressed;
$(Q) cp -r html html_compressed; $(Q) cp -r html html_compressed;
@ -173,13 +174,21 @@ ifeq ("$(COMPRESS_W_YUI)","yes")
$(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 "*.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) 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}" $(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
# mkespfsimage will compress html, css and js files with gzip by default if enabled # override with -g cmdline parameter
# override with -g cmdline parameter $(Q) cd html_compressed; find | ../espfs/mkespfsimage/mkespfsimage > ../build/espfs.img; cd ..;
$(Q) cd html_compressed; find | ../espfs/mkespfsimage/mkespfsimage > ../webpages.espfs; cd ..;
else else
$(Q) cd html; find | ../espfs/mkespfsimage/mkespfsimage > ../webpages.espfs; cd .. $(Q) cd html; find . \! -name \*- | ../espfs/mkespfsimage/mkespfsimage > ../build/espfs.img; cd ..
endif endif
$(Q) cd build; $(OBJCP) -I binary -O elf32-xtensa-le -B xtensa --rename-section .data=.espfs \
espfs.img espfs_img.o; cd ..
# edit the loader script to add the espfs section to the end of irom with a 4KB alignment to
# allow the section to be reflashed at runtime, if you run tight in space you could change the
# alignment to 4 and forego the reflash capability
build/eagle.esphttpd.v6.ld: $(SDK_LDDIR)/eagle.app.v6.ld
sed -e '/\.irom\.text/{' -e 'a . = ALIGN (4096);' -e 'a *(.espfs)' -e '}' \
$(SDK_LDDIR)/eagle.app.v6.ld >$@
blankflash: blankflash:
$(Q) $(ESPTOOL) --port $(ESPPORT) --baud $(ESPBAUD) write_flash 0x7E000 $(SDK_BASE)/bin/blank.bin $(Q) $(ESPTOOL) --port $(ESPPORT) --baud $(ESPBAUD) write_flash 0x7E000 $(SDK_BASE)/bin/blank.bin
@ -187,10 +196,6 @@ blankflash:
espfs/mkespfsimage/mkespfsimage: espfs/mkespfsimage/ espfs/mkespfsimage/mkespfsimage: espfs/mkespfsimage/
$(Q) $(MAKE) -C espfs/mkespfsimage USE_HEATSHRINK="$(USE_HEATSHRINK)" GZIP_COMPRESSION="$(GZIP_COMPRESSION)" $(Q) $(MAKE) -C espfs/mkespfsimage USE_HEATSHRINK="$(USE_HEATSHRINK)" GZIP_COMPRESSION="$(GZIP_COMPRESSION)"
htmlflash: webpages.espfs
$(Q) if [ $$(stat -c '%s' webpages.espfs) -gt $$(( $(ESPFS_SIZE) )) ]; then echo "webpages.espfs too big!"; false; fi
$(Q) $(ESPTOOL) --port $(ESPPORT) --baud $(ESPBAUD) write_flash $(ESPFS_POS) webpages.espfs
clean: clean:
$(Q) rm -f $(APP_AR) $(Q) rm -f $(APP_AR)
$(Q) rm -f $(TARGET_OUT) $(Q) rm -f $(TARGET_OUT)

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 48 KiB

@ -17,9 +17,9 @@ been loaded <b>%counter%</b> times.
</p> </p>
<p>And because we're on the Internets now, here are the required pictures of cats:<br /> <p>And because we're on the Internets now, here are the required pictures of cats:<br />
<img src="cats/cross-eyed-cat.jpg"><br /> <!--img src="cats/cross-eyed-cat.jpg"><br /-->
<img src="cats/junge-katze-iv.jpg"><br /> <img src="cats/junge-katze-iv.jpg"><br />
<img src="cats/kitten-loves-toy.jpg"><br /> <!--img src="cats/kitten-loves-toy.jpg"><br /-->
</p> </p>
</div> </div>
</body></html> </body></html>

@ -5,9 +5,9 @@ Some flash handling cgi routines. Used for reading the existing flash and updati
/* /*
* ---------------------------------------------------------------------------- * ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42): * "THE BEER-WARE LICENSE" (Revision 42):
* Jeroen Domburg <jeroen@spritesmods.com> wrote this file. As long as you retain * Jeroen Domburg <jeroen@spritesmods.com> wrote this file. As long as you retain
* this notice you can do whatever you want with this stuff. If we meet some day, * this notice you can do whatever you want with this stuff. If we meet some day,
* and you think this stuff is worth it, you can buy me a beer in return. * and you think this stuff is worth it, you can buy me a beer in return.
* ---------------------------------------------------------------------------- * ----------------------------------------------------------------------------
*/ */
@ -45,13 +45,15 @@ int ICACHE_FLASH_ATTR cgiUploadEspfs(HttpdConnData *connData) {
//Connection aborted. Clean up. //Connection aborted. Clean up.
return HTTPD_CGI_DONE; return HTTPD_CGI_DONE;
} }
/* TODO: fix this check so it calculates the end of the irom segment minus the start of the espfs
if(connData->post->len > ESPFS_SIZE){ if(connData->post->len > ESPFS_SIZE){
// The uploaded file is too large // The uploaded file is too large
os_printf("ESPFS file too large\n"); os_printf("ESPFS file too large\n");
httpdSend(connData, "HTTP/1.0 500 Internal Server Error\r\nServer: esp8266-httpd/0.3\r\nConnection: close\r\nContent-Type: text/plain\r\nContent-Length: 24\r\n\r\nESPFS image loo large.\r\n", -1); httpdSend(connData, "HTTP/1.0 500 Internal Server Error\r\nServer: esp8266-httpd/0.3\r\nConnection: close\r\nContent-Type: text/plain\r\nContent-Length: 24\r\n\r\nESPFS image loo large.\r\n", -1);
return HTTPD_CGI_DONE; return HTTPD_CGI_DONE;
} }
*/
// The source should be 4byte aligned, so go ahead and flash whatever we have // The source should be 4byte aligned, so go ahead and flash whatever we have
int address = ESPFS_POS + connData->post->received - connData->post->buffLen; int address = ESPFS_POS + connData->post->received - connData->post->buffLen;
if(address % SPI_FLASH_SEC_SIZE == 0){ if(address % SPI_FLASH_SEC_SIZE == 0){

@ -85,14 +85,21 @@ static void ICACHE_FLASH_ATTR prHeapTimerCb(void *arg) {
} }
#endif #endif
// address of espfs binary blob
extern uint8_t _binary_espfs_img_start;
//Main routine. Initialize stdout, the I/O, filesystem and the webserver and we're done. //Main routine. Initialize stdout, the I/O, filesystem and the webserver and we're done.
void user_init(void) { void user_init(void) {
stdoutInit(); stdoutInit();
ioInit(); ioInit();
os_delay_us(10000L);
os_printf("\n\nInitializing esphttpd\n");
// 0x40200000 is the base address for spi flash memory mapping, ESPFS_POS is the position // 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. // where image is written in flash that is defined in Makefile.
espFsInit((void*)(0x40200000 + ESPFS_POS)); //EspFsInitResult res = espFsInit((void*)(0x40200000 + ESPFS_POS));
EspFsInitResult res = espFsInit(&_binary_espfs_img_start);
os_printf("espFsInit(0x%08lx) returned %d\n", (uint32_t)&_binary_espfs_img_start, res);
httpdInit(builtInUrls, 80); httpdInit(builtInUrls, 80);
#ifdef SHOW_HEAP_USE #ifdef SHOW_HEAP_USE
os_timer_disarm(&prHeapTimer); os_timer_disarm(&prHeapTimer);

Loading…
Cancel
Save