Add VERIFY_FLASH_WRITE as remedy for #15

This commit is contained in:
con-f-use 2016-08-14 18:50:55 +02:00
parent f3061cb82d
commit 75c3c2d5c7
9 changed files with 54 additions and 17 deletions

Binary file not shown.

Binary file not shown.

View file

@ -3,9 +3,9 @@ include makeconf.inc # Look here for user configuration
.PHONY : all clean cleanall netburn burnweb burn
uniq = $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))
FW_FILE1 = image.elf-0x00000.bin
FW_FILE2 = image.elf-0x40000.bin
TARGET = image.elf
FW_FILE1 = $(TARGET)-0x00000.bin
FW_FILE2 = $(TARGET)-0x40000.bin
SRCS = \
driver/uart.c \
@ -49,7 +49,7 @@ $(TARGET) : $(SRCS)
ifeq ($(CHIP), 8285)
burn : $(FW_FILE1) $(FW_FILE2)
($(ESPTOOL_PY) --port $(PORT) write_flash -fs 8m -fm dout 0x00000 0x00000.bin 0x40000 0x40000.bin)||(true)
($(ESPTOOL_PY) --port $(PORT) write_flash -fs 8m -fm dout 0x00000 $(FW_FILE1) 0x40000 $(FW_FILE2))||(true)
else ifeq ($(CHIP), 8266)
burn : $(FW_FILE1) $(FW_FILE2)
($(ESPTOOL_PY) --port $(PORT) write_flash 0x00000 $(FW_FILE1) 0x40000 $(FW_FILE2))||(true)
@ -68,10 +68,12 @@ netburn : $(FW_FILE1) $(FW_FILE2)
@cd web && $(MAKE) $(MFLAGS) $(MAKEOVERRIDES) execute_reflash
web/execute_reflash $(IP) $(FW_FILE1) $(FW_FILE2)
netweb :
@cd web && $(MAKE) $(MFLAGS) $(MAKEOVERRIDES) push
clean :
$(RM) $(patsubst %.c,%.o,$(SRCS)) $(TARGET)
purge : clean
@cd web && $(MAKE) $(MFLAGS) $(MAKEOVERRIDES) clean
$(RM) $(FW_FILE1) $(FW_FILE2)

View file

@ -7,7 +7,7 @@
This project is based off of the I2S interface for the mp3 player found here:
https://github.com/espressif/esp8266_mp3_decoder/
If you want more information about the build environment, etc. You should
If you want more information about the build environment, etc. You should
check out the regular WS2812 driver, found here: https://github.com/cnlohr/ws2812esp8266
WARNING: This subproject is very jankey! It's about stable, but I don't think it's quite there yet.
@ -20,7 +20,14 @@ The audio data is taken from TOUT, but must be kept between 0 and 1V.
## Notes
./makeconf.inc has a few variables that make uses for building and flashing the firmware.
./makeconf.inc has a few variables that Make uses for building and flashing the firmware.
Most notably the location of the toolchain for the esp8266/85 on your system.
You should edit them according to your preferences or better add `export ESP_ROOT='/path/to/the/esp-open-sdk'` to your bashrc.
If you have problems with burning the firmware or transfering page data over network (`make netburn` or `make netweb`), you should try uncommenting
OPTS += -DVERIFY_FLASH_WRITE
in `makeconf.inc`. This way the esp checks if the flash is written correctly.
Especially with some ESP-01 modules there has been a problem with the flash
not being written correctly.

View file

