These are chat archives for esp8266/Arduino

16th
Jun 2015
Ivan Grokhotkov
@igrr
Jun 16 2015 05:20
given all those issues with halts, i worked a bit on post-mortem debugging last night. was able to add some hooks to the code which gets called before reset
now i have a nice stack dump after exception or a WDT reset:
Fatal exception (28):
epc1=0x4000bf64, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000067, depc=0x00000000
cont stack

sp: 3ffe9a6c end: 3ffe9e2c



3ffe9a6c:  40101d9b 00000000 00000067 00000000 00000000 00000067 00000000 40101d9e 00000002 00000000 00000000 3fffd870 00000014 0000002d 3ffe9d73 3ffe8988

3ffe9b2c:  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 

3ffe9b6c:  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000032 00000000 00000000 00000000 00000002 00000000 00000002 ffffffff 

3ffe9bac:  4020473a 3ffe9d6d 3ffe897f ffffffff ffffffff 00000000 0000000a 3fffd848 4020486e 00000000 00000000 00000000 00000014 00000067 00000000 3ffe9c4c 

3ffe9bec:  3ffe9c4c 402048de 3ffe9e88 00000000 3fffdc20 3ffe9e5c 3ffe9c7c 40203e40 40204907 00000001 3ffe888b 3ffe9e5c 3fffdc20 00000002 3ffe9c4c 3ffe9c4c 

3ffe9c2c:  00000008 00000000 3ffe9e88 40202715 3ffe9c4c 3ffe9c4c 00000008 40201b9e 402010ae 000003e8 00000002 075bcd15 00000067 3ffe899f 3ffe9e88 40201b80 

3ffe9c6c:  60000000 40026666 00000000 00000000 6d74683c 683c3e6c 3e646165 74656d3c 74682061 652d7074 76697571 6572273d 73657266 63202768 65746e6f 273d746e 

3ffe9cac:  2f273033 69743c3e 3e656c74 38505345 20363632 6f6d6544 69742f3c 3e656c74 7974733c 623e656c 2079646f 6162207b 72676b63 646e756f 6c6f632d 203a726f 

3ffe9cec:  63636323 3b636363 6e6f6620 61662d74 796c696d 7241203a 2c6c6169 6c654820 69746576 202c6163 736e6153 7265532d 203b6669 6f6c6f43 23203a72 30303030 

3ffe9d2c:  203b3838 732f3c7d 656c7974 682f3c3e 3e646165 646f623c 683c3e79 65483e31 206f6c6c 6d6f7266 50534520 36363238 682f3c21 703c3e31 7470553e 3a656d69 

3ffe9d6c:  25203220 3f201520 3ffe9e5c 00000030 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 

3ffe9dac:  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 

3ffe9dec:  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 3ffe9e54 4020186b 00000000 00000000 3ffe8e18 40100518

3ffe9aac:  40101d20 3fffc100 ffffffff 0000001c 0000001c 4000bf64 00000000 00000000 4000bf64 00000030 0000001c 00000000 40002ad0 00000067 00000063 000000ff 

3ffe9aec:  0000ff00 00ff0000 ff00
 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 1464, room 16 
tail 8
chksum 0x7a
csum 0x7a
stack unwinding doesn't work out of the box, but will be relatively easy to add.
sticilface
@sticilface
Jun 16 2015 06:14
Looks good. I was wondering as well if there was any way of adding a call esp.xo
Ivan Grokhotkov
@igrr
Jun 16 2015 06:15
xo?
sticilface
@sticilface
Jun 16 2015 06:15
esp.commit() that could obtain the current commit it was compiled with? Might help with issue tracking / debugging?
Typo sorry
Ivan Grokhotkov
@igrr
Jun 16 2015 06:16
when you install it via boards manager, the commit is part of version number
when you compile from source, it is as easy as running git describe :)
sticilface
@sticilface
Jun 16 2015 06:21
I realise that. But incorporating that as an object in your code is not that easy. Currently say I've got a binary from 2 weeks ago that doesn't crash. It is not that easy for me to 'trace' what IDE I compiled it on as things move so quickly. Unless I start keeping track myself. I've actually got about 5 ides on my machine.
Just a thought. I realise u have a lot on ;)
Kiril Zyapkov
@kzyapkov
Jun 16 2015 09:13

Another newb question: how can these be decyphered?

Fatal exception (2):
epc1=0x3fffdcc0, epc2=0x00000000, epc3=0x00000000, excvaddr=0x3fffdcc0, depc=0x00000000

what does the number in parentheses mean? This probably cannot be answered in a few lines, so pointers to reading materials would be great :)

