_thread and socket get WDT rest

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
meebox
Posts: 10
Joined: Sat Feb 01, 2020 4:41 am

_thread and socket get WDT rest

Post by meebox » Wed Jan 13, 2021 2:17 am

I write a program that accept client connection in a thread show as below:

Code: Select all

import machine,time,sys
import network
import socket
import _thread

def book_sensor_value():
    while True:
        #time.sleep(0.001)
        try:
            (csock, adr) = sock.accept()
            csock.setblocking(False)
        except:
            pass
        
    sock.close()

sta=network.WLAN(network.STA_IF)
sta.active(True)   
sta.connect('FLAG-SCHOOL','12345678')   
while(not sta.isconnected()):
    pass
print('IP:',sta.ifconfig()[0])   

sock = socket.socket()
sock.bind(('0.0.0.0', 9999))
sock.setblocking(False)
sock.listen(5)

print("Wait for client..")
_thread.start_new_thread(book_sensor_value, ())

while True:
    pass
Running this program without any clients connected always get reset by WDT in a while as log messages shown below:

Code: Select all

IP: 192.168.100.11
Wait for client:
ets Jun  8 2016 00:22:57

rst:0x8 (TG1WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:5148
load:0x40078000,len:12880
load:0x40080400,len:3484
entry 0x40080630
W (58) boot: PRO CPU has been reset by WDT.
W (58) boot: WDT reset info: PRO CPU PC=0x4009b40e
W (58) boot: WDT reset info: APP CPU PC=0x400841d8
I (574) cpu_start: Pro cpu up.
I (574) cpu_start: Application information:
I (574) cpu_start: Compile time:     Sep  2 2020 03:04:09
I (578) cpu_start: ELF file SHA256:  0000000000000000...
I (584) cpu_start: ESP-IDF:          v4.0.1
I (588) cpu_start: Starting app cpu, entry point is 0x40082830
I (0) cpu_start: App cpu up.
I (599) heap_init: Initializing. RAM available for dynamic allocation:
I (606) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
I (612) heap_init: At 3FFB6388 len 00001C78 (7 KiB): DRAM
I (618) heap_init: At 3FFB9A20 len 00004108 (16 KiB): DRAM
I (624) heap_init: At 3FFBDB5C len 00000004 (0 KiB): DRAM
I (630) heap_init: At 3FFCAD78 len 00015288 (84 KiB): DRAM
I (636) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (643) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (649) heap_init: At 4009E9D8 len 00001628 (5 KiB): IRAM
I (655) cpu_start: Pro cpu start user code
I (673) spi_flash: detected chip: generic
I (674) spi_flash: flash io: dio
I (675) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
MicroPython v1.13 on 2020-09-02; ESP32 module with ESP32
Type "help()" for more information.
If I rewrite the program without using _thread, it works well.

I don't know why the program get reset by WDT?

Post Reply