Upload ESP FS to other not used partition

pull/112/head
Timo Wischer 9 years ago
parent 21bdae68c5
commit e7678550df
  1. 24
      Makefile
  2. 4
      esp-link/cgiflash.c
  3. 9
      esp-link/main.c
  4. 10
      espfs/espfs.c

@ -84,7 +84,7 @@ LED_SERIAL_PIN ?= 14
# --------------- esp-link modules config options ---------------
# Optional Modules mqtt
#MODULES ?= mqtt rest syslog
#MODULES ?= mqtt rest syslog cmd
# --------------- esphttpd config options ---------------
@ -124,6 +124,7 @@ USE_OTHER_PARTITION_FOR_ESPFS ?= yes
HTML_PATH = $(abspath ./html)/
WIFI_PATH = $(HTML_PATH)wifi/
ET_PART1 ?= 0x01000
ifeq ("$(FLASH_SIZE)","512KB")
# Winbond 25Q40 512KB flash, typ for esp-01 thru esp-11
@ -133,6 +134,7 @@ ESP_FLASH_FREQ_DIV ?= 0 # 0->40Mhz
ESP_FLASH_MAX ?= 241664 # max bin file for 512KB flash: 236KB
ET_FS ?= 4m # 4Mbit flash size in esptool flash command
ET_FF ?= 40m # 40Mhz flash speed in esptool flash command
ET_PART2 ?= 0x41000
ET_BLANK ?= 0x7E000 # where to flash blank.bin to erase wireless settings
else ifeq ("$(FLASH_SIZE)","1MB")
@ -143,6 +145,7 @@ ESP_FLASH_FREQ_DIV ?= 15 # 15->80MHz
ESP_FLASH_MAX ?= 503808 # max bin file for 1MB flash: 492KB
ET_FS ?= 8m # 8Mbit flash size in esptool flash command
ET_FF ?= 80m # 80Mhz flash speed in esptool flash command
ET_PART2 ?= 0x81000
ET_BLANK ?= 0xFE000 # where to flash blank.bin to erase wireless settings
else ifeq ("$(FLASH_SIZE)","2MB")
@ -156,6 +159,7 @@ ESP_FLASH_FREQ_DIV ?= 15 # 15->80Mhz
ESP_FLASH_MAX ?= 503808 # max bin file for 1MB flash: 492KB
ET_FS ?= 16m # 16Mbit flash size in esptool flash command
ET_FF ?= 80m # 80Mhz flash speed in esptool flash command
ET_PART2 ?= 0x101000
ET_BLANK ?= 0x1FE000 # where to flash blank.bin to erase wireless settings
else
@ -214,7 +218,7 @@ endif
# which modules (subdirectories) of the project to include in compiling
LIBRARIES_DIR = libraries
MODULES += espfs httpd user serial cmd esp-link
MODULES += espfs httpd user serial esp-link
MODULES += $(foreach sdir,$(LIBRARIES_DIR),$(wildcard $(sdir)/*))
EXTRA_INCDIR = include .
@ -395,12 +399,24 @@ wiflash: all
./wiflash $(ESP_HOSTNAME) $(FW_BASE)/user1.bin $(FW_BASE)/user2.bin
baseflash: all
$(Q) $(ESPTOOL) --port $(ESPPORT) --baud $(ESPBAUD) write_flash 0x01000 $(FW_BASE)/user1.bin
$(Q) $(ESPTOOL) --port $(ESPPORT) --baud $(ESPBAUD) write_flash $(ET_PART1) $(FW_BASE)/user1.bin
ifeq ("$(USE_OTHER_PARTITION_FOR_ESPFS)","yes")
flash: all
$(Q) $(ESPTOOL) --port $(ESPPORT) --baud $(ESPBAUD) write_flash -fs $(ET_FS) -ff $(ET_FF) \
0x00000 "$(SDK_BASE)/bin/boot_v1.5.bin" \
$(ET_PART1) $(FW_BASE)/user1.bin \
$(ET_PART2) build/espfs.img \
$(ET_BLANK) $(SDK_BASE)/bin/blank.bin
else
flash: all
$(Q) $(ESPTOOL) --port $(ESPPORT) --baud $(ESPBAUD) write_flash -fs $(ET_FS) -ff $(ET_FF) \
0x00000 "$(SDK_BASE)/bin/boot_v1.5.bin" 0x01000 $(FW_BASE)/user1.bin \
0x00000 "$(SDK_BASE)/bin/boot_v1.5.bin" \
$(ET_PART1) $(FW_BASE)/user1.bin \
$(ET_BLANK) $(SDK_BASE)/bin/blank.bin
endif
ifeq ($(OS),Windows_NT)
tools/$(HTML_COMPRESSOR):

@ -20,6 +20,8 @@ Some flash handling cgi routines. Used for reading the existing flash and updati
#include "cgiflash.h"
#include "espfs.h"
#define SPI_FLASH_MEM_EMU_START_ADDR 0x40200000
#ifdef CGIFLASH_DBG
#define DBG(format, ...) do { os_printf(format, ## __VA_ARGS__); } while(0)
#else
@ -57,7 +59,7 @@ static int ICACHE_FLASH_ATTR getNextSPIFlashAddr(void) {
}
uint32* const ICACHE_FLASH_ATTR getNextFlashAddr(void) {
const uint32 addr = 0x4200000 + getNextSPIFlashAddr();
const uint32 addr = SPI_FLASH_MEM_EMU_START_ADDR + getNextSPIFlashAddr();
/* cast as a pointer, because it is the real address in this system,
* for accessing the SPI flash position through the mem emu

@ -152,15 +152,16 @@ void user_init(void) {
serledInit();
// Wifi
wifiInit();
// init the flash filesystem with the html stuff
#ifdef USE_OTHER_PARTITION_FOR_ESPFS
uint32* addr = getNextFlashAddr();
espFsInit(addr);
const EspFsInitResult res = espFsInit(addr);
#else
espFsInit(&_binary_espfs_img_start);
//EspFsInitResult res = espFsInit(&_binary_espfs_img_start);
//os_printf("espFsInit %s\n", res?"ERR":"ok");
const EspFsInitResult res = espFsInit(&_binary_espfs_img_start);
#endif
os_printf("espFsInit %s (%u)\n", res?"ERR":"ok", res);
// mount the http handlers
httpdInit(builtInUrls, 80);
#ifdef SERIAL_BRIDGE

@ -69,8 +69,12 @@ a memory exception, crashing the program.
bool ICACHE_FLASH_ATTR espFsIsImage(const void* const flashAddress) {
// check if there is valid header at address
const EspFsHeader* const testHeader = (EspFsHeader*)flashAddress;
return (testHeader->magic == ESPFS_MAGIC);
EspFsHeader testHeader;
os_memcpy(&testHeader, flashAddress, sizeof(EspFsHeader));
#ifdef ESPFS_DBG
os_printf("ESP FS magic is 0x%08x, should 0x%08x, at %p\n", (uint32)testHeader.magic, ESPFS_MAGIC, flashAddress);
#endif
return (testHeader.magic == ESPFS_MAGIC);
}
@ -81,7 +85,7 @@ EspFsInitResult ICACHE_FLASH_ATTR espFsInit(void *flashAddress) {
}
// check if there is valid header at address
if (espFsIsImage(flashAddress)) {
if ( !espFsIsImage(flashAddress) ) {
return ESPFS_INIT_RESULT_NO_IMAGE;
}

Loading…
Cancel
Save