Ivan Grokhotkov
@igrr
Jun 16 2015 09:14
you need to get a copy of xtensa ISA reference manual... there was a link here somewhere. sec...
Kiril Zyapkov
@kzyapkov
Jun 16 2015 09:16
found it! some 600+ pages of Sunday-afternoon-grade material :)
Ivan Grokhotkov
@igrr
Jun 16 2015 09:17
for the exceptions, search for EXCCAUSE
epc1 is obviously the instruction address where the fault happened
funny that it's in DRAM in your case
Me No Dev
@me-no-dev
Jun 16 2015 09:18
in the repo/docs there is a file that explains them as well
@Makuna or @Links2004 put it up there
Kiril Zyapkov
@kzyapkov
Jun 16 2015 09:19
thanks! to both of them and yourself
Me No Dev
@me-no-dev
Jun 16 2015 09:28
yup
Ivan Grokhotkov
@igrr
Jun 16 2015 09:35
except for the sections related to SPI Flash ROM Layout
Kiril Zyapkov
@kzyapkov
Jun 16 2015 09:54
    spi_flash_read(0x1000, (uint32*)buffer, 0x1000);
    memcpy(buffer, conf, sizeof(rboot_config));
    spi_flash_erase_sector(1);
    spi_flash_write(0x1000, (uint32*)buffer, 0x1000);
