Added flash upload function

pull/30/head
Jeroen Domburg 10 years ago
parent 7242baead5
commit 2fb0e70d9f
  1. 18
      Makefile
  2. 8
      Makefile.ota
  3. 2
      libesphttpd
  4. 24
      user/user_main.c

@ -2,12 +2,12 @@
# 'separate' - Separate espfs and binaries, no OTA upgrade # 'separate' - Separate espfs and binaries, no OTA upgrade
# 'combined' - Combined firmware blob, no OTA upgrade # 'combined' - Combined firmware blob, no OTA upgrade
# 'ota' - Combined firmware blob with OTA upgrades. # 'ota' - Combined firmware blob with OTA upgrades.
OUTPUT_TYPE=combined #OUTPUT_TYPE=combined
#OUTPUT_TYPE=separate #OUTPUT_TYPE=separate
#OUTPUT_TYPE=ota OUTPUT_TYPE=ota
#SPI flash size, in K #SPI flash size, in K
ESP_SPI_FLASH_SIZE=1024 ESP_SPI_FLASH_SIZE_K=1024
#0: QIO, 1: QOUT, 2: DIO, 3: DOUT #0: QIO, 1: QOUT, 2: DIO, 3: DOUT
ESP_FLASH_MODE=2 ESP_FLASH_MODE=2
#0: 40MHz, 1: 26MHz, 2: 20MHz, 0xf: 80MHz #0: 40MHz, 1: 26MHz, 2: 20MHz, 0xf: 80MHz
@ -15,8 +15,7 @@ ESP_FLASH_FREQ_DIV=0
ifeq ("$(OUTPUT_TYPE)","separate") ifeq ("$(OUTPUT_TYPE)","separate")
#Set the pos and length of the ESPFS here. If these are undefined, the rest of the Makefile logic #In case of separate ESPFS and binaries, set the pos and length of the ESPFS here.
#will automatically put the webpages in the binary.
ESPFS_POS = 0x12000 ESPFS_POS = 0x12000
ESPFS_SIZE = 0x2E000 ESPFS_SIZE = 0x2E000
endif endif
@ -118,6 +117,11 @@ else
CFLAGS += -DESPFS_POS=$(ESPFS_POS) -DESPFS_SIZE=$(ESPFS_SIZE) CFLAGS += -DESPFS_POS=$(ESPFS_POS) -DESPFS_SIZE=$(ESPFS_SIZE)
endif endif
ifeq ("$(OUTPUT_TYPE)","ota")
CFLAGS += -DOTA_FLASH_SIZE_K=$(ESP_SPI_FLASH_SIZE_K)
endif
#Define default target. If not defined here the one in the included Makefile is used as the default one. #Define default target. If not defined here the one in the included Makefile is used as the default one.
default-tgt: all default-tgt: all
@ -140,10 +144,10 @@ define maplookup
$(patsubst $(strip $(1)):%,%,$(filter $(strip $(1)):%,$(2))) $(patsubst $(strip $(1)):%,%,$(filter $(strip $(1)):%,$(2)))
endef endef
ESP_FLASH_SIZE_IX=$(call maplookup,$(ESP_SPI_FLASH_SIZE),512:0 1024:2 2048:5 4096:6) ESP_FLASH_SIZE_IX=$(call maplookup,$(ESP_SPI_FLASH_SIZE_K),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_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_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_SIZE=$(call maplookup,$(ESP_SPI_FLASH_SIZE_K),512:4m 256:2m 1024:8m 2048:16m 4096:32m)
ESPTOOL_OPTS=--port $(ESPPORT) --baud $(ESPBAUD) ESPTOOL_OPTS=--port $(ESPPORT) --baud $(ESPBAUD)
ESPTOOL_FLASHDEF=--flash_freq $(ESPTOOL_FREQ) --flash_mode $(ESPTOOL_MODE) --flash_size $(ESPTOOL_SIZE) ESPTOOL_FLASHDEF=--flash_freq $(ESPTOOL_FREQ) --flash_mode $(ESPTOOL_MODE) --flash_size $(ESPTOOL_SIZE)

@ -2,8 +2,8 @@
#the espfs combined into the flash binary. #the espfs combined into the flash binary.
# linker script used for the linker step # linker script used for the linker step
LD_SCRIPT_USR1 := eagle.app.v6.new.$(ESP_SPI_FLASH_SIZE).app1.ld LD_SCRIPT_USR1 := eagle.app.v6.new.$(ESP_SPI_FLASH_SIZE_K).app1.ld
LD_SCRIPT_USR2 := eagle.app.v6.new.$(ESP_SPI_FLASH_SIZE).app2.ld LD_SCRIPT_USR2 := eagle.app.v6.new.$(ESP_SPI_FLASH_SIZE_K).app2.ld
TARGET_OUT_USR1 := $(addprefix $(BUILD_BASE)/,$(TARGET).user1.out) TARGET_OUT_USR1 := $(addprefix $(BUILD_BASE)/,$(TARGET).user1.out)
TARGET_OUT_USR2 := $(addprefix $(BUILD_BASE)/,$(TARGET).user2.out) TARGET_OUT_USR2 := $(addprefix $(BUILD_BASE)/,$(TARGET).user2.out)
@ -15,7 +15,7 @@ TARGET_BIN := $(TARGET_BIN_USR1) $(TARGET_BIN_USR2)
#Convert SPI size into arg for appgen. Format: no=size #Convert SPI size into arg for appgen. Format: no=size
FLASH_MAP_CONV:=0:512 2:1024 5:2048 6:4096 FLASH_MAP_CONV:=0:512 2:1024 5:2048 6:4096
ESP_FLASH_SIZE_IX:=$(patsubst %:$(ESP_SPI_FLASH_SIZE),%,$(filter %:$(ESP_SPI_FLASH_SIZE),$(FLASH_MAP_CONV))) ESP_FLASH_SIZE_IX:=$(patsubst %:$(ESP_SPI_FLASH_SIZE_K),%,$(filter %:$(ESP_SPI_FLASH_SIZE_K),$(FLASH_MAP_CONV)))
define genappbin define genappbin
$(1): $$(APP_AR) $(1): $$(APP_AR)
@ -41,7 +41,7 @@ $(eval $(call genappbin,$(TARGET_OUT_USR2),$$(LD_SCRIPT_USR2),$$(TARGET_BIN_USR2
ldscript_memspecific.ld: ldscript_memspecific.ld:
$(vecho) "GEN $@" $(vecho) "GEN $@"
$(Q) echo "MEMORY { irom0_0_seg : org = 0x40240000, len = "$$(printf "0x%X" $$(($(ESP_SPI_FLASH_SIZE)-0x4000)))" }"> ldscript_memspecific.ld $(Q) echo "MEMORY { irom0_0_seg : org = 0x40240000, len = "$$(printf "0x%X" $$(($(ESP_SPI_FLASH_SIZE_K)*1024-0x4000)))" }"> ldscript_memspecific.ld
#define makeuser #define makeuser

@ -1 +1 @@
Subproject commit 90102be16ff46065bd831ad5b70dc7a7aec08294 Subproject commit 7b601225b50f6a929400720409c37b941dea39e0

@ -47,10 +47,22 @@ int myPassFn(HttpdConnData *connData, int no, char *user, int userLen, char *pas
} }
#ifdef ESPFS_POS #ifdef ESPFS_POS
CgiUploadEspfsParams espfsParams={ CgiUploadFlashDef uploadParams={
.espFsPos=ESPFS_POS, .type=CGIFLASH_TYPE_ESPFS,
.espFsSize=ESPFS_SIZE .fw1Pos=ESPFS_POS,
.fw2Pos=0,
.fwSize=ESPFS_SIZE,
}; };
#define INCLUDE_FLASH_FNS
#endif
#ifdef OTA_FLASH_SIZE_K
CgiUploadFlashDef uploadParams={
.type=CGIFLASH_TYPE_FW,
.fw1Pos=0x1000,
.fw2Pos=((OTA_FLASH_SIZE_K*1024)/2)+0x1000,
.fwSize=((OTA_FLASH_SIZE_K*1024)/2)-0x1000,
};
#define INCLUDE_FLASH_FNS
#endif #endif
/* /*
@ -71,8 +83,10 @@ HttpdBuiltInUrl builtInUrls[]={
{"/index.tpl", cgiEspFsTemplate, tplCounter}, {"/index.tpl", cgiEspFsTemplate, tplCounter},
{"/led.cgi", cgiLed, NULL}, {"/led.cgi", cgiLed, NULL},
{"/flash/download", cgiReadFlash, NULL}, {"/flash/download", cgiReadFlash, NULL},
{"/flash/next", cgiGetFirmwareNext, NULL}, #ifdef INCLUDE_FLASH_FNS
{"/flash/upload", cgiUploadFirmware, NULL}, {"/flash/next", cgiGetFirmwareNext, &uploadParams},
{"/flash/upload", cgiUploadFirmware, &uploadParams},
#endif
{"/flash/reboot", cgiRebootFirmware, NULL}, {"/flash/reboot", cgiRebootFirmware, NULL},
//Routines to make the /wifi URL and everything beneath it work. //Routines to make the /wifi URL and everything beneath it work.

Loading…
Cancel
Save