diff --git a/Makefile b/Makefile index 0b0c655..f1920fe 100644 --- a/Makefile +++ b/Makefile @@ -2,10 +2,17 @@ # 'separate' - Separate espfs and binaries, no OTA upgrade # 'combined' - Combined firmware blob, no OTA upgrade # 'ota' - Combined firmware blob with OTA upgrades. -OUTPUT_TYPE=ota +OUTPUT_TYPE=combined +#OUTPUT_TYPE=separate +#OUTPUT_TYPE=ota #SPI flash size, in K ESP_SPI_FLASH_SIZE=1024 +#0: QIO, 1: QOUT, 2: DIO, 3: DOUT +ESP_FLASH_MODE=2 +#0: 40MHz, 1: 26MHz, 2: 20MHz, 0xf: 80MHz +ESP_FLASH_FREQ_DIV=0 + ifeq ("$(OUTPUT_TYPE)","separate") #Set the pos and length of the ESPFS here. If these are undefined, the rest of the Makefile logic @@ -36,11 +43,6 @@ ESPBAUD ?= 460800 #Appgen path and name APPGEN ?= $(SDK_BASE)/tools/gen_appbin.py -#0: QIO, 1: QOUT, 2: DIO, 3: DOUT -ESP_FLASH_MODE ?= 0 -#0: 40MHz, 1: 26MHz, 2: 20MHz, 0xf: 80MHz -ESP_FLASH_FREQ_DIV ?= 0 - # name for the target project TARGET = httpd @@ -134,6 +136,17 @@ INCDIR := $(addprefix -I,$(SRC_DIR)) EXTRA_INCDIR := $(addprefix -I,$(EXTRA_INCDIR)) MODULE_INCDIR := $(addsuffix /include,$(INCDIR)) +define maplookup +$(patsubst $(strip $(1)):%,%,$(filter $(strip $(1)):%,$(2))) +endef + +ESP_FLASH_SIZE_IX=$(call maplookup,$(ESP_SPI_FLASH_SIZE),512:0 1024:2 2048:5 4096:6) +ESPTOOL_FREQ=$(call maplookup,$(ESP_FLASH_FREQ_DIV),0:40m 1:26m, 2:20m 0xf:80m) +ESPTOOL_MODE=$(call maplookup,$(ESP_FLASH_MODE),0:qio 1:qout 2:dio 3:dout) +ESPTOOL_SIZE=$(call maplookup,$(ESP_SPI_FLASH_SIZE),512:4m 256:2m 1024:8m 2048:16m 4096:32m) + +ESPTOOL_OPTS=--port $(ESPPORT) --baud $(ESPBAUD) +ESPTOOL_FLASHDEF=--flash_freq $(ESPTOOL_FREQ) --flash_mode $(ESPTOOL_MODE) --flash_size $(ESPTOOL_SIZE) vpath %.c $(SRC_DIR) diff --git a/Makefile.combined b/Makefile.combined index 09e5c20..d71e89f 100644 --- a/Makefile.combined +++ b/Makefile.combined @@ -25,8 +25,8 @@ $(FW_BASE): $(TARGET_OUT) $(Q) $(ESPTOOL) elf2image $(TARGET_OUT) --output $@/ 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) $(ESPTOOL_OPTS) write_flash $(ESPTOOL_FLASHDEF) 0x00000 $(FW_BASE)/0x00000.bin 0x40000 $(FW_BASE)/0x40000.bin blankflash: - $(Q) $(ESPTOOL) --port $(ESPPORT) --baud $(ESPBAUD) write_flash 0x7E000 $(SDK_BASE)/bin/blank.bin + $(Q) $(ESPTOOL) $(ESPTOOL_OPTS) write_flash $(ESPTOOL_FLASHDEF) 0x7E000 $(SDK_BASE)/bin/blank.bin diff --git a/Makefile.ota b/Makefile.ota index 7e19c45..7e57f2f 100644 --- a/Makefile.ota +++ b/Makefile.ota @@ -72,13 +72,13 @@ $(FW_BASE): $(TARGET_BIN) - 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) $(ESPTOOL_OPTS) write_flash $(ESPTOOL_FLASHDEF) 0x00000 "$(SDK_BASE)/bin/boot_v1.4(b1).bin" 0x1000 $(TARGET_BIN_USR1) +# $(Q) $(ESPTOOL) $(ESPTOOL_OPTS) write_flash $(ESPTOOL_FLASHDEF) 0x00000 $(FW_BASE)/0x00000.bin 0x40000 $(FW_BASE)/0x40000.bin blankflash: - $(Q) $(ESPTOOL) --port $(ESPPORT) --baud $(ESPBAUD) write_flash 0x7E000 $(SDK_BASE)/bin/blank.bin + $(Q) $(ESPTOOL) $(ESPTOOL_OPTS) write_flash $(ESPTOOL_FLASHDEF) 0x7E000 $(SDK_BASE)/bin/blank.bin 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 + $(Q) $(ESPTOOL) $(ESPTOOL_OPTS) write_flash $(ESPTOOL_FLASHDEF) $(ESPFS_POS) libesphttpd/webpages.espfs diff --git a/Makefile.separate b/Makefile.separate index a059808..c558efe 100644 --- a/Makefile.separate +++ b/Makefile.separate @@ -18,11 +18,11 @@ $(FW_BASE): $(TARGET_OUT) $(Q) $(ESPTOOL) elf2image $(TARGET_OUT) --output $@/ 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) $(ESPTOOL_OPTS) write_flash $(ESPTOOL_FLASHDEF) 0x00000 $(FW_BASE)/0x00000.bin 0x40000 $(FW_BASE)/0x40000.bin blankflash: - $(Q) $(ESPTOOL) --port $(ESPPORT) --baud $(ESPBAUD) write_flash 0x7E000 $(SDK_BASE)/bin/blank.bin + $(Q) $(ESPTOOL) $(ESPTOOL_OPTS) write_flash $(ESPTOOL_FLASHDEF) 0x7E000 $(SDK_BASE)/bin/blank.bin 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 + $(Q) $(ESPTOOL) $(ESPTOOL_OPTS) write_flash $(ESPTOOL_FLASHDEF) $(ESPFS_POS) libesphttpd/webpages.espfs diff --git a/user/user_main.c b/user/user_main.c index 8763a5b..b8c984c 100644 --- a/user/user_main.c +++ b/user/user_main.c @@ -64,7 +64,7 @@ general ones. Authorization things (like authBasic) act as a 'barrier' and should be placed above the URLs they protect. */ HttpdBuiltInUrl builtInUrls[]={ - {"*", cgiRedirectApClientToHostname, "esp8266.local"}, + {"*", cgiRedirectApClientToHostname, "esp8266.nonet"}, {"/", cgiRedirect, "/index.tpl"}, {"/flash.bin", cgiReadFlash, NULL}, {"/led.tpl", cgiEspFsTemplate, tplLed},