looks like the exception is caused by spi_flash_read, this code works fine with a bare SDK app, but acts up when using the arduino core. May this be because it also uses the espconn_* apis, not lwip directly? or some other conflict/incompatibility? placing all functions in flash by default? I'm lost ...
Ivan Grokhotkov
@igrr
Jun 16 2015 09:58
where is your buffer allocated? on the stack, on the heap, or is it a global?
Kiril Zyapkov
@kzyapkov
Jun 16 2015 09:59
heap
Ivan Grokhotkov
@igrr
Jun 16 2015 10:00
spi_flash_read is known to work, it's used in Esp.cpp
also...
you are erasing sector 1
and unless you have heavily modified the flash layout, we've got code in there
so once you erase that sector, the app will crash for sure
the bootloader (eboot) is in sector 0, and the app starts after that, at sector 1
the app is in standard espressif binary image format
Kiril Zyapkov
@kzyapkov
Jun 16 2015 10:05
I'm trying to get rboot to work, I'm using a custom .ld script. It basically does the rboot 2-slot layout (user program starts at 0x02000 and 0x82000) but I kept your .irom0.text changes
Ivan Grokhotkov
@igrr
Jun 16 2015 10:07
ah, okay then.
Kiril Zyapkov
@kzyapkov
Jun 16 2015 10:07
it works ... sometimes.
Ivan Grokhotkov
@igrr
Jun 16 2015 10:08
does this happen after the sketch has started (i.e. in setup method?)
are you able to get some output from the app, or it just crashes?
Kiril Zyapkov
@kzyapkov
Jun 16 2015 10:09
yes, I trigger the update with a UDP packet or button
the app works fine, it crashes when running pieces of the rboot-ota.c code. writing the config sector fails frequently
but also, it frequently just hangs while writing flash and the wdt kicks it
Ivan Grokhotkov
@igrr
Jun 16 2015 10:10
i assume you have wrapped those flash access functions with noInterrupts()/interrupts()?
if not, you really should
Kiril Zyapkov
@kzyapkov
Jun 16 2015 10:11
umm ... the c code doesn't do that. okay, brb
Ivan Grokhotkov
@igrr
Jun 16 2015 10:11
check Esp.cpp, it has some examples
Kiril Zyapkov
@kzyapkov
Jun 16 2015 10:11
I saw you're using wrappers for the SPI flash access functions
I'll try noInterrupts/interrupts, and if that doesn't work I'll try using the wrappers
Ivan Grokhotkov
@igrr
Jun 16 2015 10:12
which wrappers?
spi_flash_read?
Kiril Zyapkov
@kzyapkov
Jun 16 2015 10:13
umm, my bad, I must have seen this elsewhere
Ivan Grokhotkov
@igrr
Jun 16 2015 10:13
yeah, there were some wrappers in the Filesystem code
Russ Mathis
@RussMathis
Jun 16 2015 12:59
Can anyone tell me what WiFiClient.setNoDelay() does? I'm trying to calculate round trip time between server and client and I'm not sure it this method with help stablize the results?
Russ Mathis
@RussMathis
Jun 16 2015 13:05
Thx @me-no-dev ! exactly what I needed to know:)
Kiril Zyapkov
@kzyapkov
Jun 16 2015 13:27
@igrr interrupts/noInterrupts around spi_flash calls didn't help. I prepared a stripped down version of the whole thing, now the failure is completely different -- ESP.restart() doesn't work
Ivan Grokhotkov
@igrr
Jun 16 2015 13:32
what's the error now?
Kiril Zyapkov
@kzyapkov
Jun 16 2015 13:33
it's not consistent, and it actually worked fine last 5-10 times I tried :(
Ivan Grokhotkov
@igrr
Jun 16 2015 13:33
that's the hardest bug to find then)
alon24
@alon24
Jun 16 2015 13:48
is there a chance that ssd1306 will be in soon? or can u repeat the solution? I tried compiling arduino, and using the zip that was mentioned here before, but no go, can anyone who been able to do this, tell me how, again, sorry to talk about this so much, but I need it :)
Ivan Grokhotkov
@igrr
Jun 16 2015 13:49
what exactly is required? some fix for the ssd1306 library?
alon24
@alon24
Jun 16 2015 13:49
I did this with sming, and i want to do it with arduino:
the ssd1306 lib as it comes from adafruit does not compile well with esp - spi, and other issues
Me No Dev
@me-no-dev
Jun 16 2015 13:51
have not tested it with SPI, do not have one
alon24
@alon24
Jun 16 2015 13:51
but i need it with i2c not spi
Me No Dev
@me-no-dev
Jun 16 2015 13:51
have only I2C type
alon24
@alon24
Jun 16 2015 13:51
i am just saying that it does not compile
i2c is great, how/.
(I also need to change the pins, so Wire.pins(x,y)????_
alon24
@alon24
Jun 16 2015 13:53
gr8, ill check at home
Me No Dev
@me-no-dev
Jun 16 2015 13:54
//LCD
void initLcd(){
  Wire.begin(0,2);
  lcd.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  Wire.setClock(400000);
  lcd.setTextSize(1);
  lcd.setTextColor(WHITE);
  lcd.display();
}
alon24
@alon24
Jun 16 2015 13:54
setclock?
Me No Dev
@me-no-dev
Jun 16 2015 13:55
faster i2c
do you know how it works at all?
alon24
@alon24
Jun 16 2015 13:55
yes, bit banging?
Me No Dev
@me-no-dev
Jun 16 2015 13:55
not the implementation of the protocol, but the I2C protocol itself
Kiril Zyapkov
@kzyapkov
Jun 16 2015 13:56
oops
alon24
@alon24
Jun 16 2015 13:56
i know it sends commands, to an address
(3C in this case)
Me No Dev
@me-no-dev
Jun 16 2015 13:57
init the lcd like this: Adafruit_SSD1306 lcd(-1);
alon24
@alon24
Jun 16 2015 13:58
i will do that at home and report back, and thanks
Me No Dev
@me-no-dev
Jun 16 2015 13:58
np
Kiril Zyapkov
@kzyapkov
Jun 16 2015 13:58
here's what I'm trying to do: https://github.com/kzyapkov/esp-arduino-rboot and it works now. fails if I call spiflash* functions from within espconn* callbacks, it seems. but I am most likely entirely wrong again. Still, may be useful for someone
alon24
@alon24
Jun 16 2015 14:01
so @igrr there is a fix for ssd1306 i2c, from @me-no-dev why not add it to arduino esp?
Ivan Grokhotkov
@igrr
Jun 16 2015 14:26
as @me-no-dev pointed out some time ago, it would be best to submit the pull request upstream
for now you can just place the library into your Documents/Arduino/libraries directory
alon24
@alon24
Jun 16 2015 14:27
I will and again my thanks
Michael Miller
@Makuna
Jun 16 2015 15:29
@igrr what are your thoughts on when you are going to look into SSL?
Ivan Grokhotkov
@igrr
Jun 16 2015 15:35

my bucket list right now is as follows:

  • post-mortem debug info (50% done)
  • OTA support in esptool (50%)
  • DNS-SD integrated into mDNS library (0%) — needed for OTA
  • Filesystem (0%, but since this is going to be a second shot it's probably more than that)
  • SSL
  • Async webserver

So this puts SSL somewhere into July timeframe i guess

Michael Miller
@Makuna
Jun 16 2015 15:47
Do you want to offload it? Send me some research pointers and I could start looking into it if you want.
Ivan Grokhotkov
@igrr
Jun 16 2015 16:00
I would certainly appreciate that (as no doubt will the users).
You can get the SSL sources from the esp_iot_sdk_v0.9.3 (inside examples/IoT_Demo) and also in the FreeRTOS port. These two versions are slightly different because freertos has synchronous sockets whereas in the normal SDK they use lwIP.
Now I see two ways of doing this... one is to keep the library from Espressif (libssl.a) but attach our WiFiClient layer not to the public API of libssl (which is linked to espconn) but directly to the axTLS functions. We are lucky that Espressif has not stripped symbols or declared internal functions as static...
This way we can benefit from future updates to this lib from Espressif. But we also get a liability in the form of bugs which they may introduce.
Another way is to start from the source which is available to us and build an open-source version.
Ivan Grokhotkov
@igrr
Jun 16 2015 16:05
We know that Espressif has updated SSL at least twice since that public version was published, perhaps we can get a hint of what they fixed by reading SDK changelogs. One thing which i remember is that they had an issue with a predictable random number generator.
On the Arduino side i think we can have something like a SecureClientContext which will be derived from ClientContext and will take care of calling all the SSL functions. Then we will be able to construct WiFiClient around SecureClientContext or perhaps have a SecureWiFiClient derived from WiFiClient which will have additional TLS-related APIs. Roughly the same goes for the WiFiServer.
testing a build with 1.1.2 sdk, if it works, i'll push the update
krishnaraov
@krishnaraov
Jun 16 2015 18:12

Hi There,

Currently i'm working with ESP8266 ESP-12 Module.

Yesterday i thought of loading pre compiled binaries to flash to connect wifi router ( eagle.flash.bin & eagle.irom0text.bin)

i will let you know steps followed & kindly help on this..

Environment: WINDOWS VISTA, Python2.x, ESPTool

1) i played command "esptool.py -p COM5 flash_id" .. then i got "Manufacturer : C8, Device: 4016"
2) i played command "esptool.py -p COM5 write_flash 0x00000 eagle.flash.bin 0x40000 eagle.irom0text.bin" .. then i got "invalid packet exception" .
3) i played command "esptool.py -p COM5 flash_id" .. then i got below output

