From 41181e1cc77e8c821aed76ecbd3741899a6f66e9 Mon Sep 17 00:00:00 2001 From: Jeroen Domburg Date: Tue, 9 Feb 2016 21:55:13 +0800 Subject: [PATCH] Added feature to do upgrade on webpage --- Makefile | 6 +-- Makefile.ota | 23 ++++++------ html/flash/140medley.min.js | 2 + html/flash/index.html | 75 +++++++++++++++++++++++++++++++++++++ html/flash/style.css | 34 +++++++++++++++++ libesphttpd | 2 +- user/user_main.c | 1 + 7 files changed, 128 insertions(+), 15 deletions(-) create mode 100644 html/flash/140medley.min.js create mode 100644 html/flash/index.html create mode 100644 html/flash/style.css diff --git a/Makefile b/Makefile index e652db4..37a74c7 100644 --- a/Makefile +++ b/Makefile @@ -3,12 +3,12 @@ # 'combined' - Combined firmware blob, no OTA upgrade # 'ota' - Combined firmware blob with OTA upgrades. #Please do a 'make clean' after changing this. -OUTPUT_TYPE=separate +#OUTPUT_TYPE=separate #OUTPUT_TYPE=combined -#OUTPUT_TYPE=ota +OUTPUT_TYPE=ota #SPI flash size, in K -ESP_SPI_FLASH_SIZE_K=512 +ESP_SPI_FLASH_SIZE_K=1024 #0: QIO, 1: QOUT, 2: DIO, 3: DOUT ESP_FLASH_MODE=0 #0: 40MHz, 1: 26MHz, 2: 20MHz, 0xf: 80MHz diff --git a/Makefile.ota b/Makefile.ota index ae844bb..966eca9 100644 --- a/Makefile.ota +++ b/Makefile.ota @@ -1,6 +1,9 @@ #Makefile with the options specific to the build of a non-upgradable firmware with #the espfs combined into the flash binary. +# Change tagname to some identifier that's unique for your project. 27 chars max. +TAGNAME ?= "generic" + # linker script used for the linker step LD_MAP_1:=512:eagle.app.v6.new.512.app1.ld 1024:eagle.app.v6.new.1024.app1.ld 2048:eagle.app.v6.new.2048.ld 4096:eagle.app.v6.new.2048.ld @@ -15,6 +18,8 @@ TARGET_OUT := $(TARGET_OUT_USR1) $(TARGET_OUT_USR2) TARGET_BIN_USR1 := $(addprefix $(BUILD_BASE)/,$(TARGET).user1.bin) TARGET_BIN_USR2 := $(addprefix $(BUILD_BASE)/,$(TARGET).user2.bin) TARGET_BIN := $(TARGET_BIN_USR1) $(TARGET_BIN_USR2) +TARGET_OTAFILE := $(addprefix $(BUILD_BASE)/,$(TARGET).ota) + BLANKPOS="$$(printf "0x%X" $$(($(ESP_SPI_FLASH_SIZE_K)*512-0x2000)))" INITDATAPOS="$$(printf "0x%X" $$(($(ESP_SPI_FLASH_SIZE_K)*512-0x4000)))" @@ -23,6 +28,8 @@ INITDATAPOS="$$(printf "0x%X" $$(($(ESP_SPI_FLASH_SIZE_K)*512-0x4000)))" FLASH_MAP_CONV:=0:512 2:1024 5:2048 6:4096 ESP_FLASH_SIZE_IX:=$(maplookup $(ESP_SPI_FLASH_SIZE_K),,$(FLASH_MAP_CONV)) +CFLAGS += -DOTA_TAGNAME=\"$(TAGNAME)\" + define genappbin $(1): $$(APP_AR) $$(vecho) LD $$@ @@ -70,21 +77,15 @@ ldscript_memspecific.ld: #user1.bin: # $(call makeuser,user1.bin,1) +libesphttpd/mkupgimg/mkupgimg: libesphttpd/mkupgimg/ + make -C libesphttpd/mkupgimg/ -$(FW_BASE): $(TARGET_BIN) -# $(vecho) "FW $@" -# $(Q) mkdir -p $@ -# $(Q) $(ESPTOOL) elf2image $(TARGET_OUT) --output $@/ - - +$(FW_BASE): $(TARGET_BIN) libesphttpd/mkupgimg/mkupgimg + $(Q) libesphttpd/mkupgimg/mkupgimg $(TARGET_BIN_USR1) $(TARGET_BIN_USR2) $(TAGNAME) $(TARGET_OTAFILE) flash: $(TARGET_OUT) $(FW_BASE) - $(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 + $(Q) $(ESPTOOL) $(ESPTOOL_OPTS) write_flash $(ESPTOOL_FLASHDEF) 0x00000 "$(SDK_BASE)/bin/boot_v1.5.bin" 0x1000 $(TARGET_BIN_USR1) blankflash: $(Q) $(ESPTOOL) $(ESPTOOL_OPTS) write_flash $(ESPTOOL_FLASHDEF) $(BLANKPOS) $(SDK_BASE)/bin/blank.bin $(INITDATAPOS) $(SDK_BASE)/bin/esp_init_data_default.bin -htmlflash: libesphttpd - $(Q) if [ $$(stat -c '%s' libesphttpd/webpages.espfs) -gt $$(( $(ESPFS_SIZE) )) ]; then echo "webpages.espfs too big!"; false; fi - $(Q) $(ESPTOOL) $(ESPTOOL_OPTS) write_flash $(ESPTOOL_FLASHDEF) $(ESPFS_POS) libesphttpd/webpages.espfs diff --git a/html/flash/140medley.min.js b/html/flash/140medley.min.js new file mode 100644 index 0000000..d1495d1 --- /dev/null +++ b/html/flash/140medley.min.js @@ -0,0 +1,2 @@ +var t=function(a,b){return function(c,d){return a.replace(/#{([^}]*)}/g,function(a,f){return Function("x","with(x)return "+f).call(c,d||b||{})})}},s=function(a,b){return b?{get:function(c){return a[c]&&b.parse(a[c])},set:function(c,d){a[c]=b.stringify(d)}}:{}}(this.localStorage||{},JSON),p=function(a,b,c,d){c=c||document;d=c[b="on"+b];a=c[b]=function(e){d=d&&d(e=e||c.event);return(a=a&&b(e))?b:d};c=this},m=function(a,b,c){b=document;c=b.createElement("p");c.innerHTML=a;for(a=b.createDocumentFragment();b= +c.firstChild;)a.appendChild(b);return a},$=function(a,b){a=a.match(/^(\W)?(.*)/);return(b||document)["getElement"+(a[1]?a[1]=="#"?"ById":"sByClassName":"sByTagName")](a[2])},j=function(a){for(a=0;a<4;a++)try{return a?new ActiveXObject([,"Msxml2","Msxml3","Microsoft"][a]+".XMLHTTP"):new XMLHttpRequest}catch(b){}}; diff --git a/html/flash/index.html b/html/flash/index.html new file mode 100644 index 0000000..d336a6c --- /dev/null +++ b/html/flash/index.html @@ -0,0 +1,75 @@ + +Upgrade firmware + + + + + +
+

