khcnz / Espressif2Arduino

Allows for OTA updates from an Espressif ESP8266 V2 OTA image to an Arduino image by replacing the bootloader and dynamically patching the binary memory offsets
25 stars 13 forks source link

Solid LED when flashing Tasmota #9

Open StSimmons opened 7 years ago

StSimmons commented 7 years ago

So, I bought a few new Sonoff switches (the basic one).

I rebuilt everything with the 8266 config (Espressif and Sonoff-Tasmota). Flashing to Espressif worked without a hitch using SonOTA. I built in my wifi-credentials to handle the fallback case.

Now, I saw it grab the snoff bin from my HTTP server, and after some time the device has ended up with a solid LED and is seen on the network (it is pingable).

When it is restarted (flipping the mains) it starts with a fast flash, followed by a slow flash. One it connects to the wifi, it maintains a solid flash.

None of the buttons etc work, nor does it host a web server. I assume this means it is still running Espressif. (Tasmota wouldn't have kept my wifi network IIRC).

Any ideas on what this could be?

StSimmons commented 7 years ago

FYI: I build Sonoff-Tasmota using the instructions on https://github.com/arendst/Sonoff-Tasmota/wiki/Upload

I then copied the firmware.bin over to the HTTP server as sonoff-1024.bin

khcnz commented 7 years ago

Solid flash do you mean constantly illuminated?

Do you have an FTDI so you can see the serial output? You don't need to actually solder you can just connect with pogo pins.

I have a build coming shortly that carries the wifi credentials over to tasmota.

StSimmons commented 7 years ago

I found the error:

                                                   Downloading rom to 0x001000-0x076150 in 1024 byte blocksTEST
Size: 4477
          address=0x001000, bytes=1024, len=479568

Exception (9):
epc1=0x400041dc epc2=0x00000000 epc3=0x00000000 excvaddr=0x3ffef871 depc=0x00000000

ctx: cont 
sp: 3fff0b20 end: 3fff0e50 offset: 01a0

>>>stack>>>
3fff0cc0:  00000000 400041bc 3fff000a 00000400  
3fff0cd0:  00000100 40004ac0 00000100 00001000  
3fff0ce0:  00000100 3ffef871 3fffc718 00001000  
3fff0cf0:  00000400 00000004 40105854 00000400  
3fff0d00:  3ffef871 3ffef871 00001000 4028438f  
3fff0d10:  3fffc718 3ffef871 3fff0cf0 3fff0d20  
3fff0d20:  00001000 40283e52 00001000 00000400  
3fff0d30:  00075150 3fff1d04 3ffefd68 40282529  
3fff0d40:  3fff1e8c 3fff1d04 3fff1744 0000000f  
3fff0d50:  0000000c 40000050 3f011388 3fff1cdc  
3fff0d60:  0000001f 00000015 3fff1ea4 0000000f  
3fff0d70:  00000004 3fff1bfc 0000000f 00000000  
3fff0d80:  3fff1c14 0000001f 00000011 3fff1c3c  
3fff0d90:  0000000f 00000000 00000000 00000000  
3fff0da0:  000000c8 00076150 3ffefd00 00000000  
3fff0db0:  00000000 00000000 00000000 200301e9  
3fff0dc0:  00000080 00076150 00000000 00000001  
3fff0dd0:  00000080 00000001 000000e9 00080000  
3fff0de0:  00000003 3ffef871 00000400 016aa101  
3fff0df0:  60000200 00020000 ffffffff 3ffefe24  
3fff0e00:  00000001 00000000 3ffefd68 40282617  
3fff0e10:  00000080 3ffe8709 00000003 3ffefe24  
3fff0e20:  00000001 00000000 3ffefd68 40282720  
3fff0e30:  3fffdad0 00000000 3ffefe1c 40284fc0  
3fff0e40:  feefeffe feefeffe 3ffefe30 40100718  
<<<stack<<<

Looks like the exception (9) is LoadStoreAlignmentCause, which points at some alignment issue when reading/writing the flash. Any ideas?

khcnz commented 7 years ago

Yes this is very useful - but i'm not sure how this error could occur when writing a 1024byte block to 0x1000.. (as that is 4byte aligned..) will do some thinking / research.

StSimmons commented 7 years ago

I worked it out and fixed it.

The issue is that the buffer itself is not 4 byte aligned. I needed to add some arbitrary packing in order to get it to a 4 byte alignment.

Since then, I’ve managed to get 15 Sonoffs flashed OTA.

I’ll clean up the code and do a PRX

khcnz commented 7 years ago

I was just reading about aligning the in memory buffer in some code here https://github.com/esp8266/Arduino/blob/master/cores/esp8266/spiffs_hal.cpp - something like this i presume uint8_t tmp[4] attribute((aligned(4))) = {0xff, 0xff, 0xff, 0xff};

Odd I never came across it in all my testing (good or bad luck?)

anyway - thanks - I have some other changes to come as well so will include this change.

khcnz commented 7 years ago

Which version of arduino / esp did you use (or platform.io?)

StSimmons commented 7 years ago

I built Espressif2Arduino with Arduino IDE 1.8.3 (and the 2.3.0 esp SDK).

I built Sonoff-Tasmota with Platform.io.

cputoaster commented 7 years ago

I seem to hit the same problem, did you commit a solution yet?

StSimmons commented 7 years ago

The change does not appear to have been committed. At this point, you will need to flash with UART (to recover from that state).

cputoaster commented 7 years ago

Thanks, good to know