igrr / atproto

AT protocol library
Other
63 stars 15 forks source link

wdt_reset after closing server and receiving data #14

Open saper-2 opened 9 years ago

saper-2 commented 9 years ago

As martinayotte (from ESP8266 Forum @ Post ) noticed, that after closing server by CIPCLOSE , and sending data to closed server causes watchdog to bite :wink: esp and reboot him. I do confirm this issue. I run a test, and sent data after AT+CIPCLOSE=6 and there is log from terminal:

+CWSTAT:1

+CWSTAT:5
AT+IDBG?

+IDBG:0
AT+IDBG=1

OK
AT+GMR

0.1 rev. 00eefbd

OK
AT+GMM

Chip: ESP8266EX
Firmware: https://github.com/igrr/atproto

OK
AT+GMEM

38296
data  : 0x3ffe8000 ~ 0x3ffe8a54, len: 2644
rodata: 0x3ffe8a60 ~ 0x3ffeab4c, len: 8428
bss   : 0x3ffeab50 ~ 0x3fff2010, len: 2330
OK
AT+CIPSTA?

+CIPSTA:"192.168.2.14"
AT+CIPLISTEN="TCP",2222

+CIPLISTEN:6,2222,2048

+CIPACCEPT:0,"192.168.2.26"

+CIPDR:0,29

+CIPDISCONNECT:0
AT+CIPRD=0

+CIPRD:0,29

This TCP server is working :)

OK
AT+CIPCLOSE=6

OK
Fatal exception (29): 
epc1=0x4000df98, epc2=0x00000000, epc3=0x00000000, excvaddr=0x0000000c, depc=0x00000000

 ets Jan  8 2013,rst cause:4, boot mode:(3,6)

wdt reset
load 0x40100000, len 23716, room 16 
tail 4
chksum 0xd5
load 0x3ffe8000, len 2644, room 4 
tail 0
chksum 0x80
load 0x3ffe8a60, len 8428, room 8 
tail 4
chksum 0x72
csum 0x72

+CWSTAT:1

+CWSTAT:5
igrr commented 9 years ago

It seems that calling espconn_disconnect does not work for server (listening) sockets. Looking at the source of espconn_tcp_server function (lwip/app/espconn_tcp.c), they just create a pcb, set it up the server, and never store this pcb anywhere! So there's no way to "stop" the server because they have leaked the pointer to it. Other than do a reset, of course.

saper-2 commented 9 years ago

Ok, I don't need anyway to stop server, now I think there is problem with freeing connection-contexts. I posted on esp8266 forum about this.