Update firmware

+
Loading...
+ + +
+ \ No newline at end of file diff --git a/html/flash/style.css b/html/flash/style.css new file mode 100644 index 0000000..7678ec8 --- /dev/null +++ b/html/flash/style.css @@ -0,0 +1,34 @@ + +body { + background-color: #404040; + font-family: sans-serif; +} + +#main { + background-color: #d0d0FF; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; + border-radius: 5px; + border: 2px solid #000000; + width: 800px; + margin: 0 auto; + padding: 20px +} + +#progressbar { + margin: 10px; + padding: 0; + border: 1px solid #000000; + height: 20px; + width: 200px; + background-color: #808080; +} + +#progressbarinner { + width: 10px; + height: 20px; + border: none; + background-color: #00ff00; +} + + diff --git a/libesphttpd b/libesphttpd index a38909a..cbed5b3 160000 --- a/libesphttpd +++ b/libesphttpd @@ -1 +1 @@ -Subproject commit a38909a9559c5f1562d2933213e4ec6301ef99c3 +Subproject commit cbed5b369459649401dea5e6a3be9700c9af4ef1 diff --git a/user/user_main.c b/user/user_main.c index 862b800..c61235b 100644 --- a/user/user_main.c +++ b/user/user_main.c @@ -102,6 +102,7 @@ CgiUploadFlashDef uploadParams={ .fw1Pos=0x1000, .fw2Pos=((OTA_FLASH_SIZE_K*1024)/2)+0x1000, .fwSize=((OTA_FLASH_SIZE_K*1024)/2)-0x1000, + .tagName=OTA_TAGNAME }; #define INCLUDE_FLASH_FNS #endif