@ -36,8 +36,8 @@ struct totalscan_t
int scanplace = 0;
static void ICACHE_FLASH_ATTR scandone(void *arg, STATUS status)
{
scaninfo *c = arg;
struct bss_info *inf;
scaninfo *c = arg;
struct bss_info *inf;
if( need_to_switch_back_to_soft_ap == 1 )
need_to_switch_back_to_soft_ap = 2;
@ -143,11 +143,22 @@ int ICACHE_FLASH_ATTR issue_command(char * buffer, int retsize, char *pusrdata,
spi_flash_write( nr, (uint32*)buffer, (datlen/4)*4 );
ExitCritical();
#ifdef VERIFY_FLASH_WRITE
#define VFW_SIZE 128
int jj;
uint8_t __attribute__ ((aligned (32))) buf[VFW_SIZE];
for(jj=0; jj<datlen; jj+=VFW_SIZE) {
spi_flash_read( nr+jj, (uint32*)buf, (datlen/4)*4 );
if( ets_memcmp( buf, buffer+jj, VFW_SIZE ) != 0 ) goto failw;
}
#endif
buffend += ets_sprintf(buffend, "FW%d\r\n", nr );
break;
}
}
buffend += ets_sprintf(buffend, "!FW\r\n" );
failw:
buffend += ets_sprintf(buffend, "!FW\r\n" );
break;
case 'x': case 'X': //Flash Write Hex (FX#\t#\tDATTAAAAA) <- a = byte pos. b = length (in hex-pairs). Generally used for web-browser.
if( colon )
@ -184,6 +195,20 @@ int ICACHE_FLASH_ATTR issue_command(char * buffer, int retsize, char *pusrdata,
spi_flash_write( nr, (uint32*)buffend, (datlen/4)*4 );
ExitCritical();
#ifdef VERIFY_FLASH_WRITE
// uint8_t __attribute__ ((aligned (32))) buf[1300];
// spi_flash_read( nr, (uint32*)buf, (datlen/4)*4 );
// if( ets_memcmp( buf, buffer, (datlen/4)*4 ) != 0 ) break;
// Rather do it in chunks, to avoid allocationg huge buf
#define VFW_SIZE 128
int jj;
uint8_t __attribute__ ((aligned (32))) buf[VFW_SIZE];
for(jj=0; jj<datlen; jj+=VFW_SIZE) {
spi_flash_read( nr+jj, (uint32*)buf, (datlen/4)*4 );
if( ets_memcmp( buf, buffer+jj, VFW_SIZE ) != 0 ) goto failfx;
}
#endif
buffend += ets_sprintf(buffend, "FX%d\t%d\r\n", nr, siz );
break;
}
@ -248,10 +273,10 @@ failfx:
{
bssid_set = ets_str2macaddr( mac, colon3 )?1:0;
if( ( mac[0] == 0x00 || mac[0] == 0xff ) &&
( mac[1] == 0x00 || mac[1] == 0xff ) &&
( mac[2] == 0x00 || mac[2] == 0xff ) &&
( mac[3] == 0x00 || mac[3] == 0xff ) &&
( mac[4] == 0x00 || mac[4] == 0xff ) &&
( mac[1] == 0x00 || mac[1] == 0xff ) &&
( mac[2] == 0x00 || mac[2] == 0xff ) &&
( mac[3] == 0x00 || mac[3] == 0xff ) &&
( mac[4] == 0x00 || mac[4] == 0xff ) &&
( mac[5] == 0x00 || mac[5] == 0xff ) ) bssid_set = 0;
}
@ -330,9 +355,9 @@ failfx:
{
if( strcmp( colon3, enctypes[k] ) == 0 )
config.authmode = k;
}
}
}
#endif
int chan = (colon4)?my_atoi(colon4):config.channel;
@ -426,10 +451,10 @@ failfx:
int i, r;
buffend += ets_sprintf( buffend, "WR%d\n", scanplace );
for( i = 0; i < scanplace && buffend - buffer < retsize - 64; i++ )
{
buffend += ets_sprintf( buffend, "#%s\t%s\t%d\t%d\t%s\n",
buffend += ets_sprintf( buffend, "#%s\t%s\t%d\t%d\t%s\n",
totalscan[i].name, totalscan[i].mac, totalscan[i].rssi, totalscan[i].channel, enctypes[totalscan[i].encryption] );
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -11,6 +11,8 @@ SDK_DEFAULT ?= $(HOME)/esp8266/esp-open-sdk
ESP_GCC_VERS ?= 4.8.5
OPTS += -DICACHE_FLASH
#OPTS += THIS_DEBUG
#OPTS += -DVERIFY_FLASH_WRITE
#OPTS += -DFREQ=12500
###########################################################################VARS
@ -32,3 +34,4 @@ ifeq ($(strip $(ESP_ROOT)),)
$(warning Warning: No shell variable 'ESP_ROOT', using '$(SDK_DEFAULT)')
ESP_ROOT := $(SDK_DEFAULT)
endif