Connecting... Traceback (most recent call last): File "D:\esptool-master\esptool.py", line 482, in <module> esp.connect() File "D:\esptool-master\esptool.py", line 158, in connect raise Exception('Failed to connect') Exception: Failed to connect

4) Now, i thought of using AT command to reset the ESP8266.. i used many serial monitor softwares (realterm, arduino, sscomm32E, Terminal, accessport etc..)
5) i made "AT" command .. no response in return.. i tried "AT+RST" command .. no response in return.

Now i'm clueless .. can some body help me out by answer below questions

1) how can i reset my device ( factory settings ) ?
2) how to load my precompiled binary files to flash ?

Thanks in advance & have a great day.

Cheers.

Holger Lembke
@holgerlembke
Jun 16 2015 18:58
Hi!
I try to get the rodata address into my program to walk throu the memory, but I fail....
I end with something like #define RODATA_START_ADDRESS (&_irom0_text_start) but compiler says NO.... Any hints? thanks!
Ivan Grokhotkov
@igrr
Jun 16 2015 19:00
.rodata and .irom0.text are completely different segments... so not sure what you are trying to acheive
also what exactly does the compiler tell you? i doubt it actually said NO.
Me No Dev
@me-no-dev
Jun 16 2015 19:03
extern "C" uint32_t _irom0_text_start;
#define RODATA_START_ADDRESS ((uint32_t)&_irom0_text_start)
but @igrr is right
Ivan Grokhotkov
@igrr
Jun 16 2015 19:03
yeah, smth like that will compile
but still #define RODATA.... _irom0_text makes me think that something's not right
alon24
@alon24
Jun 16 2015 20:11
@me-no-dev thanks, the library seems to be working, i will start on it
Holger Lembke
@holgerlembke
Jun 16 2015 20:12
I'm on my little heap walking utility.
I currently get rodata from system_print_meminfo(); but I want it in a program
Ivan Grokhotkov
@igrr
Jun 16 2015 20:15
if you are walking the heap, i guess you need _heap_start
Holger Lembke
@holgerlembke
Jun 16 2015 20:17
where to get? to walk the heap I need two pointer: to used and free heap list. I see them in a memory dump but I fail to find the starting ping
Holger Lembke
@holgerlembke
Jun 16 2015 20:42
point..
Ivan Grokhotkov
@igrr
Jun 16 2015 20:42
did you check the source of pvPortAlloc / vPortFree?
i had this in my notes somewhere but can't find it right now
i was also interested in overriding the heap management functions...
Holger Lembke
@holgerlembke
Jun 16 2015 20:58
extern char _heap_start;
Serial.println((uint32)&_heap_start,HEX);
Holger Lembke
@holgerlembke
Jun 16 2015 21:19
sneaky bastards. only one list and a bit set in block size
bedtime.